Very basic MySQL/PHP question!

  OK Computer 20:22 01 Feb 2006
Locked

Hi,

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!

Thanks in advance
Martin

  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...

<?php

$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

Best phone camera 2017

Stunning new film posters by Hattie Stewart, Joe Cruz & more

iPad Pro 10.5in (2017) review

28 astuces pour profiter au mieux de votre iPhone