Brian W Posted October 28, 2008 Share Posted October 28, 2008 This could be under ISS, PHP, or Mysql for all I know... so I posted here in the general PHP board. I have a page that processes some user data that was working earlier yesterday but than suddenly stopped working and feeds me this error. 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. <?php require_once('../../Connections/Epm.php'); mysql_select_db($database_Epm, $Epm);?> <?php include("../includes/functions.php"); check(); //User validation ?> <?php if(isset($_GET['A'] && $_GET['A'] == "pass"){ if($_POST['password'] == $_POST['password2']){ $sql = "UPDATE `bexusers` SET `Password`='p".md5($_POST['password'].$Salt)."' WHERE `Username`='".$_SESSION['Username']."'"; $Update = mysql_query($sql, $Epm) or die(mysql_error()); if(!isset(mysql_fetch_assoc($Update))){ die('Error: 10'); } header('Location: .././'); } else { die('Passwords did not match'); } } //FIND USER $colname_User = $_SESSION['Username']; mysql_select_db($database_Epm, $Epm); $query_User = sprintf("SELECT * FROM bexusers WHERE Username = '%s'", $colname_User); $User = mysql_query($query_User, $Epm) or die(mysql_error()); $row_User = mysql_fetch_assoc($User); $totalRows_User = mysql_num_rows($User); if(isset($_POST['Pass']) && $_GET['A'] == "Try"){ $Pass = "p".md5($_POST['Pass'].$Salt); if($Pass == $row_User['Password']){ $_SESSION['ENC'] = md5($row_User['ID']); header('Location: ../?P=User');} else { echo "The password was incorrect <br>"; } } if($_GET['A'] == "un"){ unset($_SESSION['ENC']); header('Location: ../?P=User');} echo "Fail... no action specified."; ?> Is there anything in the code that could cause that error? OR Is this a IIS problem? OR Is this a MySQL problem? System info: *Windows Server 2008 *IIS 7 *PHP 5.2.6 Quote Link to comment https://forums.phpfreaks.com/topic/130442-solved-unknown-cause-of-error/ Share on other sites More sharing options...
revraz Posted October 28, 2008 Share Posted October 28, 2008 What changed from yesterday? Quote Link to comment https://forums.phpfreaks.com/topic/130442-solved-unknown-cause-of-error/#findComment-676677 Share on other sites More sharing options...
GKWelding Posted October 28, 2008 Share Posted October 28, 2008 This is a 'catch-all' error generated by your Web server. Basically something has gone wrong, but the server can not be more specific about the error condition in its response to the client. In addition to the 500 error notified back to the client, the Web server should generate some kind of internal error log which gives more details of what went wrong. To me this looks like a server error rather than a PHP or MySQL error. I say this because the error is so unspecific. if it was MySQL or PHP errors then the respective program would tell you, ie. you'd get a php syntax error etc... Quote Link to comment https://forums.phpfreaks.com/topic/130442-solved-unknown-cause-of-error/#findComment-676679 Share on other sites More sharing options...
Brian W Posted October 28, 2008 Author Share Posted October 28, 2008 That is what I've been thinking, but couldn't be sure because I'm still relatively new to PHP (just about 6 months now). I'll move over to the IIS section and if a mod wants they can move this thread or delete it. Thanks GK Quote Link to comment https://forums.phpfreaks.com/topic/130442-solved-unknown-cause-of-error/#findComment-676687 Share on other sites More sharing options...
wildteen88 Posted October 28, 2008 Share Posted October 28, 2008 Your code has a few errors from looking at it. The first is on line 4: if(isset($_GET['A'] && $_GET['A'] == "pass"){ It should be if(isset($_GET['A']) && $_GET['A'] == "pass"){ The last error is on this line 10: if(!isset(mysql_fetch_assoc($Update))){ die('Error: 10'); } That code does not make sense. The line above is running an UPDATE query. No rows are returned from an update query so you cannot use mysql_fetch_assoc to check whether the query succeeded or not. You should use the mysql_affected_rows() function instead. Your code fixed and cleaned <?php require_once('../../Connections/Epm.php'); mysql_select_db($database_Epm, $Epm);?> <?php include("../includes/functions.php"); check(); //User validation ?> <?php if(isset($_GET['A']) && $_GET['A'] == "pass") { if($_POST['password'] == $_POST['password2']) { $sql = "UPDATE `bexusers` SET `Password`='p".md5($_POST['password'].$Salt)."' WHERE `Username`='".$_SESSION['Username']."'"; $Update = mysql_query($sql, $Epm) or die(mysql_error()); if(mysql_affected_rows($Update) != 0) { header('Location: .././'); } else { die('Error: 10'); } } else die('Passwords did not match'); } //FIND USER $colname_User = $_SESSION['Username']; mysql_select_db($database_Epm, $Epm); $query_User = sprintf("SELECT * FROM bexusers WHERE Username = '%s'", $colname_User); $User = mysql_query($query_User, $Epm) or die(mysql_error()); $row_User = mysql_fetch_assoc($User); $totalRows_User = mysql_num_rows($User); if(isset($_POST['Pass']) && $_GET['A'] == "Try") { $Pass = "p".md5($_POST['Pass'].$Salt); if($Pass == $row_User['Password']) { $_SESSION['ENC'] = md5($row_User['ID']); header('Location: ../?P=User'); } else { echo "The password was incorrect <br>"; } } elseif($_GET['A'] == "un") { unset($_SESSION['ENC']); header('Location: ../?P=User'); } echo "Fail... no action specified."; ?> Quote Link to comment https://forums.phpfreaks.com/topic/130442-solved-unknown-cause-of-error/#findComment-676818 Share on other sites More sharing options...
Brian W Posted October 28, 2008 Author Share Posted October 28, 2008 I got the page to start working again by reading exploring on google for at least two hours. Turns out I needed to change an .ini setting because I am using fast cgi and its on IIS. But I was still having problems which what you just gave me will fix it... namely the mysql_affected_rows() because I found the missing ) a little bit ago once I got the page to start coming up again. Thanks wild Quote Link to comment https://forums.phpfreaks.com/topic/130442-solved-unknown-cause-of-error/#findComment-676825 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.