tysty7 Posted December 7, 2008 Share Posted December 7, 2008 Hi all! I'm new to PHP but really enjoying it! I have this one issue i can't seem to figure out tho. When i get to this page, of which i included a snippet below, the GET['id'] holds a value, but if the value becomes erased when i try to use it in the POST-submit SQL Insert statement. I can't figure out how to get that value into the INSERT ->VALUES. help?? <?php session_start(); $secretID = $_GET['id']; // echo secretID; // returns a correct value here if (isset($_SESSION['id'])) { if ($_POST['submit']) { $sql = "INSERT INTO comments (secretID, comment_body, dateAdded) VALUES ( '$secretID', '$_POST[comment_body]', NOW())"; // echo secretID; // returns no value at all here Link to comment https://forums.phpfreaks.com/topic/135943-cant-pull-my-_getid-into-my-if_postsubmit-sql-insert/ Share on other sites More sharing options...
jnerotrix Posted December 7, 2008 Share Posted December 7, 2008 could you post all the code on the page Link to comment https://forums.phpfreaks.com/topic/135943-cant-pull-my-_getid-into-my-if_postsubmit-sql-insert/#findComment-708636 Share on other sites More sharing options...
graham23s Posted December 7, 2008 Share Posted December 7, 2008 // echo secretID; // returns no value at all here should be echo $secretID; what does that bring back? Graham Link to comment https://forums.phpfreaks.com/topic/135943-cant-pull-my-_getid-into-my-if_postsubmit-sql-insert/#findComment-708643 Share on other sites More sharing options...
msinternet Posted December 7, 2008 Share Posted December 7, 2008 Hi, Without the rest of the code it is hard but I would say that if the second string is not echoed the if statement may not be being satisfied. To test this add echo 'Hello'; or something similar just after eac hconditional statement and see what you do / do not see. Then, try to echo the conditions (i.e $_SESSION['id'] etc). Plus, you could use session_is_registered('id') instead here. Also, watch that you do not have standard variables named the same as session variables because this can cause problems. Martin Link to comment https://forums.phpfreaks.com/topic/135943-cant-pull-my-_getid-into-my-if_postsubmit-sql-insert/#findComment-708723 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.