Link to home
Start Free TrialLog in
Avatar of aej1973
aej1973

asked on

mysqli error...

Hi, I am running this query and I keep get the following error, can someone let me know what is wrong here?


Warning: mysqli::prepare(): Couldn't fetch mysqli in /var/www/voicebox/home_user.php on line 87

Fatal error: Call to a member function bind_param() on a non-object in /var/www/voicebox/home_user.php on line 88


$ph=$mysqli->prepare("select did_number from did_numbers where assigned_to=? and did_status='1'");
   $ph->bind_param("i",$userid);
   $ph->execute();
   $ph->fetch();
   $ph ->store_result();   
   $phCount=$ph->num_rows;
   if($phCount==0)
   $rowCount="No  Lines";
       else {
		       $rowCount=$phCount;
                 }   

Open in new window

Avatar of sriramiyer
sriramiyer

insert this sqlstr code for debugging purpose to get valid sqlstr or not first,

$sqlstr="select did_number from did_numbers where assigned_to=? and did_status='1'";
echo $sqlstr . "</br>";
exit;
mysqli->prepare("select did_number from did_numbers where assigned_to=? and did_status='1'");
Avatar of Dave Baldwin
Do you have code to open the connection on that page before those lines?  http://us3.php.net/manual/en/mysqli.construct.php
Avatar of aej1973

ASKER

yes, the connection is open..
See the first user comment here http://php.net/manual/en/mysqli.query.php about "Couldn't fetch mysqli".
Avatar of aej1973

ASKER

ok, let me check.
You may also be missing a statement according to the example here: http://www.php.net/manual/en/mysqli.prepare.php
ASKER CERTIFIED SOLUTION
Avatar of Marco Gasi
Marco Gasi
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aej1973

ASKER

Marcus, this is the error I am getting...

Fatal error: Call to undefined method mysqli::error() in /var/www/voicebox/home_user.php on line 92
Avatar of aej1973

ASKER

solved. Thanks Marcus.

if ($ph == false){
       die($mysqli->error);
           }