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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql_connect

Status
Not open for further replies.

shiyixia

Technical User
Dec 27, 2004
4
GB
Dear all, i have the first problem when i try to testmysql_connect, the codes is as following:


<?php
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>


but the browser cannot read it(everything worked well before i use this command.
 
you could just do this:
Code:
$link = mysql_connect('localhost', 'root', '') or die("error connecting: ".mysql_error());

the die(); statement stops all code underneath it from executing.


Regards,

Martin

Gaming Help And Info:
 
hi, thanks for your reply, i have tried this

<?php
$link = mysql_connect('localhost', 'root', '') or die('error connecting:'.mysql_error());

echo 'Connected successfully';
mysql_close($link);
?>

but still doesnot work, i think u r right, die()stops all code underneath it from executing. is it because it cannot connect to MySQL? i have MySQL-front, the user root and no password can conncet to the server, still have no clue
 
somebody can help me? i still havenot sorted it out, :'(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top