Hello all, I am brand new to PHP, MySQL and Apache but I have over 25 years of software development experience on other platforms and more than 15 years of client/server, object-oriented, GUI, and SQL back-end development experience, so I feel confident that I will be able to give back to this community within the near future.
Anyways, hopefully someone can help me. Actually, I've made a lot of progress already. I've got PHP, MySQL and Apache installed and everything seems to be working to some extent. Through PHP, I can connect to my database and do a query and I get back rows when I use fetch_row. The problem is that when I use fetch_assoc or fetch_object, the system churns and churns and then finally comes back with a connection interruption error.
My code looks okay to me. I copied from php.net and the Welling and Thomson book. Here is my test code:
<?php
$mysqli = new mysqli("localhost", "bookorama", "bookorama123", "books");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
else {
echo "<p>I'm in.</p>";
}
$query = "SELECT title, isbn from books";
if ($result = $mysqli->query($query)) {
echo "<p>query is ok.</p>";
/* fetch assoc array
while ($row = $result->fetch_assoc()) {
echo "<p><strong>Title: ";
echo htmlspecialchars(stripslashes ($row['title']));
echo "<br />ISBN: ";
echo stripslashes($row['isbn']);
}
*/
/* fetch object array
while ($obj = $result->fetch_object()) {
echo "<p>$obj->title, $obj->isbn</p>";
}
*/
/* fetch row array */
while ($row = $result->fetch_row()) {
echo "<p>$row[0], $row[1])</p>";
}
/* free result set */
$result->close();
}
/* close connection */
$mysqli->close();
?>
Since I am expecting this to be a configuration problem, I am attaching my php.ini, http.conf and phpinfo output.
Thanks in advance if you can help me.