funbinod Posted September 11, 2014 Share Posted September 11, 2014 on php 5.5.6 mysqli_stmt_get_result worked fine but on php 5.3 it says undefined function while php.net says this can be used on "PHP 5 >= PHP 5.3" why??? can there be some mistakes in my code?????? Link to comment Share on other sites More sharing options...
Ingolme Posted September 11, 2014 Share Posted September 11, 2014 There's a comment in the PHP manual page for the function. Please note that this method requires the mysqlnd driver. Othervise you will get this error: Call to undefined method mysqli_stmt::get_result() It might be that the server doesn't have the mysqlnd driver. Link to comment Share on other sites More sharing options...
funbinod Posted September 11, 2014 Author Share Posted September 11, 2014 how can I know if my server has mysqlnd driver or not????????? Link to comment Share on other sites More sharing options...
justsomeguy Posted September 11, 2014 Share Posted September 11, 2014 A phpinfo page will list all of that information. There will be a section for mysqlnd. Link to comment Share on other sites More sharing options...
funbinod Posted September 12, 2014 Author Share Posted September 12, 2014 (edited) I did not see mysqlnd available there. but I found an option to upgrade my php to 5.5 for public_http folder. when I did that it did not show the error but it did not return any result also.... Edited September 12, 2014 by funbinod Link to comment Share on other sites More sharing options...
justsomeguy Posted September 12, 2014 Share Posted September 12, 2014 Is that because the SQL query didn't return any results? Do you have all error messages enabled? Are you checking how many results it returned? It's hard to comment without seeing the code you're using. Link to comment Share on other sites More sharing options...
funbinod Posted September 12, 2014 Author Share Posted September 12, 2014 the same code is working fine in my local server. its just not showing anything at my online server. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 12, 2014 Share Posted September 12, 2014 I understand it's working on one server and not another one, that's because the servers are different. If it's showing a blank page then it sounds like you do not have error messages enabled on the online server. Link to comment Share on other sites More sharing options...
funbinod Posted September 12, 2014 Author Share Posted September 12, 2014 it should be enabled. coz I've made no changes in setting and before this there was displaying some error messages on some pages. you yourself have noticed some of them before, didn't u???? Link to comment Share on other sites More sharing options...
Ingolme Posted September 12, 2014 Share Posted September 12, 2014 You said you just changed your server's PHP version so some of the settings were probably altered. Â Go activate error displaying on your page with PHP and see if any errors show up. ini_set('display_errors', '1');error_reporting(E_ALL); Link to comment Share on other sites More sharing options...
funbinod Posted September 12, 2014 Author Share Posted September 12, 2014 ok! it displayed the msg now. it means there was some alteration on error msg setting????? did it happened because I changed the version of php????? but the msg it is displaying is the error is the same msg it was displaying before that is --- undefined function mysqli_stmt_get_result  I checked the version and the mysqlnd driver in the php configuration and it said php is version 5.5.11 and mysqlnd driver is present... Link to comment Share on other sites More sharing options...
Ingolme Posted September 12, 2014 Share Posted September 12, 2014 Is that the only error on your page? First, check phpinfo to see if MySQLi is installed. Â Post the part of your code that isn't working and a few of the surrounding lines. Â If you get any error messages, copy and paste them here exactly as they are. There might be some context missing that makes it difficult to figure out exactly what the problem might be. Link to comment Share on other sites More sharing options...
funbinod Posted September 12, 2014 Author Share Posted September 12, 2014 (edited) yes! this is the only message on the page... Â Fatal error: Call to undefined function mysqli_stmt_get_result() in /home..................../classFifo.php on line 8 Â and here is the code for classFifo.php <?php$totqty = 0;$totamt = 0;$querysss = "SELECT qty, amt FROM fifo WHERE sid=? AND cid=$cid ORDER BY date DESC";$stmt = mysqli_prepare($connect, $querysss);if (mysqli_stmt_bind_param($stmt, 'i', $sid)){ mysqli_stmt_execute($stmt) or die("Error: " . mysqli_error($connect)); $result = mysqli_stmt_get_result($stmt); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { if ( !is_null($row['qty']) ){ if ($row['qty']>0 && $row['qty']+$totqty > $cqty){ $diff = $cqty - $totqty; $totqty = $cqty; $totamt += $diff*$row['amt']/$row['qty']; // now you must record the remain count = $row->remain-$diff } else if ($row['qty']>0) { $totqty += $row['qty']; $totamt += $row['qty']*$row['amt']/$row['qty']; // now you must record the remain=0 } } else if ($row['qty']+$totqty > $cqty){ $diff = $cqty-$totqty; $totqty = $cqty; $totamt += $diff*$row['amt']/$row['qty']; // now you must record the remain count = $row->qty-$diff } else { $totqty += $row['qty']; $totamt += $row['amt']; // now you must record the remain=0 } } if ($cqty != $totqty) { echo "error: recorded totqty={$totqty} purchased is insufficient to match cqty={$cqty}"; }} else { echo 'error: could not bind';}$totamtarr[ $sid ] = $totamt;$runSum = 0;foreach($totamtarr as $clamt) { $runSum += $clamt; $total[] = $runSum;}mysqli_stmt_close($stmt);?> Edited September 12, 2014 by funbinod Link to comment Share on other sites More sharing options...
justsomeguy Posted September 12, 2014 Share Posted September 12, 2014 You might want to ask your host. As far as I can tell, if MySQLi and mysqlnd are loaded then that function should be defined. Link to comment Share on other sites More sharing options...
funbinod Posted September 16, 2014 Author Share Posted September 16, 2014 i asked my host. but they are still unable to find out d problem and this is still unsolved. will u please guide me (if this problem is not solved) to change d code to work under php 5.3 without mysqlnd driver????? Link to comment Share on other sites More sharing options...
funbinod Posted September 16, 2014 Author Share Posted September 16, 2014 back with a self try. please suggest if it gives d exact result as the above code gives.. <?php$totqty = 0;$totamt = 0;$querysss = "SELECT qty, amt FROM fifo WHERE sid=$sid AND cid=$cid ORDER BY date DESC";if ($stmt = mysqli_prepare($connect, $querysss)) {//if (mysqli_stmt_bind_param($stmt, 'i', $sid)){ mysqli_stmt_execute($stmt) or die("Errorsssss: " . mysqli_error($connect)); mysqli_stmt_bind_result($stmt, $qty, $amt); while (mysqli_stmt_fetch($stmt)) { if ( !is_null($qty) ){ if ($qty>0 && $qty+$totqty > $cqty){ $diff = $cqty - $totqty; $totqty = $cqty; $totamt += $diff*$amt/$qty; // now you must record the remain count = $row->remain-$diff } else if ($qty>0) { $totqty += $qty; $totamt += $qty*$amt/$qty; // now you must record the remain=0 } } else if ($qty+$totqty > $cqty){ $diff = $cqty-$totqty; $totqty = $cqty; $totamt += $diff*$amt/$qty; // now you must record the remain count = $row->qty-$diff } else { $totqty += $qty; $totamt += $amt; // now you must record the remain=0 } } if ($cqty != $totqty) { echo "error: recorded totqty={$totqty} purchased is insufficient to match cqty={$cqty}"; }} else { echo 'error: could not bind';}$totamtarr[ $sid ] = $totamt;$runSum = 0;foreach($totamtarr as $clamt) { $runSum += $clamt; $total[] = $runSum;}mysqli_stmt_close($stmt);?> I changed the code by getting idea from <php.net/manual/en/mysqli-stmt.bind-result.php> Link to comment Share on other sites More sharing options...
justsomeguy Posted September 16, 2014 Share Posted September 16, 2014 And does the code return the results you expect? Link to comment Share on other sites More sharing options...
funbinod Posted September 16, 2014 Author Share Posted September 16, 2014 yes! I just wanted to know is the code perfect or it is just giving d result for now only! will it still work if I updated my data??? Link to comment Share on other sites More sharing options...
justsomeguy Posted September 16, 2014 Share Posted September 16, 2014 You should test that yourself, update your data and see what happens. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now