sanderphp Posted May 5, 2008 Share Posted May 5, 2008 I use the $_SESSION['login_id'] to determine which user is logged in so I can write an ID to the table. The previous page uses session_start () and $rider_id = $_SESSION['login_id']; In order to use the login_id again on a 3rd page, do I need to do anything differently? I'm not returning any results with the following. $rider_id = $_SESSION['login_id']; $sql="SELECT * FROM `".$tablename."` WHERE rider_id = '$rider_id'"; Link to comment https://forums.phpfreaks.com/topic/104291-solved-sql-query-using-_session/ Share on other sites More sharing options...
947740 Posted May 6, 2008 Share Posted May 6, 2008 You have to start the session on the second page, too. Link to comment https://forums.phpfreaks.com/topic/104291-solved-sql-query-using-_session/#findComment-534030 Share on other sites More sharing options...
sanderphp Posted May 6, 2008 Author Share Posted May 6, 2008 Ok, that worked but also gave me this error: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/sanderan/public_html/php/cycling/submit_success.php:9) in /home/sanderan/public_html/php/cycling/submit_success.php on line 10 I googled this error and found that you can't have anything above the session_start() but I don't think I do. Is it something else? <html> <head> <title>Cycling Stats</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="style.css"/> </head> <table> <?php session_start(); $databasename='sanderan_cycling'; // Name of the database Link to comment https://forums.phpfreaks.com/topic/104291-solved-sql-query-using-_session/#findComment-534050 Share on other sites More sharing options...
dezkit Posted May 6, 2008 Share Posted May 6, 2008 the session start has to be above all javascript, html, php, perl, cgi, c++, java, 1337speak, etc... like so <?php session_start(); ?> <html> <head> <title>Cycling Stats</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="style.css"/> </head> <table> <?php $databasename='sanderan_cycling'; // Name of the database Link to comment https://forums.phpfreaks.com/topic/104291-solved-sql-query-using-_session/#findComment-534054 Share on other sites More sharing options...
atravotum Posted May 6, 2008 Share Posted May 6, 2008 Session start needs to be at the top of the page Link to comment https://forums.phpfreaks.com/topic/104291-solved-sql-query-using-_session/#findComment-534055 Share on other sites More sharing options...
sanderphp Posted May 6, 2008 Author Share Posted May 6, 2008 ah... I never knew you could have multiple <?php> sets in a page. Thanks!!!! Link to comment https://forums.phpfreaks.com/topic/104291-solved-sql-query-using-_session/#findComment-534068 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.