roymogg
03-10-2010, 05:07 PM
I have been trying to get the latest photopost classifieds direct php working:
I am using the following code from over there at PC:
$host = 'localhost';
$dbUser = 'example';
$dbPass = 'password';
$db = 'forum';
mysql_connect("$host", "$dbUser", "$dbPass") or die(mysql_error());
mysql_select_db("$db") or die(mysql_error());
ob_start();
$result = mysql_query("SELECT id,cat,bigimage FROM cp_products WHERE bigimage != '' order by rand() LIMIT 2" ) or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
print"<center>";
print "<a href=\"http://www.example.com/classifieds/showproduct.php?product=" . $row['id'] . "&cat=" . $row['cat'] . "\"><img src=\"http://www.example.com/classifieds/data/" . $row['cat'] . "/thumbs/" . $row['bigimage'] . "\" border=\"0\"></a>";
print "</center>";
}
$output .= ob_get_contents();
ob_end_clean();
I put this into a widget or forum block and module renders but no content and I cannot see a problem.
EDIT: There was a slip in the path to the image - the above code works fine
cheers
Roy
I am using the following code from over there at PC:
$host = 'localhost';
$dbUser = 'example';
$dbPass = 'password';
$db = 'forum';
mysql_connect("$host", "$dbUser", "$dbPass") or die(mysql_error());
mysql_select_db("$db") or die(mysql_error());
ob_start();
$result = mysql_query("SELECT id,cat,bigimage FROM cp_products WHERE bigimage != '' order by rand() LIMIT 2" ) or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
print"<center>";
print "<a href=\"http://www.example.com/classifieds/showproduct.php?product=" . $row['id'] . "&cat=" . $row['cat'] . "\"><img src=\"http://www.example.com/classifieds/data/" . $row['cat'] . "/thumbs/" . $row['bigimage'] . "\" border=\"0\"></a>";
print "</center>";
}
$output .= ob_get_contents();
ob_end_clean();
I put this into a widget or forum block and module renders but no content and I cannot see a problem.
EDIT: There was a slip in the path to the image - the above code works fine
cheers
Roy