0

I have a problem with get_result() function.

The php script on my localhost working well but on the server have this error

Fatal error: Call to undefined method mysqli_stmt::get_result() 

I searched many times but I didn't find the solution. My code:

$sql=$db->prepare("SELECT * FROM `news` WHERE cat = ? order by id desc limit 10");
$cat=$_GET['cat'];
$sql->bind_param('i', $cat);
$sql->execute();
$result=$sql->get_result();
if($result){
    while ($row = $result->fetch_array()) { echo "something"; }

(Both "mysqli" and "mysqlnd" are installed. )

what i have to do now ?

Dharman
  • 30,962
  • 25
  • 85
  • 135
user2976078
  • 75
  • 1
  • 2
  • 10
  • Check with phpinfo driver of mysql. – sectus Jun 25 '14 at 02:15
  • this might help [link](http://stackoverflow.com/questions/12996427/mysqli-stmt-get-result-alternative-for-php-5-2-6/13794165#13794165) – michikot Jun 25 '14 at 02:19
  • possible duplicate of [Fatal error: Call to undefined method mysqli\_stmt::get\_result()](http://stackoverflow.com/questions/13659856/fatal-error-call-to-undefined-method-mysqli-stmtget-result) *mysqli_stmt :: get_result is Available only with mysqlnd.* – Scuzzy Jun 25 '14 at 02:19
  • From php.ini i got this information PDO drivers sqlite, mysql – user2976078 Jun 25 '14 at 02:23
  • Do you have a `mysqlnd` section under `phpinfo()`? – Machavity Jun 25 '14 at 02:32
  • yes i have `mysqlnd` under `phpinfo()` check this image [link](http://i.stack.imgur.com/GR0aZ.png) – user2976078 Jun 25 '14 at 02:39
  • @Machavity did you see the image ? – user2976078 Jun 25 '14 at 02:53
  • I'm not sure what else to suggest then. If you have access to restart your web server I would try that. – Machavity Jun 25 '14 at 03:10
  • i am just user on the server i don't have access to restart the server @Machavity , any other idea ? maybe the code missing something – user2976078 Jun 25 '14 at 03:15
  • Does this answer your question? [Fatal error: Uncaught Error: Call to undefined method mysqli\_stmt::get\_result()](https://stackoverflow.com/questions/51567335/fatal-error-uncaught-error-call-to-undefined-method-mysqli-stmtget-result) – Dharman Nov 30 '20 at 10:56

1 Answers1

1

I had this issue on Namecheap's Shared Hosting.

I solved it by switching from mysqli to nd_mysqli module in the PHP Selector in CPanel.

PHP Selector configuration

I was having the same error of get_results() seemingly not existing, but after talking to their support they confirmed it should work.

I kept playing with PHP configuration and ended up getting it to work.

elfensky
  • 45
  • 2
  • 7