Very basic MySQL/PHP question!

  OK Computer 20:22 01 Feb 06


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 06

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 06

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.

Sniper Elite 4 review: Headshotting Nazis has never felt so good

1995-2015: How technology has changed the world in 20 years

The Best Design, Illustration, Animation and VFX Awards of 2017

WWDC 2017 dates: How to get WWDC 2017 tickets, when is WWDC 2017 and more details announced