My php script seems to be dieing at the database connection using this code but it's not printing my error. It will print all php code before the connection code, but it prints nothing after it making me think this is my problem:

$DBConnect = @mysqli_connect("localhost", "user", "pass")
	Or die("<p>Unable to connect to the database server</p>" . "<p>Error code " . mysqli_connect_errno() . ": " . mysqli_connect_error()) . "</p>";

This works just fine offline in my testing environment but when I upload it online and change my information over to the real database host, username, and password nothing happens beyond this string of code.

It doesnt print the success message and it doesn't print an error message saying that it could not connect.

Is this a problem with my code? I've checked my host name, username, and password 10+ times.

Could this code maybe not work with the database being Mysql 4.0?

Thanks for any help.


9 Years
Discussion Span
Last Post by somedude3488

Wierd those mysqli functions. Try converting your code to the mysql equivilents such as the following:

mysql_connect("localhost", "user", "pass") or
die("<p>Unable to connect to the database server</p>" . "<p>Error code ".mysql_error());

Hello cwarn23.

I was thinking the same thing. After looking through my hosts FAQ's on mysql I noticed they didnt use msqli in their examples. That was the problem they dont support that syntax I guess.

I was taught php using mysqli on everything, so I just had to convert all of them to the normal mysql and on the query ones and select_db just has to remove the DBConnect from them. Worked like a charm.

Thanks for your help.


This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.