lwolfe63 Posted March 14, 2013 Share Posted March 14, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/275633-trying-to-populate-a-form-textarea-with-a-php-variable/ Share on other sites More sharing options...
Barand Posted March 14, 2013 Share Posted March 14, 2013 Check out these links mysql_fetch_assoc mysql_fetch_row Quote Link to comment https://forums.phpfreaks.com/topic/275633-trying-to-populate-a-form-textarea-with-a-php-variable/#findComment-1418496 Share on other sites More sharing options...
AyKay47 Posted March 14, 2013 Share Posted March 14, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/275633-trying-to-populate-a-form-textarea-with-a-php-variable/#findComment-1418498 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.