SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Mar 2004
    Location
    scotland
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    putting html into the database

    Hi folks,

    I downloaded a nifty program called visual text box that lets you type in a textarea and format the text with a little control panel. When you press submit, it turns it into formatted html for you.

    I then send it to preview.php - stored in the variable $content - to see how it looks.

    If I like what I see, I send it to publish.php, which is supposed to store $content in the database. This is where the problem starts. When I try to display $content I am given Resource id #3.

    I know $content does contain the correct data because it displays ok if I put
    PHP Code:
    echo $content
    before I put it in the database.

    What is going on?

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    The reason to why "Resource id #3" is displayed is that you're echoing the result resource directly, instead of using any of the result handling functions (mysql_fetch_assoc, mysql_fetch_object, mysql_result, etc.) as you should.

    PHP Code:
    $result mysql_query('SELECT foo FROM bar') or die(mysql_error());
    echo 
    sprintf('foo is %s at row 0'mysql_result($result0'foo')); 
    If there's something you don't understand, let me know.
    ERIK RIKLUND :: Yes, I've been gone quite a while.


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
  •