Can't make PHP4 talk to MySQL
I have been trying for days to get my php scripts to control a mysql db. I am getting parse errors and it seems like PHP is using it's own functions and cannot recognize mysql functions like: mysql_num_rows for example.
Even when using a test script provided in a tutorial i am getting garbage on the screen:
Here's the script:
<html>
<body>
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("mydb",$db);
$result = mysql_query("SELECT * FROM employees",$db);
echo "<table border=1>\n";
echo "<tr><td>Name</td><td>Position</tr>\n";
while ($myrow = mysql_fetch_row($result)) {
printf("<tr><td>%s %s</td><td>%s</td></tr>\n",
$myrow[1], $myrow[2], $myrow[3]);
}
echo "</table>\n";
?>
</body>
</html>
And this is what I get as output:
\n", mysql_result($result,1,"first")); printf("Last Name: %s
\n", mysql_result($result,0,"last")); printf("Address: %s
\n", mysql_result($result,0,"address")); printf("Position: %s
\n", mysql_result($result,0,"position")); ?>
If I use PHP scripts running only PHP functions, everything works great. If I include mySQL functions... it completely freaks out.
This is my current setup:
Apache Server vs. 1.3.14
MySQL vs. 3.23.32
PHP vs. 4
Any suggestions?
Thanks,
April
|