| 
 Posted by Reggie on 08/08/07 21:44 
how can i resolve this: 
 
Warning: mysql_connect() [function.mysql-connect]: Lost connection to 
MySQL server during query in /home/fhlinux169/c/clashoff.co.uk/user/ 
htdocs/checklogin.php on line 9 
cannot connect 
 
this is the script. please help.very stuck 
 
<?php 
$host="localhost"; // Host name 
$username=""; // Mysql username 
$password=""; // Mysql password 
$db_name="test"; // Database name 
$tbl_name="members"; // Table name 
 
// Connect to server and select databse. 
mysql_connect("$host", "$username", "$password")or die("cannot 
connect"); 
mysql_select_db("$db_name")or die("cannot select DB"); 
 
// username and password sent from signup form 
$myusername=$_POST['myusername']; 
$mypassword=$_POST['mypassword']; 
 
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and 
password='$mypassword'"; 
$result=mysql_query($sql); 
 
// Mysql_num_row is counting table row 
$count=mysql_num_rows($result); 
// If result matched $myusername and $mypassword, table row must be 1 
row 
 
if($count==1){ 
// Register $myusername, $mypassword and redirect to file 
"login_success.php" 
session_register("myusername"); 
session_register("mypassword"); 
header("location:login_success.php"); 
} 
else { 
echo "Wrong Username or Password"; 
} 
?>
 
[Back to original message] 
 |