Page 1 of 1

Database connection

Posted: Sat Sep 02, 2006 5:13 pm
by Scarophion
HELP!
This is totally doing my nut! I have installed PHP5 and MySQL5 and I'm using IIS. Having major problems. Observe the following (short) code.

Code: Select all

<?php
	echo 'Hello';

	$db = new mysql('localhost','root','xxx');
	  
	if (!$db) {
   	die('Could not connect: ' . mysql_error());
	}
?>
Now there is no reason why this shouldn't work. Its available from many wesbites. All my web page does is print "Hello" so my PHP is working but it doesn't even give an error for the db connection. Its just blank. I know the host, password etc is correct because its what I use to connect using MySQL Administrator. Oh, and phpinfo() give me some MySQL information so that's there. Help! I've been stuck on this for hours :(

Posted: Sat Sep 02, 2006 5:23 pm
by Scarophion
Typical, right after I've posted all over the place I work it out.
I don't need to put "new" before mysql(). Funny, the book I bought uses that, but they use mysqli which may be different. Hey ho, never mind.

Posted: Sat Sep 02, 2006 5:24 pm
by volka