[SOLVED] You have an error in your SQL syntax???

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

[SOLVED] You have an error in your SQL syntax???

Post by Dale »

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 'Resource id #7' at line 1
^ I keep getting that error and its really getting on my nerves. Click Here.

Here are the source codes for the database bits...

settings.php

Code: Select all

<?php
// DATABASE SETTINGS
$dhost = "localhost"; // Database Host
$duser = "dframe_dale"; // Database Username
$dpass = "PASSWORD"; // Database Password
$ddata = "dframe_dforum"; // Database
?>
db_connect.php

Code: Select all

<?php
include("settings.php");

$db = mysql_connect("$dhost","$duser","$dpass"); 
mysql_select_db ($ddata) or die(mysql_error()); 
?>
index.php

Code: Select all

<?php

include("header.php");

$query = mysql_query("SELECT * FROM df_forums"); 
$result = mysql_query($query) or die(mysql_error()); 

while($r=mysql_fetch_array($result)) 
{ 
	$id=$r["id"];
	$forumname=$r["forumname"];
	$description=$r["description"];
	$posts=$r["posts"];
	$threads=$r["threads"];
	$orderid=$r["orderid"];

   echo "<tr>
<td bgcolor="#C9C9C9" width="50%" align="left"><font face="verdana" size="2"><a href="./viewforum.php?fid=$id">$forumname</a></font><br><font face="verdana" size="1">$description</font></td>
<td bgcolor="#CCCCCC" width="10%" align="center"><font face="verdana" size="2">$posts</font></td>
<td bgcolor="#C9C9C9" width="10%" align="center"><font face="verdana" size="2">$threads</font></td>
<td bgcolor="#CCCCCC" width="30%" align="right"><font face="verdana" size="2" colour="#FF0000">Not Avaliable Yet</font></td>
</tr>";
}

include("footer.php");
?>
^ Thats the source but i still get the error...
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

I'm barely awake ... but this makes no sense?

Code: Select all

$query = mysql_query("SELECT * FROM df_forums"); 
$result = mysql_query($query) or die(mysql_error());
Try...

Code: Select all

$result = mysql_query("SELECT * FROM df_forums") or die(mysql_error());
Last edited by Buddha443556 on Wed Jul 14, 2004 7:44 am, edited 1 time in total.
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Thanks!
Post Reply