Jump to content

500 Error on Windows Serv 2008


zero118

Recommended Posts

Greetings...  I'm new to running PHP on Win2008 and I can't seem to figure out my problem here.  Below is the code that checks users against the database.  I get an error telling me "500, There is a problem with the resource you are looking for..."

 

(Oh, PHP5 and MySQL (newest stable) )

 

Thanks!!

 

<?php $username="";
$password="";
include("db.php");

$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword']; 

$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $user_database_table WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql);

$count=mysql_num_rows($result);

if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername");
session_register("mypassword");
header("location:index.php"); } else { echo "Wrong Username or Password"; }
ob_end_flush(); ?>

Link to comment
https://forums.phpfreaks.com/topic/136626-500-error-on-windows-serv-2008/
Share on other sites

This is just a simple, NON-object oriented system that I was playing with and I just want to make sure I get things right on the 2008 server.  So please don't laugh =-)

 

<?php $dbhost = 'localhost';
$dbusername = '*****';
$dbpasswd = '*****';
$database_name = 'nimbus';
$length = '5';

// Site information
$siteadd = '10.0.1.197';
$formsOnOff = '1'; // 0=off 1=on
$level = $_SESSION['s_userlevel'];
$username = $_SESSION['s_username'];
$disname = $_SESSION['s_disname'];


//db tables
$user_database_table = 'users';
$serials_database_table = 'serials';


/* Database Stuff, do not modify below this line */

$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd")
        or die ("Couldn't connect to server.");

$db = mysql_select_db("$database_name", $connection)
        or die("Couldn't select database.");

if ($db) {echo "Connected!";}

?>

Have you successfully executed any php scripts on your server?

 

That error usually means you have a fatal parse or runtime error and since the code you have posted does not generate a parse error (tested), it is probably a fatal runtime error. Add the following two lines immediately after your first opening <?php tag -

 

ini_set ("display_errors", "1");
error_reporting(E_ALL);

Actually, yes.  PHP is running, just some odd things that make me think this is the php.ini causing it...  For instance I cannot use <?$variable?> to display but I can use <? echo $variable ?>

 

I will add the tags when I get to the office and let you know what I get.

Do you get output saying connected?  Is there a reason you're using pconnect rather than connect?  pconnect finds existing connections and leaves the one you just opened up.  Which is good if you need it but other than that there's no real difference.

 

Try everything in one file like this.  (I changed a lot around)

 

include("db.php");

$dbhost = 'localhost';
$dbusername = '*****';
$dbpasswd = '*****';
$database_name = 'nimbus';

$connection = mysql_connect($dbhost, $dbusername, $dbpasswd)
        or die ("Couldn't connect to server.");

$db = mysql_select_db("$database_name", $connection)
        or die("Couldn't select database.");

$username = (isset($_POST['myusername'])) ? $_POST['myusername'] : "";
$password = (isset($_POST['mypassword'])) ? $_POST['mypassword'] : ""; 

$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql = "SELECT * FROM $user_database_table WHERE username='$myusername' and password='$mypassword'"; 
$result = mysql_query($sql);

$count = mysql_num_rows($result);

if($count == 1) {
// Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername");
session_register("mypassword");
header("location:index.php"); 
} else { 
echo "Wrong Username or Password"; 
}
?>

Archived

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

×
×
  • 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.