Firefox PHP

Display Last 5 Phorum Posts -script

Posted by dagon 
Re: Display Last 5 Phorum Posts -script
March 06, 2007 03:07PM
In the query before the order by (if you have one) post the query you are using if you need more help.
Re: Display Last 5 Phorum Posts -script
March 06, 2007 03:09PM
@$con=mysql_connect($host,$dbuser,$dbpass) or die ("cannot connect to MySQL");
$select_db = mysql_select_db($dbname,$con);

$result = mysql_query("select * from $table m, $forum_table f where m.forum_id = f.forum_id order by m.datestamp desc limit $number") or die("Failed Query of " . $result. mysql_error());

while($row = mysql_fetch_array($result)){
Re: Display Last 5 Phorum Posts -script
March 06, 2007 03:21PM
$result = mysql_query("select * from $table m, $forum_table f where m.forum_id = f.forum_id order by m.datestamp WHERE forum_id !=25 desc limit $number") or die("Failed Query of " . $result. mysql_error());
Re: Display Last 5 Phorum Posts -script
March 06, 2007 03:46PM
I get this:

Failed Query of You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE forum_id !=117 desc limit 1' at line 1

(the forum id is actuall 117)



Edited 1 time(s). Last edit at 03/06/2007 03:50PM by M@AATW.
Re: Display Last 5 Phorum Posts -script
March 06, 2007 04:32PM
There's now two WHERE statements in the query. Make it:

$result = mysql_query("select * from $table m, $forum_table f where m.forum_id = f.forum_id and forum_id != 25 order by m.datestamp desc limit $number") or die("Failed Query of " . $result. mysql_error());mysql_error());


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Display Last 5 Phorum Posts -script
March 06, 2007 05:00PM
Hmmm...that seems to turn the whole script off...
Re: Display Last 5 Phorum Posts -script
March 06, 2007 07:04PM
Hmm.. cutting and pasting error probably. I see that my code ends in "mysql_error());mysql_error());" That should be only one time "mysql_error());".


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Display Last 5 Phorum Posts -script
March 07, 2007 05:29AM
Hmmm.....Failed Query of Column 'forum_id' in where clause is ambiguous
Re: Display Last 5 Phorum Posts -script
March 07, 2007 07:11AM
Okay, almost there then ;-)

and forum_id != 25 --> and m.forum_id != 25


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Display Last 5 Phorum Posts -script
March 07, 2007 07:51AM
Right...added that. EHang on...it's working....! Thanks guys, much appreciated ;-)



Edited 1 time(s). Last edit at 03/07/2007 07:51AM by M@AATW.
Sorry, only registered users may post in this forum.

Click here to login