SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Mar 2003
    Location
    Portugal
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy ?? Resource id #4 ??

    hi, guys. i just bought a book in site.com and i'm new here. and im new in php to.

    i have a litle problem, very heird... after i connect to mysql database and choose the table i say a variable is equal to a query and then i make an echo of the varible and gives me this error "Resource id #4"...

    the code is this simple:
    $tema = mysql_query ("SELECT tema FROM noticias WHERE tema='teste'");
    echo($tema);

    this ever hapen to anyone?

    thx for the atention

  2. #2
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to use a function to actual get the result from the db.
    mysql_query do query the db but it only returns a Resource id.
    Try:
    PHP Code:
    $result mysql_query ("SELECT tema FROM noticias WHERE tema='teste'" ) or die(mysql_error());
    $row mysql_fetch_array($result);
    echo 
    $row['tema']; 
    See www.php.net/mysql-fetch-array

    -Helge

  3. #3
    SitePoint Member
    Join Date
    Mar 2003
    Location
    Portugal
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    ty so much... how dumb i am! of course i need to fetch the result of the query!!

    ty helge


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •