Jump to content

Counting Num_rows after SELECT for login


Eggzorcist

Recommended Posts

I'm creating a login that uses PDO statements, however when I try to count how many rows was selected, it gives me an error mentioning its an unidentified property, I always tried rowCount, but it did not work either...

 

Notice: Undefined property: PDOStatement::$num_rows in /Users/JPFoster/Sites/Jaipai.Blog/engine.php on line 50

 

 

Here's my class method:

 public function login($user, $pw){
	$user = addslashes($this->user);
	$pw = md5($pw);

	$query = "SELECT * FROM `users` WHERE `username` = '".$user."' AND `password` = '".$pw."'";

	//set up query
	$results = $this->pdo->query($query);


	if ($results->num_rows == 1){
	$row = $results->fetch_assoc();
	echo "Worked!";
		//$this->set_session($row['id'], $row['username'], $row['email']);
	} else {

	echo "Your Username and Password did not match"; 	

	}

	//if user + passs match { redirect (member page) and set up sessions

	// Else ... Retry...
}	

 

 

Any help with this will be greatly appreciated!

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.