webguync Posted April 21, 2010 Share Posted April 21, 2010 I am storing a session variable and want to use that variable in a SQL Query. I think my syntax is a bit off, so need some help with this. I currently have $_SESSION['user_id']; $user_id='user_id'; print_r($_SESSION); //DELETE QUERY TO SELECT RECORD TO DELETE BASED ON LOGIN INFO. $query_delete = "DELETE FROM log_April2010 USING April2010 INNER JOIN roster_April2010 WHERE April2010.user_id = roster_April2010.user_id AND roster_April2010.user_id = '"{$_SESSION['user_id']}"'"; echo $query_delete; //for debugging test any assistance is greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/199265-help-with-syntax-for-including-session-variable-in-sql-query/ Share on other sites More sharing options...
Alex Posted April 21, 2010 Share Posted April 21, 2010 $query_delete = "DELETE FROM log_April2010 USING April2010 INNER JOIN roster_April2010 WHERE April2010.user_id = roster_April2010.user_id AND roster_April2010.user_id = '{$_SESSION['user_id']}'"; Link to comment https://forums.phpfreaks.com/topic/199265-help-with-syntax-for-including-session-variable-in-sql-query/#findComment-1045878 Share on other sites More sharing options...
webguync Posted April 21, 2010 Author Share Posted April 21, 2010 that did the trick, thanks! Link to comment https://forums.phpfreaks.com/topic/199265-help-with-syntax-for-including-session-variable-in-sql-query/#findComment-1045901 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.