Jump to content

Recommended Posts

I am trying to populate a form textarea with data I am getting from a table.  I am pretty new to PHP - feeling quite inadequate!

 

I don't think I am doing the query right because I try to print the query results to the screen and I get nothing.

 

       $postID = $_GET['post_id'];
       echo $postID;  // This works - I am getting the post id ok
     
      // Execute the query
      $result = mysql_query('SELECT post FROM blog WHERE id = $postID');
      echo $result;

 

I am getting nothing when I try to print out the contents of $result so my query must be wrong.

 

Thanks in advance for you help.
 

Also, arbitrary user input data should not be inserted directly into an SQL statement.

Make sure to mysql_real_escape_string the data before using it in an SQL statement.

 

However, in this particular case since the value is an expected integer, casting the value to an (int) or using intval is sufficient.

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.