Jump to content

[SOLVED] SQL query using $_Session


sanderphp

Recommended Posts

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

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

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.