lecithin Posted March 3, 2009 Share Posted March 3, 2009 I'm a new to php and web development. I can't seem to figure out why my app crashes when calls to certain methods of the mysqli are made. MySQLi_Result->fetch_object or MySQLi_Result->fetch_assoc. Both these fail and apache crashes. but both MySQLi_Result->fetch_row() and MySQLi_Result->fetch_array(MYSQLI_NUM) works fine . here is my code.. $query = 'Select * from user_accounts where user_name = '."'".$_SESSION["username"]."'"; //echo $query; $results = $conn->query($query); if (!$results) { throw new Exception('Could not execute query'); } $row = $results->fetch_array(MYSQLI_ASSOC); <- fails here any ideas? I searched, and there was someone else who had a similiar problem. They apparently downgraded, rebooted and their problem was solved. I haven't downgraded, but I have rebooted. php 5.2.9 mysql 5.1.30 Quote Link to comment Share on other sites More sharing options...
nefty123 Posted April 14, 2009 Share Posted April 14, 2009 I am encountering the same problem while working through Sams Teach Yourself PHP, MySQL and Apache 4th edition book. mySQL 5.1.30 Apache 2.2.11 PHP 5.2.8 My code is: <?php $mysqli = mysqli_connect("localhost", "root", "bernedit123", "sty"); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { $sql = "SELECT * FROM testTable"; $res = mysqli_query($mysqli, $sql); if ($res) { while ($newArray = mysqli_fetch_array($res, MYSQLI_ASSOC)) { $id = $newArray['id']; $testField = $newArray['testField']; echo "The ID is ".$id." and the text is ".$testField."<br/>"; } } else { printf("Could not retrieve records: %s\n", mysqli_error($mysqli)); } mysqli_free_result($res); mysqli_close($mysqli); } ?> I get the MS Windows error pop up and Internet Explorer cannot display the page: Microsoft windows message Apache HTTP Server stopped working and was closed A problem caused the application to stop working correctly. Windows will notify you if a solution is available. I have been using Google to locate an answer. Thanks for any feedback. Quote Link to comment Share on other sites More sharing options...
Mchl Posted April 14, 2009 Share Posted April 14, 2009 Please run phpinfo and post which MySQL API version it reports. As far as I remember 5.0.51 was the last stable version for Windows. Quote Link to comment Share on other sites More sharing options...
nefty123 Posted April 14, 2009 Share Posted April 14, 2009 Thanks for quick reply. The Client API library version is 5.1.30. The Client API header version is 5.0.51a. Quote Link to comment Share on other sites More sharing options...
Mchl Posted April 14, 2009 Share Posted April 14, 2009 Try to get API library version 5.0.51a. Unfortunately I don't know how one can find it... Quote Link to comment Share on other sites More sharing options...
nefty123 Posted April 17, 2009 Share Posted April 17, 2009 Well I took Mchl's advice, in a way. I uninstalled my versions and then installed from the CD that came with the book. Now I have: mySQL 5.0.51a Apache 2.2.8 PHP 5.2.5 The mysqli_assoc now works perfectly. I can not say definitively that the newer versions had a bug. It may have been during this install I entered the correctly needed parms for it to work. I did have a heck of a time installing mySQL. I had to use www.angusj.com/resourcehacker to correct a line in the MySQLInstanceConfig.exe file. I used the sdafasd posting, MySQL Server 5.0.51a Installation guide for Windows Vista, found on forums.mysql.com. I used this guide because the InstanceConfig did not work from the .msi for mySQL. Well, thanks to all for your help. Quote Link to comment Share on other sites More sharing options...
keeB Posted April 17, 2009 Share Posted April 17, 2009 Or the book had a bug and is tailored to that specific version of mysqli Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.