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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.