6

It might be a duplication of many questions however i dont seem to get my answer from any of the questions present.I am using multi domain linux hosting provided by hostgator.I tried to use mysqli_stmt_get_result() but it throws me an error stating as anundefined method.I contacted the hostgator admin panel and they enabled the mysqlnd extension for me.I do see the mysqlnd extension enabled in phpinfo of my website.However i still see the same error.

$mysqlnd = function_exists('mysqli_stmt_get_result');

if ($mysqlnd) {
    echo 'mysqlnd enabled!';
}
else
   var_dump("nope");

I tried to check if it is enabled or not , it says nope but i do see mysqlnd as enabled in my phpinfo.

What is the problem and how can i solve this one ? Plus using with any other method is not an option because i have already coded the whole project using mysqli_stmt_get_result().

Update:

Mysqli

mysqlnd

Query:

 $stmt=$this->link->prepare("SELECT `Session_Data`,`ip_address` FROM Session WHERE `Session_Id` = ? AND `Session_Expires` > '".date('Y-m-d H:i:s')."'");

        $stmt->bind_param("s",$id);
        $stmt->execute();
         $res=$stmt->get_result();
Tilak Raj
  • 1,369
  • 5
  • 31
  • 64

3 Answers3

29

To make this thing work, Enable nd_mysqli in php extensions and disable mysqli. This will work like charm!

Dharman
  • 30,962
  • 25
  • 85
  • 135
Tilak Raj
  • 1,369
  • 5
  • 31
  • 64
  • how did you do that through cpanel? – user2782001 Aug 23 '16 at 16:38
  • 3
    @user2782001 Cpanel->Select PHP version(This might be under software tab)->You will see modules there.You can check uncheck any module you want to,as well as you can change your php version.Hope, this might help. – Tilak Raj Aug 24 '16 at 05:07
  • Is there a way to enable it and keep mysqli active aswell? – Max O. Nov 13 '16 at 15:46
  • 2
    i tried doing that but cpanel doesn't allow it and `nd_mysqli` is the same as `mysqli`, i have kept it active while unchecking `mysqli` , till this day i have not faced any thing that worked on `mysqli` and not on `nd_mysqli`. – Tilak Raj Nov 13 '16 at 15:53
  • 1
    I did this after fiddling around but for some reason, although the errors have gone, no database results seem to be returning :/ PHP 7.0 / 7.1 – CodeUK Apr 08 '17 at 21:32
  • 1
    Wow what an answer. superb answer same my lot of time to debug into server – Hardik Shah Sep 12 '17 at 08:52
  • @CodeUK debug your code , might be some logical error. – Tilak Raj Jan 14 '18 at 03:34
  • 2
    @BOTJr. I upgraded my server to PHP 7.4 and it broke my queries. After relentless searching all day and all night with answers stating to use another function or functions; that didn't seem to work in my situation I find this and it worked wonders!! Thank you good sir! +1 – Dawson Irvine Oct 19 '20 at 01:03
  • In my case, i had to uncheck "mysqli" first before i could enable "nd_mysqli" – The concise Nov 12 '21 at 13:28
3

Go to Cpanel ->PHP version under software section and change the options as below enable nd_mysqli enter image description here

Nelu
  • 151
  • 1
  • 6
0

Yes It worked with nd_mysqli option selected. Thanks @BOTJr. It also shows 'nd_mysqli skipped as conflicting' as an warning so no need to worry just disable mysqlnd, mysqli and then enable again nd_mysqli option. It will work fine.