dudejma Posted August 1, 2011 Share Posted August 1, 2011 This code isn't working.. Again. It's a different code, same problem. It's not the same problem as the last time though. Can you find anything wrong with this code? Thanks. (Probably AyKay or Pikachu.) <?php require 'include/sql.php'; $random = $_GET['code']; $sql = "SELECT * FROM temp_pass WHERE random='$random'"; $result = mysql_query($sql) or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error()); if (isset($_POST['submit'])) { while ($row = mysql_fetch_array($result)) { $pilotid = $row['pilotID']; $newPass = md5($_POST['password']); $sql2 = "UPDATE users WHERE pilotID='$pilotid'"; $result2 = mysql_query($sql2) or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error()); $sql3 = "DELETE FROM temp_pass WHERE pilotID='$pilotid'"; $result3 = mysql_query($sql3) or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error()); header("Location: login.php"); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/243433-no-error-again/ Share on other sites More sharing options...
dudejma Posted August 1, 2011 Author Share Posted August 1, 2011 I found some errors and fixed them but still nothing. Here's the updated code: <?php require 'include/sql.php'; $random = $_GET['code']; $sql = "SELECT * FROM temp_pass WHERE random='$random'"; $result = mysql_query($sql) or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error()); if (isset($_POST['submit'])) { while ($row = mysql_fetch_array($result)) { $pilotid = $row['pilotID']; $newPass = md5($_POST['password']); $sql2 = "UPDATE users SET password='$newPass' WHERE pilotID='$pilotid'"; $result2 = mysql_query($sql2) or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error()); $sql3 = "DELETE FROM temp_pass WHERE pilotID='$pilotid'"; $result3 = mysql_query($sql3) or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error()); header("Location: login.php"); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/243433-no-error-again/#findComment-1250040 Share on other sites More sharing options...
IrOnMaSk Posted August 2, 2011 Share Posted August 2, 2011 what is this same problem you're talking about? what's the error? and what's in your sql.php? Quote Link to comment https://forums.phpfreaks.com/topic/243433-no-error-again/#findComment-1250724 Share on other sites More sharing options...
AyKay47 Posted August 2, 2011 Share Posted August 2, 2011 well what exactly is happening here, i'm assuming that you aren't receiving any errors? I also assume that your error_reporting is set to E_ALL offhand I would think that it has something to do with your connection if your queries are not working properly...however an error would be triggered if that were the case... Quote Link to comment https://forums.phpfreaks.com/topic/243433-no-error-again/#findComment-1250743 Share on other sites More sharing options...
WebStyles Posted August 2, 2011 Share Posted August 2, 2011 I can see several things with your code. 1. Not checking to see if $_GET['code'] exists and not planing for when it doesn't 2. creating an unnecessary mysql_query before if (isset($_POST['submit'])) { ... 3. this: $sql2 = "UPDATE users WHERE pilotID='$pilotid'"; is supposed to update what? 4. You have most of the code in a while loop but at the end of the first loop you do this: header("Location: login.php"); Quote Link to comment https://forums.phpfreaks.com/topic/243433-no-error-again/#findComment-1250850 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.