473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

stuck

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

Aug 8 '07 #1
4 1467
On Aug 8, 5:44 pm, Reggie <joelregisfo...@hotmail.comwrote:
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?

Aug 8 '07 #2
Give username as root and password as null and then check

Aug 9 '07 #3
al**********@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.
js*******@attglobal.net
==================
Aug 9 '07 #4
On Aug 8, 5:44 pm, Reggie <joelregisfo...@hotmail.comwrote:
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.

Aug 9 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: No | last post by:
I purchased a program ( So I thought) that turned out to be just a bunch of php scripts put together. I am getting terrible support from the author but I am biting my tongue because I don't want...
1
by: ron | last post by:
have been stuck on this for several days now. I am trying to create a reverse polish calculator and I'm stuck at an intermediate stage. This is what I know I have to do (just not sure how to do it...
2
by: Vladimir | last post by:
I'm running ASP on IIS 5.1 on Windows XP, the same thing works on Windows 98 with PWS. The function below stuck the IIS - draws only frame with nothing inside and wait for infinite. All other...
3
by: Yeren | last post by:
We run a website with pages that are created using ASP. The website is used by different people from different networks. For some people, the pages are stuck. It looks like the were able to open...
2
by: Bryan Field-Elliot | last post by:
We have a running server (v7.3) which, over time, seems to accumulate a bunch of "stuck" PostgreSQL instances which appear to be dead inside of a transaction. For example, "ps" reveals many of...
8
by: MLH | last post by:
I use a mouse-down procedure to trap right mouse clicks and CTRL-Right mouse clicks. Running the procedure must put honey or some other sticky substance into my keyboard because subsequent...
4
by: Astronomically Confused | last post by:
using System; using System.Collections; using System.IO; using System.Net; using System.Net.Sockets; using System.Threading; class HttpProcessor { private Socket s;
4
by: =?Utf-8?B?TWF1cg==?= | last post by:
My cd is stuck in the drive. I can open the drawer O K but the c d will not come out Help me please -- Maur
0
by: =?Utf-8?B?QmlsbEI=?= | last post by:
This is a tough one... My Windows Service app periodically performs some processing on new entries to a SQL Server database table. It uses a simple System.Timer to call the Elapsed event...
7
by: alphasahoo | last post by:
Hi I am working on a program which writes the output a SQL select statements from number of source tables first to a load matrix and then writes to a load.dat file. But while writing to the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.