I'm an absolute beginner to both PHP and MySQL. I'm simply trying to prove a connection to MySQL using an example in a PHP book. However I keep getting the error message:
[Wed Feb 01 20:00:01 2006] [error] [client 127.0.0.1] PHP Warning: mysql_connect() [ a href='function.mysql-connect'>function.mysql-connect /a>]: Host 'MYHOST' is not allowed to connect to this MySQL server in C:\\Program Files\\Apache Group\\Apache2\\htdocs\\mysqltest.php on line 7
Any ideas? I've searched the net hight and low but don't seem to be getting anywhere!
If you've just installed MySQL then you need to make sure it's started (a windows serivce called MySQL on a windows box).
After that you just use code like this...
$connection = mysql_connect('localhost', 'sa', ') or die('Could not connect: ' . mysql_error()); echo 'Connected successfully';
Note: the sa account is the default administrative account on MySQL and i put it in the code above as an example only as it will be active without you needing to do anything to your MySQL installation. You should not use this to connect from your web app, you should set up a special user using the MySQL command line utility or MySQL Administrator (click here).
This thread is now locked and can not be replied to.