Neptunus Maris Posted February 26, 2007 Share Posted February 26, 2007 mysql_num_rows() function and mysql_fetch_array() will not work what so ever my code: (pretty simple) it will just turn out a blank screen. if (!isset($_POST[submit])) { $show_form = "yes"; } elseif (isset($_POST[submit])) { $pwd = md5($_POST[password]); $query = "SELECT * FROM admins WHERE f_name = '$_POST[f_name]' AND l_name = '$_POST[l_name]' AND password = '$pwd'"; $result = mysql_query($query) or die(mysql_error()); $check_row = mysql_num_rows($result) or die(mysql_error()); if ($check_row != 1) { $error = "This Administration record is not found. And/Or name and password do not match."; $show_form = "yes"; } else { $row = mysql_fetch_array($result) or die(mysql_error()); if ($row[auth_lvl] == "SA") { $cookie = $row[adminID]; setcookie("sa", $cookie, time()+1800, "/", 0); $display = "You are logged in <a href = 'control_panel.php'>Go to Control Panel</a>."; } else { $cookie = $row[adminID]; setcookie("admin", $cookie, time()+1800, "/", 0); $display = "You are logged in <a href = 'control_panel.php'>Go to Control Panel</a>."; } } } //end if its a script that uses $_SERVER[php_SELF] but that is not the problem...ive tried the tow mysql functions in other types of code and it will just not work. Quote Link to comment Share on other sites More sharing options...
papaface Posted February 26, 2007 Share Posted February 26, 2007 im pretty sure these $_POST[f_name] should be $_POST["f_name"] Quote Link to comment Share on other sites More sharing options...
Neptunus Maris Posted February 26, 2007 Author Share Posted February 26, 2007 im pretty sure these $_POST[f_name] should be $_POST["f_name"] that shouldnt be the case...because ive used that without the "" before... Quote Link to comment Share on other sites More sharing options...
btherl Posted February 26, 2007 Share Posted February 26, 2007 Actually, best is $_POST['f_name']. Although it works without quotes, it's risky as your variable names may clash with defined values. And single quotes are slightly faster than double quotes. But that's not causing your error. Try changing your num_rows() line to this: $check_row = mysql_num_rows($result); Adding the "or die" to mysql_num_rows() doesn't work, and in fact makes things worse. You should keep the "or die" on the other mysql calls. If you still get a blank page, add ini_set('display_errors', true); at the top of your code (I am not 100% sure that is right, but the goal is to turn on display of errors) Quote Link to comment Share on other sites More sharing options...
Neptunus Maris Posted February 26, 2007 Author Share Posted February 26, 2007 Actually, best is $_POST['f_name']. Although it works without quotes, it's risky as your variable names may clash with defined values. And single quotes are slightly faster than double quotes. But that's not causing your error. Try changing your num_rows() line to this: $check_row = mysql_num_rows($result); Adding the "or die" to mysql_num_rows() doesn't work, and in fact makes things worse. You should keep the "or die" on the other mysql calls. If you still get a blank page, add ini_set('display_errors', true); at the top of your code (I am not 100% sure that is right, but the goal is to turn on display of errors) ok thanks...very much Quote Link to comment 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.