Suchy Posted May 14, 2007 Share Posted May 14, 2007 I hava a session variable that holds an int passed from a previous page, the new page looks like: session_start(); session_register ("new_id"); $id = $_GET['id']; // passed from previous page $_SESSION['new_id'] = $id; Then on this page I have a submit form if(in("submit")) { ... session_start(); $_SESSION['new_id'] = $temp ; $query = "SELECT * FROM names WHERE id = '$new_id' "; ... When I press the submit button the session inside the if(in("submit")) function is not working? What is wrong with my code, and how to fix it? Quote Link to comment https://forums.phpfreaks.com/topic/51405-sessions-problem/ Share on other sites More sharing options...
btherl Posted May 14, 2007 Share Posted May 14, 2007 What is in() ? It is not part of standard php. Quote Link to comment https://forums.phpfreaks.com/topic/51405-sessions-problem/#findComment-253142 Share on other sites More sharing options...
Suchy Posted May 14, 2007 Author Share Posted May 14, 2007 When I press the submit button on the form that function kicks in to insert values into MYSQL Quote Link to comment https://forums.phpfreaks.com/topic/51405-sessions-problem/#findComment-253144 Share on other sites More sharing options...
btherl Posted May 15, 2007 Share Posted May 15, 2007 Can you post the rest of your script? I don't understand your description of what your code is supposed to do either. And please describe in detail what "the if(in("submit")) function is not working" looks like. What do you see on the screen? What did you expect to see? Quote Link to comment https://forums.phpfreaks.com/topic/51405-sessions-problem/#findComment-253149 Share on other sites More sharing options...
Suchy Posted May 15, 2007 Author Share Posted May 15, 2007 I use this function anytime I have a form, since I can have multiple forms with multiple id (ex. id="submit" , then a second form id="update" then third id="delete"...) and then I can have multiple functions ex: if(in("update")) { $id = $_POST['id']; $contacted = $_POST['contacted']; $done = $_POST['done']; $paid = $_POST['paid']; $jobnotes = mysql_real_escape_string($_POST['jobnotes']); $query = "UPDATE entries SET contacted = '$contacted' , done = '$done' , paid = '$paid' , jobnotes = '$jobnotes' WHERE id = '$id' "; $result = mysql_query($query); } /// if(in("Delete")) { $id = $_POST['id']; $query = "DELETE FROM entries WHERE id = '$id'"; $result = mysql_query($query); } These are just examples from previous sites. The function that I am talking about is: if(in("submit")) { session_start(); $_SESSION['new_id'] = $xxx ; $query = "SELECT * FROM photo WHERE id = '$new_id' "; $result = mysql_query($query); $entriesResults = getRows($result); } No what I suposed to ge is the picture that has that id. and then use the $new_id in <img src=" "> tag Quote Link to comment https://forums.phpfreaks.com/topic/51405-sessions-problem/#findComment-253154 Share on other sites More sharing options...
btherl Posted May 15, 2007 Share Posted May 15, 2007 If you want to get $new_id from the session, you should do this: $new_id = $_SESSION['new_id']; Quote Link to comment https://forums.phpfreaks.com/topic/51405-sessions-problem/#findComment-253161 Share on other sites More sharing options...
Suchy Posted May 15, 2007 Author Share Posted May 15, 2007 This is not working. Also in the code I posted above it should be: $query = "SELECT * FROM photo WHERE id = '$xxx' "; and not $query = "SELECT * FROM photo WHERE id = '$new_id' "; Quote Link to comment https://forums.phpfreaks.com/topic/51405-sessions-problem/#findComment-253164 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.