Jump to content

Trying to populate a form textarea with a PHP variable


lwolfe63

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.

Archived

This topic is now archived and is closed to further replies.

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