+ Reply to Thread
Results 1 to 4 of 4

Thread: I can't retrieve info from db to display on page??

  1. #1
    goldy300's Avatar
    goldy300 is offline x10Hosting Member goldy300 is an unknown quantity at this point
    Join Date
    Jul 2008
    Location
    Australia
    Posts
    33

    Question I can't retrieve info from db to display on page??

    I'm trying to retrieve row[0] from pages table in the db but I keep getting this error:

    Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/daniel/public_html/govpetitions/index.php on line 76

    This is my code:

    PHP Code:
    include ("database.inc");
                        
                        
    $query "SELECT * FROM pages WHERE pages_id= $id";
                        
    $mysql_result=mysql_query($query,$conn);
                        
    $row=mysql_fetch_row($mysql_result);

                        
                        echo 
    $row[0]; 
    I would like it if someone could chat with me through msn to work this out... and I'll send whatever files to you for you to look at, I'll implement changes and upload live to check. I want to get this sorted out quickly. I've got 2 weeks before I have to finish this and I've got a lot to do.

    email me airbrushkits@live.com with your email and add me to msn

  2. #2
    Livewire's Avatar
    Livewire is offline Abuse Compliance Officer Livewire is a glorious beacon of lightLivewire is a glorious beacon of light
    Join Date
    Jun 2005
    Location
    Behind a keyboard.
    Posts
    8,998

    Re: I can't retrieve info from db to display on page??

    The query looks fine but what is $id set to?

    When in doubt replace:
    Code:
    $mysql_result=mysql_query($query,$conn);


    With

    Code:
    $mysql_result=mysql_query($query,$conn) or die($query . "<br/>" . mysql_error());


    Last part'll return the query, a line-break, then the error that is actually occuring, which should help narrow down what is actually causing the problem


    TOS breakers will be suspended regardless of race, creed, national origin, hair color, or favorite food. Thanks for your understanding!

  3. #3
    mephis's Avatar
    mephis is offline x10Hosting Member mephis is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    London, UK
    Posts
    39

    Re: I can't retrieve info from db to display on page??

    Two things could be wrong here:

    1) Like Livewire said: is $id set, and if so, what is it set to?
    If it's set to an INT then it's fine, if not:
    PHP Code:
    $query "SELECT * FROM pages WHERE pages_id='$id'"
    (notice the single quotes around $id)

    2) I assume you are making the connection to your database in the file "database.inc", but is $conn a valid connection?

  4. #4
    goldy30's Avatar
    goldy30 is offline x10Hosting Member goldy30 is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    60

    Re: I can't retrieve info from db to display on page??

    Ive had help and fixed some of the problem.



    I didn't understand about the pages_id=$id... I thought the $id stayed that way but the person who helped me changed it to '0'.

    PHP Code:
    $query "SELECT * FROM pages WHERE pages_id='0'"
    Now I need help with inserting title and blurb in the pages database. contact me on msn asap
    Last edited by goldy30; 11-22-2008 at 03:53 AM.

+ Reply to Thread

Similar Threads

  1. PHP Nuke 7.9 doesn't display on home page?
    By themasterrocker in forum Scripts & 3rd Party Apps
    Replies: 0
    Last Post: 05-26-2008, 02:37 PM
  2. Load Pages from one Page via URI
    By VPmase in forum Tutorials
    Replies: 1
    Last Post: 05-02-2008, 01:35 AM
  3. php next page error
    By nahsorhseda in forum Free Hosting
    Replies: 5
    Last Post: 11-25-2007, 05:40 AM
  4. Blank page...?
    By DecemberGuild in forum Scripts & 3rd Party Apps
    Replies: 6
    Last Post: 11-24-2006, 01:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers