Jump to content

[SOLVED] HTTP 500 - Internal server error


dark_mirage

Recommended Posts

Hi all, ive recently started learning php and everything is working fine, until today.

However, i followed a 'login script' tutorial today and whenever i enter the username and click login, firefox just hangs on the php page which connects to mysql, and in IE it gives a HTTP 500 - Internal server error.

I know this is something to do with mysql because when wrote a simple script just to echo a peice of info from the database onto the screen and again, it just hangs, but any other (non mysql related) php script works, any ideas why this happens?  :-\

 

heres the code that checks the login details:

<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="pass"; // Mysql password
$db_name="mysql"; // 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";
}
?>

obviously, i have entered the correct password, just changed it for this lol

Thanks in advance.

Link to comment
Share on other sites

What versions are you using?  If the case is based on what you stated it is something to do with php/mysql relationship.  Check your versions I had similar problem before and it is based on the version incompatability of the two services.

Link to comment
Share on other sites

Replace

 

if($count==1){

// Register $myusername, $mypassword and redirect to file "login_success.php"

session_register("myusername");

session_register("mypassword");

header("location:login_success.php");

}

 

with

 

if($count==1){

echo "Success";

}

 

To see if the problem is in the header and/or sessions.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.