Jump to content

[SOLVED] apache crashes when php runs MySQLi_Result->fetch_array(MYSQLI_ASSOC) or ...


lecithin

Recommended Posts

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

 

Link to comment
Share on other sites

  • 1 month later...

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.