stuck

stuck

am 08.08.2007 23:44:39 von Reggie

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

$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";
}
?>

Re: stuck

am 09.08.2007 01:53:00 von ELINTPimp

On Aug 8, 5:44 pm, Reggie wrote:
> 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
>
> > $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";}
>
> ?>

I can't really see anything obviously wrong...although I like to
specify my link handles ie. $db = mysqlconnect() and specify $db
throughout


run mysqladmin...what is the connect_timeout set to?

Re: stuck

am 09.08.2007 16:37:18 von allampraveen

Give username as root and password as null and then check

Re: stuck

am 09.08.2007 16:45:08 von Jerry Stuckle

allampraveen@gmail.com wrote:
> Give username as root and password as null and then check
>

Not his problem - he's connecting just fine.

And username of root with no password is about as insecure as you can get.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: stuck

am 09.08.2007 22:07:23 von nfantis

On Aug 8, 5:44 pm, Reggie wrote:
> 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


Does your user have privileges in MySQL to do the operation on line 9
of your code (SELECT database?) I believe you get disconnected if you
are not authorized to execute a query.