GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   mysqli prepared statements num_rows (https://gfy.com/showthread.php?t=1117649)

eMonk 08-06-2013 04:52 PM

mysqli prepared statements num_rows
 
This keeps returning 0 results. Any ideas?

Code:

$qry1 = $db->prepare("SELECT id FROM user WHERE username = ? AND password = ?");
$qry1->bind_param('ss', $_GET['username'], $_GET['password']);
$qry1->execute();

$qry1->store_result();
$result_1 = $qry1->num_rows;

echo $result_1;


EddyTheDog 08-06-2013 05:02 PM

Quote:

Originally Posted by eMonk (Post 19749137)
This keeps returning 0 results. Any ideas?

Code:

$qry1 = $db->prepare("SELECT id FROM user WHERE username = ? AND password = ?");
$qry1->bind_param('ss', $_GET['username'], $_GET['password']);
$qry1->execute();

$qry1->store_result();
$result_1 = $qry1->num_rows;

echo $result_1;


that's because ->bind_result() is a method of the mysqli_stmt class. it's not a method of the mysqli class.

lol - Just kidding - It's a small world...

valeriyCE 08-06-2013 05:11 PM

It has to do with binding arrays that are not declared

$params = array('ss', 'stan', 'Stanley');
$tmp = array();
foreach($params as $key => $value) $tmp[$key] = &$params[$key];
call_user_func_array(array($stmt, 'bind_param'), $tmp);

use this style.

Dankasaur 08-06-2013 05:13 PM

Code:

$db->prepare("SELECT id FROM user WHERE username = ? AND password = ?");
$db->bind_param('ss', $_GET['username'], $_GET['password']);
$db->execute();

$db->store_result();
$result_1 = $db->num_rows;

echo $result_1;


eMonk 08-06-2013 05:19 PM

Quote:

Originally Posted by EddyTheDog (Post 19749149)
that's because ->bind_result() is a method of the mysqli_stmt class. it's not a method of the mysqli class.

lol - Just kidding - It's a small world...

LOL. Dude, I've been trying to figure this out the past 2 days and no luck.

I've searched google but the sites I checked said to include store_result() which I tried but still 0 results returned.


All times are GMT -7. The time now is 06:45 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123