I'm a newb! I have apache2.2 running, have PHP installed and working. I tried saving a script named mysqltest.php in apache's htdocs directory, but when I try to go to http://localhost/mysqltest.php I get the error that the page cannot be found. I really need some help figuring this out. The content of my 'mysqltest.php' script is below: <html> <head> <title> MySQL Connection Test </title> </head> <body> <h2> <?php mysql_connect("localhost","user","password") or die(mysql_error()); echo("Connected to MySQL"); ?> </h2> </body> </html> I'm not exactly sure what should be set for "user", I remember setting a password when I installed mysql, does it just use the user that I'm signed into Windows with? I'm not sure that is the problem though, please help me out.
If you have cPanel you can find out the mysql username / password there, or create antoher user if you forgot
Hi, As far as I can remember, the default user is "root". But can be changed via the MySQL command line. Regards, Steve
Okay, I changed it to root and set the password, but when I try to reach http://localhost/mysqltest.php I get an error that the page cannot be found Any ideas?
Okay, I'm having a different problem now. I'm getting HTTP 500 Internal Server error when trying to test connecting to mysql via php script. Can someone check my syntax to make sure I didn't screw something up? <?php mysql_connect("localhost","root","password") or die(mysql_error()); echo"Connected to MySQL"; ?> Am I missing any ()'s or anything else? I'm assuming root is the user since it was a default mysql install.
HTTP 500 is a server error, it probably can be made with PHP but i believe it is caused by something else. First of all can you run any other script on your server? If yes then maybe your problem is .htaccess file in your directory, if you have one then try removing it and thn run your script.
check the permissions on your script, make sure the script is readable and executable by all. 755 should do the trick.