anything before the <?php tag is considered HTML and thus output. Since headers are always sent before the output is, they will be sent the moment PHP notices the spaces and/or newlines. So, what happens is:
PHP starts processing
PHP encounters spaces and/or newlines
PHP sends headers to the browser
PHP sends those spaces and/or newlines to the browser
PHP notices the <?php tag, and such swithed to "parsing-mode"
PHP notices session_start(); and thus tries to send a cookie (a cookie is actually one of the headers)
PHP notices that headers have already been sent! So it gives an error, because it can't "get them back and send them after the cookie again".
So, remove the spaces and/or newlines before the <?php tag to fix this.
Hope you get what to do now ;|
- Tul
Dre wrote:
thank u all .. I really did all of what u said but nothing worked !!!!!!!!!!!!! which was so so strange The problem was that the php.ini file I have got corrupted or something that the php.exe couldn't parse all of its values
Any way thanks again .. Now I have another error with the same file and session the errors are as follows //===================================================== Warning: session_start(): Cannot send session cookie - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\ELBA\logme_in.php:1) in C:\Program Files\Apache Group\Apache2\htdocs\ELBA\logme_in.php on line 2
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:\Program Files\Apache Group\Apache2\htdocs\ELBA\logme_in.php:1) in C:\Program Files\Apache Group\Apache2\htdocs\ELBA\logme_in.php on line 2
//=====================================================
"Dre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
Hi
I'm trying to make a small login system on my website, I'm using
Apache 2.0.49 for testing locally and PHP 4.3.4 on MS Windows XP Pro.
the login script is in the file logme_in.php shown below
//============================================================
<?php session_start(); include("db.php");
$username = trim(addslashes($_POST['user_name'])); $pass = trim(addslashes($_POST['password']));
if((empty($_POST['user_name'])) || (empty($_POST['password']))) {
echo "enter username/password"; }
else{ $sql = "SELECT * FROM members WHERE user_name='".$username."' AND password='".$pass."'"; $result = mysql_query($sql); $num_return = mysql_num_rows($result);
if($num_return ==1) { $row = mysql_fetch_array($result); session_register('uname'); $_SESSION['uname'] = $username;
} else { echo "invalid username/password"; } }
?> //============================================================
The problem is that every time I try to login I keep have the following error messages
****************************************************************************
****** Warning: session_start(): open(/tmp\sess_2984f6d378560d0882f37728dbe1defc, O_RDWR) failed: No such file or directory (2) in C:\Program Files\Apache Group\Apache2\htdocs\ELBA\logme_in.php on line 3
Warning: session_start(): Cannot send session cookie - headers already
sent
by (output started at C:\Program Files\Apache Group\Apache2\htdocs\ELBA\logme_in.php:2) in C:\Program Files\Apache Group\Apache2\htdocs\ELBA\logme_in.php on line 3
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:\Program Files\Apache Group\Apache2\htdocs\ELBA\logme_in.php:2) in C:\Program Files\Apache Group\Apache2\htdocs\ELBA\logme_in.php on line 3
Warning: Unknown(): open(/tmp\sess_2984f6d378560d0882f37728dbe1defc,
O_RDWR)
failed: No such file or directory (2) in Unknown on line 0
Warning: Unknown(): Failed to write session data (files). Please verify
that
the current setting of session.save_path is correct (/tmp) in Unknown on line 0
****************************************************************************
*******
the session.save_path parameter in my php.ini file is as follows ************************************** session.save_path = "C:/WINDOWS/Temp" **************************************
I'm kinda new at php and web development environment .. so any help will
be
appreciated.
Thanks in advance Dre,
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php