Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1924 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

i have problem when i start me session i got an error.help please

Thread title: i have problem when i start me session i got an error.help please
Reply  
Page 1 of 2 1 2 >
    Thread tools Search this thread Display Modes  
06-26-2009, 09:09 PM
#1
free-designer is offline free-designer
Status: Junior Member
Join date: Jun 2009
Location:
Expertise:
Software:
 
Posts: 98
iTrader: 0 / 0%
 

free-designer is on a distinguished road

  Old  i have problem when i start me session i got an error.help please

you know im not that good im still learning and the first thing im doing now is users management system.

it's really simple and easy all im doing is an
constants.php{witch's hold my database details}
connection.php{witch's where i start my connection and selceting my database name}

and i started my session at the top of the connection.php page like this...
PHP Code:
<?php
    session_start
();
    require(
"constants.php");

    
//the database connection
    
$connection mysql_connect(DB_SERVER,DB_USER);
    if(!
connection){
        die(
"Database connection failed: " mysql_error());
    }
    
    
//select database
    
$db_select mysql_select_db(DB_NAME$connection);
    if(!
$db_select){    
        die(
"database selection failed:" mysql_error()); 
    }
?>
the session_start(); function at the top when i type it i got this error
Code:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D:\xampp\htdocs\login script\index.php:1) in D:\xampp\htdocs\login script\includes\connection.php on line 2
...
i have tow pages the first one is index.php that where people will login here an image for examble

and an register page and everything okay with the register page

here is the code of the index.php

PHP Code:
    <?php require_once("includes/connection.php"); ?>
<html>
    <head>
        <title>User Login</title>
    </head>
    <style>
        body{background:#dbdbdb; margin:0; padding:0; font:'Verdana', Geneva, sans-serif;}
    </style>
    <link href="stylesheets/style.css" media="all" rel="stylesheet" type="text/css" />
    <body>
    
        <div id="box_outter">
        
        
            <div id="box_bg">
                <div class="header">
                <img src="images/logo.gif" alt="Logo" class="logo">
                <img src="images/bigman.jpg" alt="bigman" class="bigman">
                </div>
                
    <?php
        
if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['username']))
        {
             
?>
            
             <p>Welcome back<?=$_SESSION['username']?>.</p>
            
            <ul>
                <li><a href="logout.php">Logout.</a></li>
            </ul>
            
            <?php
        
}
        
        elseif(!empty(
$_POST['username']) && !empty($_POST['password']))
        {
            
$get_username mysql_real_escape_string($_POST['username']);
            
$get_password md5(mysql_real_escape_string($_POST['password']));
            
            
$checklogin mysql_query("SELECT * FROM users WHERE username = '".$username."' AND password = '".$password."'");
            
            if(
mysql_num_rows($checklogin) == 1)
            {
                 
$row mysql_fetch_array($checklogin);
                
                
$_SESSION['get_username'] = $username;
                
$_SESSION['LoggedIn'] = 1;
                
                echo 
"<p>you now logged in successfully</p>";
                echo 
"<meta http-equiv='refresh' content='=3;index.php' />";
            }
            
            else
            {
                echo 
"<p>this user dose not exist</p>";
            }
            
        }
        else
        {
      
?>
            <div class="body">
                <div class="login_box">
                <h1 class="li-h"></h1>
                <form action="index.php" method="post" class="login_box_out">
                
                    <input type="text" name="get_username" class="user_form" value="Username" 
                    onfocus="if(this.value=='Username'){this.value=''};" onBlur="if(this.value==''){this.value='Username'};">
                    
                    <input type="password" name="get_password" class="pass_form" value="password" 
                    onfocus="if(this.value=='password'){this.value=''};" onBlur="if(this.value==''){this.value='password'};">
                    
                    <input type="submit" name="login" class="login_btn" value=" ">
                </form>
                <a href="register.php" class="reg-link">Register</a>
                </div>
            </div>
            <?php  ?>
            </div>
        </div>
    </body>
</html>
<?php 
    mysql_close
($connection);
?>
and as we can see above of the code we required once the connection.php and the example for the connection at the top of the topic

notice that when i get rid of the session_start(); function everything okay and no erorr will come to me

so please people anyhelp with that cuz i really want to know the solve of this problem and i tired of searcing in google

Reply With Quote
06-26-2009, 09:29 PM
#2
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

The problem is on the very first line of index.php. There must not be any empty space before the text on that line.

Reply With Quote
06-26-2009, 10:12 PM
#3
free-designer is offline free-designer
Status: Junior Member
Join date: Jun 2009
Location:
Expertise:
Software:
 
Posts: 98
iTrader: 0 / 0%
 

free-designer is on a distinguished road

  Old

if u mean that it have to be like that
PHP Code:
<?php require_once("includes/connection.php"); ?>
<html>
    <head>
        <title>User Login</title>
    </head>
    <style>
        body{background:#dbdbdb; margin:0; padding:0; font:'Verdana', Geneva, sans-serif;}
    </style>
    <link href="stylesheets/style.css" media="all" rel="stylesheet" type="text/css" />
    <body>
if u want me to take the spaces out i did it and i still have the error
if u have anything thing else u want to tell me about it
and thank u very mush for helping me

Reply With Quote
06-26-2009, 10:21 PM
#4
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

You still have the exact same error, word for word?

Reply With Quote
06-26-2009, 10:23 PM
#5
free-designer is offline free-designer
Status: Junior Member
Join date: Jun 2009
Location:
Expertise:
Software:
 
Posts: 98
iTrader: 0 / 0%
 

free-designer is on a distinguished road

  Old

ohhh man it worked ohhh thank u so mush thanx

Reply With Quote
06-26-2009, 10:30 PM
#6
free-designer is offline free-designer
Status: Junior Member
Join date: Jun 2009
Location:
Expertise:
Software:
 
Posts: 98
iTrader: 0 / 0%
 

free-designer is on a distinguished road

  Old

i did somewthing wrong i did nothing of what u told me but i take a last look and i did what u told me and it worked

so i have a question u a php programer do u have any tutorials for u ?

Reply With Quote
06-27-2009, 01:46 AM
#7
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

You can not start sessions (which requires a cookie to be made) or make/modify cookies after you output anything. This is because cookie data is send with the HTTP headers, those must be sent to the browser before it can do anything with the data you feed it, so having that space there sends the HTTP headers.

Reply With Quote
06-27-2009, 08:53 AM
#8
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

Originally Posted by free-designer View Post
i did somewthing wrong i did nothing of what u told me but i take a last look and i did what u told me and it worked

so i have a question u a php programer do u have any tutorials for u ?
So you asked for help, some was given and you chose not to follow it. Then complained that it was still broken? Haha, just follow the advice next time!

I am a PHP programmer, yes. However I don't have any tutorials for myself, I'm beyond the stage of relying on tutorials to learn disparate little nuggets of scripts. Are you looking for tutorials for yourself? A good starting point might be tizag.com (I haven't followed their tutorials, but VI likes to suggest that site).

Reply With Quote
06-27-2009, 12:54 PM
#9
free-designer is offline free-designer
Status: Junior Member
Join date: Jun 2009
Location:
Expertise:
Software:
 
Posts: 98
iTrader: 0 / 0%
 

free-designer is on a distinguished road

  Old

Originally Posted by Village Genius View Post
You can not start sessions (which requires a cookie to be made) or make/modify cookies after you output anything. This is because cookie data is send with the HTTP headers, those must be sent to the browser before it can do anything with the data you feed it, so having that space there sends the HTTP headers.
thank you.i didn't realized that but i really thanx for ur help

Reply With Quote
06-27-2009, 12:57 PM
#10
free-designer is offline free-designer
Status: Junior Member
Join date: Jun 2009
Location:
Expertise:
Software:
 
Posts: 98
iTrader: 0 / 0%
 

free-designer is on a distinguished road

  Old

Originally Posted by Salathe View Post
So you asked for help, some was given and you chose not to follow it. Then complained that it was still broken? Haha, just follow the advice next time!

I am a PHP programmer, yes. However I don't have any tutorials for myself, I'm beyond the stage of relying on tutorials to learn disparate little nuggets of scripts. Are you looking for tutorials for yourself? A good starting point might be tizag.com (I haven't followed their tutorials, but VI likes to suggest that site).
sorry im just was really upset cuz it's my first time to do something and it's broken so i was confused but i just took a last look and i did what u told me and it worked you are the best...
about the tizag.com thank you for that i really needed an website to teach php except php.net
really thank you again

Reply With Quote
Reply  
Page 1 of 2 1 2 >


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed