Database connection

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Scarophion
Forum Newbie
Posts: 2
Joined: Sat Sep 02, 2006 5:06 pm

Database connection

Post 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 :(
Scarophion
Forum Newbie
Posts: 2
Joined: Sat Sep 02, 2006 5:06 pm

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Post Reply