[Wolves] Php question

Chris Ball chris at mnemonik.net
Tue Jan 18 09:07:58 GMT 2005


Wayne, I've cleaned up your code, but I can't see what's wrong with it. 
What problems are you having exactly?

[code as follows]

<?php
	require("common.php");
	dbConnect();
	$time = time();
	$result = mysql_query( "SELECT `ad_id`, `cat_id`, `subject`, `add_date` 
FROM `ads` WHERE `exp_date` > '$time'ORDER BY `add_date` DESC LIMIT 20") 
or die(mysql_error());
	displayHeader("Recent Added");
	// include( "menu.php" );
	echo "<p align=\"center\"><font size=\"4\">Recent Listed</font></p>\n";
	echo "<div align=\"center\">\n";
	echo "<center>\n";
	echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" 
width=\"500\">\n";
	echo "<tr class=\"frame\">\n";
<much more snipped>

results in an email:

'$time' ORDER BY `add_date` DESC LIMIT 20" ) or die(mysql_error());
displayHeader( "Recent Added" ); // include( "menu.php" );
echo "Recent Listed\n";
echo "\n";
echo "\n";
echo "
<more snipped.>

[/code]


A good habit to get into when using PHP and MySQL is to encase 
references to tables or fields with `` and to encase references to data 
in ''. Also use die instead of error, as this will kill your script at 
the point where you have the first error, which makes problems ten times 
easier to track down.

If you want to send me an off list email with the full script (with all 
your passwords and whatever removed) i'll take a look again if you need 
me too.




More information about the Wolves mailing list