Jump to content

Mysql error PLEASE HELP


scope

Recommended Posts

So me and a friend have a website (actually my friends but i work on it with him). He set up a mysql database and i set up a php registration thingy. It through back this error: Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /hermes/bosweb26b/b867/ipg.escratchorg/scope/process.php on line 6Lost connection to MySQL server at 'reading initial communication packet', system error: 111 Please help and if you need me to show files i will. (website is scope.escratch.org/register.html) ~SCOPE

Link to comment
Share on other sites

are you trying to connect with any other remote mysql server in that script?

Link to comment
Share on other sites

post the code please

Link to comment
Share on other sites

  • 2 weeks later...
post the code please
<form action="finish.php" method="POST">Email: <input type="text" name="email" /></br>Username: <input type="text" name="username" /></br>Password: <input type="password" name="password" /></br>Re-type Password: <input type="password" name="re-password" /></br>Birth Year: <input type="text" name="birth" /></br><input type="submit" /></form>

this was the registration html file

<?php// CHANGE THESE VALUESDEFINE ('DB_USER', 'MY USERNAME');DEFINE ('DB_PASSWORD', 'MY PASSWORD');DEFINE ('DB_HOST', 'MY DB HOST');DEFINE ('DB_NAME', 'MY NAME); $dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error()); @mysql_select_db (DB_NAME) OR die('Could not select the database: ' . mysql_error() );?>

some of those values i left out but that was called connect.php

<?php//STEP 1 Connect To Database$connect = mysql_connect("HOST","USERNAME","PASSWORD");if (!$connect){die("MySQL could not connect!");}$DB = mysql_select_db('scope');if(!$DB){die("My SQL could not select Database!");}//STEP 2 Declare Variables$Username = $_POST['username'];$Email = $_POST['email'];$Email1 = "@";$Email_Check = strpos($Email,$Email1);$Password = $_POST['password'];$Re_Password = $_POST['re-password'];$Birth = $_POST['birth'];//STEP 3 Check To See If All Information Is Correctif($Username == ""){die("Opps! You don't enter a username!");}if($Password == "" || $Re_Password == ""){die("Opps! You didn't enter one of your passwords!");}if($Birth == ""){die("Opps! You never entered in your birth year!");}if($Password != $Re_Password){die("Ouch! Your passwords don't match! Try again.");}if($Email_Check === false){die("Opps! That's not an email!");}//STEP 4 Insert Information Into MySQL Databaseif(!mysql_query("INSERT INTO users (email, username, password, birth)VALUES ('$Email', '$Username', '$Password', '$Birth')")){die("We could not register you due to a mysql error (Contact the website owner if this continues to happen.)");}?>

this was the finish.php which i also left out some things. this file was the file the register html file sent info to

<form action="members.php" method="POST" />Username: <input type="text" name="username" /></br>Password: <input type="password" name="password" /></br><input type="submit" />

this was the login form (but if anyone knows how it can make it so you login and stayed logged in on other pages and you can logout, please tell me)

<?php//STEP 1 Connect To Database$connect = mysql_connect("HOST","USERNAME","PASSWORD");if (!$connect){die("MySQL could not connect!");}$DB = mysql_select_db('scope');if(!$DB){die("MySQL could not select Database!");}//STEP 2 Declare Variables$Name = $_POST['username'];$Pass = $_POST['password'];$Query = mysql_query("SELECT * FROM Users WHERE Username='$Name' AND Password='$Pass'");$NumRows = mysql_num_rows($Query);$_SESSION['username'] = $Name;$_SESSION['password'] = $Pass;//STEP 3 Check to See If User Entered All Of The Informationif(empty($_SESSION['username']) || empty($_SESSION['password'])){die("Go back and login before you visit this page!");}if($Name && $Pass == ""){die("Please enter in a name and password!");}if($Name == ""){die("Please enter your name!" . "</br>");}if($Pass == ""){die("Please enter a password!");echo "</br>";}//STEP 4 Check Username And Password With The MySQL Databaseif($NumRows != 0){while($Row = mysql_fetch_assoc($Query)){$Database_Name = $Row['username'];$Database_Pass = $Row['password'];}}else{die("Incorrect Username or Password!");}if($Name == $Database_Name && $Pass == $Database_Pass){// If The User Makes It Here Then That Means He Logged In Successfullyecho "Hello " . $_SESSION['username'] . "!";}?><html><body><p>Here is where you can put information for the user to see when he logs on. (Anything inside these html tags!)</p></body></html>

this file is called members.php and it stores the info

Link to comment
Share on other sites

did you replace the db credentials? what did you put in DB_HOST? btw remove the @ error supressor oprator which will help you to debug.

Link to comment
Share on other sites

I know get this error:

Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /hermes/bosweb26b/b867/ipg.escratchorg/scope/source/include/fg_membersite.php on line 733

I also now use code from this site instead of the other stuff:http://www.html-form-guide.com/php-form/php-registration-form.html

Link to comment
Share on other sites

That's the same error from the first post. Did you check the link I posted? There are any number of reasons why that error would happen. It could be a network issue like a firewall, it could be a configuration error with MySQL, or something else.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...