Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql_connect stops script

Status
Not open for further replies.

dunstantom

Programmer
Feb 10, 2005
2
US
So, I've just started using Php/apache/mysql on my linux box. I use php in my pages and I can access mysql from the command line with user=root and pwd=rootpwd. However, when I run this code:
<?php
echo "Starting...<br>";
$connect = mysql_connect('localhost','root','rootpwd');
if (!$connect) {
die('Could not connect: ' . mysql_error());
}

echo "Connected<br>";
... etc. ...
?>

My output is this:
Starting...


And that's it. No error or anything. I thought maybe it was my firewall, but it isn't that. Any ideas?
 
Try re writing the connect command like that.

$connect = mysql_connect('localhost','root','rootpwd') or die("Could not connect:".mysql_error());

and another thing instead of '' use "".

Hope this will help
 
dunstantom

i don't think that there is anything wrong with your code as is although i agree that fireburner69's connect formulation is more standard.

can you set error reporting to report all errors
Code:
error_reporting(E_ALL);
and rerun the code.

lastly, have you got the mysql extensions to php installed? pre v5 they were automatically there, thereafter, you have to add them. check by using phoinfo().

hth
Justin
 
You know, what... I was dumb. The error output was turned off in my php.ini file =P

Now I will go through the other myriad of threads with the same error I have (mysql_connect undefined) to find the solution. Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top