Bongeh Posted March 6, 2008 Share Posted March 6, 2008 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/fhlinux153/a/***.co.uk/user/htdocs/fetch.php on line 8 This is the error im getting from this code, the includes work correctly as far as i know, it connects to the db and selects the table okay. <?php include 'config.php'; include 'opendb.php'; $query = "SELECT addr, rent, frontimg, desc, advdesc, addimg1, addimg2, addimg3 FROM properties"; $result = mysql_query($query); while(list($addr,$rent,$frontimg,$desc,$advdesc,$addimg1,$addimg2,$addimg3)= mysql_fetch_row($result)) { echo "Address :$addr <br>" . "Rent PCM : $rent <br>" . "Front Image : $frontimg <br>" . "Description : $desc <br>" . "Advanced Description : $advdesc <br>" . "Additional Image 1 : $addimg1 <br>" . "Additional Image 2 : $addimg2 <br>" . "Additional Image 3 : $addimg3 <br><br>"; } include 'closedb.php'; ?> Anyone got any ideas whats going wrong? Quote Link to comment Share on other sites More sharing options...
shocker-z Posted March 6, 2008 Share Posted March 6, 2008 Try this as it will return your error <?php include 'config.php'; include 'opendb.php'; $query = "SELECT addr, rent, frontimg, desc, advdesc, addimg1, addimg2, addimg3 FROM properties"; $result = mysql_query($query) or die(mysql_error()); while(list($addr,$rent,$frontimg,$desc,$advdesc,$addimg1,$addimg2,$addimg3)= mysql_fetch_row($result)) { echo "Address :$addr " . "Rent PCM : $rent " . "Front Image : $frontimg " . "Description : $desc " . "Advanced Description : $advdesc " . "Additional Image 1 : $addimg1 " . "Additional Image 2 : $addimg2 " . "Additional Image 3 : $addimg3 "; } include 'closedb.php'; ?> regards Liam Quote Link to comment Share on other sites More sharing options...
Bongeh Posted March 6, 2008 Author Share Posted March 6, 2008 thanks liam, it kicked up this error 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 'desc, advdesc, addimg1, addimg2, addimg3 FROM properties' at line 1 desc, advdesc, addimg1, addimg2 and addimg3 are just fields in the table 'properties' the same as addr, rent and frontimg, but they see to be ok? im confused ??? Quote Link to comment Share on other sites More sharing options...
Bongeh Posted March 6, 2008 Author Share Posted March 6, 2008 sorry for the double post, If i only request the first three fields it works fine, anything past desc doesnt seem to work or has 'wrong syntax'.. i dont get it though, there all identical fields just with different names.. Anyone had this before? Quote Link to comment Share on other sites More sharing options...
phpanon Posted March 6, 2008 Share Posted March 6, 2008 desc is a reserved word in mySQL, try renaming that field in your database. Quote Link to comment Share on other sites More sharing options...
Bongeh Posted March 6, 2008 Author Share Posted March 6, 2008 thank you, it works a charm now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.