The select statement works finewhen logged into mySQL from a telnet client, but when I try from PHP it is not working:
<?php
require("global.php3");
$stmt = "SELECT * from REVIEWS
ORDER by ts
LIMIT 20" ;
if (!($link=mysql_pconnect($hostName, $userName, $password))) {
printf("Error");
exit() ;
}
if (!mysql_select_db($databaseName, $link)) {
printf("Error");
exit() ;
}
if (!($result =mysql_query($stmt, $link))) {
printf("Error");
exit() ;
}
$number = 0;
while (($row = mysql_fetch_object($result))){
++$number;
$latestname = mysql_query("SELECT PRODUCTNAME FROM PRODUCTS WHERE ROWID='" . $row->KEYTOPROD . "'");
printf("
<font color=\"#FF9900\">$number</font> <a href=\"view.php3?id=" . $row->KEYTOPROD . "\"><font color=\"#FFFFFF\">$latestname</font></a><br>
");
}
mysql_free_result($result) ;
?>
That is the code and it is supposed to display the latest reviews written. The original select statement is selecting the newest 20 revews from the REVIEWS table (using timestamp) and it works fine. Then when in the results while loop I want to display the product the review is on so I do a select statement with the key that corresponds the review to the product its on and it doesnt work.
Even when I put ROWID=1 it still does not work!
It displays Resource id #10 (or some other number)!
At http://www.pbreview.com/ you can see on the left side of the page what it displays!!!
Thanks for any help,
John