Jump to content

Trouble Retrieving data from a mysql db


Bongeh

Recommended Posts

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?

 

Link to comment
https://forums.phpfreaks.com/topic/94670-trouble-retrieving-data-from-a-mysql-db/
Share on other sites

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

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  ???

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.