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
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

 

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.