SearchSearch   

stuck

 
   Webmaster Forums (Home) -> PHP RSS
Next:  Problem with PEAR + PHP5 + is_a function  
Author Message
Reggie

External


Since: Jun 29, 2007
Posts: 11



(Msg. 1) Posted: Wed Aug 08, 2007 2:44 pm
Post subject: stuck
Archived from groups: comp>lang>php (more info?)

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 top
ELINTPimp

External


Since: Jun 30, 2007
Posts: 42



(Msg. 2) Posted: Wed Aug 08, 2007 11:53 pm
Post subject: Re: stuck
Archived from groups: per prev. post (more info?)

On Aug 8, 5:44 pm, Reggie <joelregisfo... DeleteThis @hotmail.com> 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
>
> <?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";}
>
> ?>

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?
Back to top
allampraveen

External


Since: Aug 07, 2007
Posts: 3



(Msg. 3) Posted: Thu Aug 09, 2007 7:37 am
Post subject: Re: stuck
Archived from groups: per prev. post (more info?)

Give username as root and password as null and then check
Back to top
Jerry Stuckle

External


Since: Jul 08, 2004
Posts: 3787



(Msg. 4) Posted: Thu Aug 09, 2007 10:45 am
Post subject: Re: stuck
Archived from groups: per prev. post (more info?)

allampraveen DeleteThis @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 DeleteThis @attglobal.net
==================
Back to top
nfantis

External


Since: Aug 09, 2007
Posts: 3



(Msg. 5) Posted: Thu Aug 09, 2007 8:07 pm
Post subject: Re: stuck
Archived from groups: per prev. post (more info?)

On Aug 8, 5:44 pm, Reggie <joelregisfo... RemoveThis @hotmail.com> 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.
Back to top
Display posts from previous:   
       Webmaster Forums (Home) -> PHP
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum