Jump to content

MySQL with PHP error.


Domcsore

Recommended Posts

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.