Dear John,
Many thanks for your response. It is true that the
Beginning MySQL book seems to reference MySQL v4.01. Oddly, this hadn't occurred to me.
I have attempted your suggestion. Unfortunately, this does not seem to solve the problem either. Is it possible that I have PHP configured incorrectly? The phpinfo() command shows that I have support for both mysql and mysqli enabled, so this seems doubtful. Maybe I did not adjust my code appropriately. I am therefore posting my revised code here for your reference. If you see anything wrong with this, or have any further suggestions, your insights are greatly appreciated:
<html>
<head>
<title>The Parts Table</title>
</head>
<body bgcolor="white">
<?php
// Define the variables necessary to access MySQL.
$host="localhost";
$user="username";
$pw="password";
$database="test";
// Make connection to MySQL Database.
$dbc=new mysqli($host, $user, $pw, $database);
// Create an SQL query.
$query="SELECT PartName, PartID FROM Parts ORDER BY PartName";
// Execute the query and store the query results in memory.
$result=mysql_query($query) or die ("Query failed!");
// Process the query results.
if (mysql_num_rows($result) > 0)
{
echo "<h2>Data from the Parts Table<br>
in the MySQL Test database</h2>";
echo "<br>";
echo "<table cellpadding=10 border=1>";
echo "<thead>";
echo "<tr bgcolor="#ffcccc">
<th>Part Name</th>
<th>Part Number</th>
</tr>";
echo "</thead>";
echo "<tbody>";
while ($row=mysql_fetch_row($result))
{
echo "<tr>";
echo "<td>" . $row[0] . "</td>";
echo "<td>" . $row[1] . "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
}
else
{
echo "The Parts table is empty.";
}
// Free the memory used for the query results.
mysql_free_result($result);
// Close the connection to MySQL.
mysql_close($connection);
?>
</body>
</html>
================================================== ===================
END OF CODE
================================================== ===================
Please note that for security reasons, I have changed the username and password to generic names.
Again, many thanks for your help.
Sincerely,
Robert Hieger
Quote:
quote:Originally posted by jmaronilla
Robert,
The book your are referencing to has an older version of MySQL.
Probably 4.1 or lesser.
I you have mentioned you got 5.0 version intalled.
Under the 5.0 version, almost all mysql properties/functions
now uses mysqli.
For example:
$dbc = new mysqli($host, $username, $password, $database);
I hope this helps,
John
|