Domcsore Posted April 4, 2010 Share Posted April 4, 2010 Hey guys, me again. Im getting an error but I really can't figure it out! Im getting this error: Warning: mysql_fetch_array() [function.mysql-fetch-array]: The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH. in /home/alliedri/public_html/register/classes/global_reg.php on line 43 and this is the PHP for it: public function login(){ $user = mysql_real_escape_string($_POST['username']); $pass = md5($_POST['password']); $result = mysql_query("SELECT * FROM userList WHERE username = '".$user."'"); $row = mysql_fetch_array($result, $con); if($user == $row['username'] && $pass == $row['password']){ $_SESSION['user'] = $row['username']; $_SESSION['level'] = $row['perm']; header('Location: index2.php'); }else{ echo 'bad'; } } any ideas? Cheers Quote Link to comment https://forums.phpfreaks.com/topic/197574-mysql-with-php-error/ Share on other sites More sharing options...
nafetski Posted April 4, 2010 Share Posted April 4, 2010 Make sure you connect to the DB first That error would lead me to imply that the query was never executed. Quote Link to comment https://forums.phpfreaks.com/topic/197574-mysql-with-php-error/#findComment-1036913 Share on other sites More sharing options...
PFMaBiSmAd Posted April 4, 2010 Share Posted April 4, 2010 Read the definition of what the second parameter is - http://php.net/mysql_fetch_array Quote Link to comment https://forums.phpfreaks.com/topic/197574-mysql-with-php-error/#findComment-1036914 Share on other sites More sharing options...
Domcsore Posted April 4, 2010 Author Share Posted April 4, 2010 My second parameter connects to the mysql. Thing is, this worked on my xampp but when I uploaded it onto a server it wouldn't work, any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/197574-mysql-with-php-error/#findComment-1036919 Share on other sites More sharing options...
PFMaBiSmAd Posted April 4, 2010 Share Posted April 4, 2010 any suggestions Yes, fix the code. Also, your xampp system either has display_errors set to OFF or error_reporting set to less than E_ALL and that specific problem in your code was being hidden. A lot of the all-in-one xammp packages simply are not setup correctly as development systems to report and display all php errors, causing a lot of lost time when code is moved to a live server. Quote Link to comment https://forums.phpfreaks.com/topic/197574-mysql-with-php-error/#findComment-1036923 Share on other sites More sharing options...
Domcsore Posted April 4, 2010 Author Share Posted April 4, 2010 Well that didn't really help as to my error. How ever thanks for the advice. Quote Link to comment https://forums.phpfreaks.com/topic/197574-mysql-with-php-error/#findComment-1036924 Share on other sites More sharing options...
Pikachu2000 Posted April 4, 2010 Share Posted April 4, 2010 The second parameter in a mysql_fetch_array() is not a database connection call. That, along with selecting the database to use, should have been taken care of before the query ran. If you'd read the manual page that was linked to previously, you'd realize the error message is telling you exactly what is wrong. Quote Link to comment https://forums.phpfreaks.com/topic/197574-mysql-with-php-error/#findComment-1036928 Share on other sites More sharing options...
ignace Posted April 5, 2010 Share Posted April 5, 2010 PFMaBiSmAd keeps rather vague when he answers so I'll spell it out for you: THE SECOND PARAMETER OF mysql_fetch_array() IS NOT $con IF YOU'D BOTHERED YOU WOULD HAVE NOTICED THAT ON THE MANUAL Hopefully this got your attention And next time if someone gives you some advice listen, try it and then draw conclusions. Well that didn't really help as to my error. How ever thanks for the advice. As we KNOW that it would solve your error. Quote Link to comment https://forums.phpfreaks.com/topic/197574-mysql-with-php-error/#findComment-1037049 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.