zero118 Posted December 12, 2008 Share Posted December 12, 2008 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(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/136626-500-error-on-windows-serv-2008/ Share on other sites More sharing options...
Maq Posted December 12, 2008 Share Posted December 12, 2008 Can you post the db.php? There's probably a class in there you have to use. Quote Link to comment https://forums.phpfreaks.com/topic/136626-500-error-on-windows-serv-2008/#findComment-713412 Share on other sites More sharing options...
zero118 Posted December 12, 2008 Author Share Posted December 12, 2008 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!";} ?> Quote Link to comment https://forums.phpfreaks.com/topic/136626-500-error-on-windows-serv-2008/#findComment-713420 Share on other sites More sharing options...
PFMaBiSmAd Posted December 12, 2008 Share Posted December 12, 2008 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); Quote Link to comment https://forums.phpfreaks.com/topic/136626-500-error-on-windows-serv-2008/#findComment-713430 Share on other sites More sharing options...
zero118 Posted December 12, 2008 Author Share Posted December 12, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/136626-500-error-on-windows-serv-2008/#findComment-713634 Share on other sites More sharing options...
Maq Posted December 12, 2008 Share Posted December 12, 2008 You can never use $variable?> to display. You can use =$variable ?>, but you shouldn't. I always use : Interested to see what errors you get. Quote Link to comment https://forums.phpfreaks.com/topic/136626-500-error-on-windows-serv-2008/#findComment-713662 Share on other sites More sharing options...
PFMaBiSmAd Posted December 12, 2008 Share Posted December 12, 2008 Basically the same as above ^^^^ <?$variable?> never would have displayed anything. Quote Link to comment https://forums.phpfreaks.com/topic/136626-500-error-on-windows-serv-2008/#findComment-713666 Share on other sites More sharing options...
zero118 Posted December 12, 2008 Author Share Posted December 12, 2008 I meant to add the = in there... I don't get any new error with the added tags. IIS is still just saying 500, There is a problem with the resource... Quote Link to comment https://forums.phpfreaks.com/topic/136626-500-error-on-windows-serv-2008/#findComment-713673 Share on other sites More sharing options...
Maq Posted December 12, 2008 Share Posted December 12, 2008 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"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/136626-500-error-on-windows-serv-2008/#findComment-713682 Share on other sites More sharing options...
zero118 Posted December 12, 2008 Author Share Posted December 12, 2008 if I open this (inc_usercheckall.php) by itself I see that it connects and tells me wrong password. If I try to load this from my login for I get the 500 error again. Quote Link to comment https://forums.phpfreaks.com/topic/136626-500-error-on-windows-serv-2008/#findComment-713697 Share on other sites More sharing options...
zero118 Posted December 12, 2008 Author Share Posted December 12, 2008 I really wanted this to work on IIS 7with 2008 Server but it's just too much of a headache. I'm going to just install Apache Quote Link to comment https://forums.phpfreaks.com/topic/136626-500-error-on-windows-serv-2008/#findComment-713812 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.