Phaelon Posted May 2, 2014 Share Posted May 2, 2014 Hey all, I am getting an error with PHP where my page halts, but there is nothing in the error log to indicate why. The error is specifically with the subroutine if ($row['email'] == '') {, everything else works fine. Does anyone have any ideas? <?php session_start(); if (isset($_POST["e-mail"])) { $link = mysql_connect('localhost', 'testuser', 'testpw') OR die(mysql_error()); mysql_select_db('testdb', $link); $query = "SELECT * FROM customers WHERE email = '".mysql_real_escape_string($_POST["e-mail"])."'"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { if ($row['email'] == '') { mysql_close($link); echo 'notregistered'; exit; } if ($row['password'] != $_POST["password"]) { mysql_close($link); include 'wrongpassword'; exit; } if ($row['password'] == $_POST["password"]) { mysql_close($link); $_SESSION['login']['customernumber'] = $row['number']; header('Location: http://test.com/account/'); exit; } } } else { include 'login'; } ?> Link to comment https://forums.phpfreaks.com/topic/288189-error-with-a-log-entry/ Share on other sites More sharing options...
bsmither Posted May 2, 2014 Share Posted May 2, 2014 "I am getting an error with PHP." How do you know it's an error? A pervasive mistake I see is this: while ($row = mysql_fetch_assoc($result)) { Technically, you are testing for $row containing a non-false value, but you are not doing anything should the expression for while() be false. mysql_fetch_assoc could return false - and it eventually will - but return false immediately. Sketch your flowchart and determine where program control flows when while() is false. Link to comment https://forums.phpfreaks.com/topic/288189-error-with-a-log-entry/#findComment-1477987 Share on other sites More sharing options...
Phaelon Posted May 2, 2014 Author Share Posted May 2, 2014 I solved it. I just had to move it up a nest. Link to comment https://forums.phpfreaks.com/topic/288189-error-with-a-log-entry/#findComment-1477988 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.