Very basic MySQL/PHP question!

  OK Computer 20:22 01 Feb 2006


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] 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!

Thanks in advance

  harristweed 10:44 04 Feb 2006

I've not heard of connecting with an link!

Have a look at this tutorial, it shows how to set up and get info from a mysql database using php.

click here

  dez82 21:32 13 Feb 2006

Here's the PHP docs for MySQL...

click here

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.

Elsewhere on IDG sites

Honor 9 Lite review

How Social Media has Propelled Political Graphic Design and Art in the Last Decade

The best kids apps for iPhone & iPad 2018

HomePod d’Apple : date de sortie, prix et fiche technique