 |
Forum PHP Romania - Discutii despre PHP, MySQL, Javascript, AJAX, etc Comunitatea PHP Romania
|
| Subiectul anterior :: Subiectul următor |
| Autor |
Mesaj |
alexandru
Data înscrierii: 26/Sep/2003
Mesaje: 4
|
| Trimis: Vin Sep 26, 2003 10:17 am Titlul subiectului: Eroare: Cannot send session cookie - headers already sent by |
|
|
Am acest script si am urmatoarea eroare pe php 4.3.3
<?php
session_start();
$user_name = $_POST['user_name'];
$password = $_POST['password'];
$db_user = 'xxx';
$db_pass = 'xxx';
//connect to the DB and select the "dictator" database
$connection = mysql_connect('localhost', $db_user, $db_pass) or die(mysql_error());
mysql_select_db('xxx', $connection) or die(mysql_error());
//set up the query
$query = "SELECT * FROM admin WHERE user='$user_name' AND pass='$password'";
$result = mysql_query($query, $connection) or die('error making query');
$affected_rows = mysql_num_rows($result);
//run the query and get the number of affected rows
$result = mysql_query($query, $connection) or die('error making query');
$affected_rows = mysql_num_rows($result);
//if there's exactly one result, the user is validated. Otherwise, he's invalid
if($affected_rows == 1) {
$row = mysql_fetch_row($result);
$_SESSION['username'] = $user_name;
$to = "saptamana.php";
header('Location: '. $to);
exit;
}
else {
print 'User sau parola GRESIT. Va rugam mai incercati <br>';
echo "<form name=login method=post action=validate.php>
<div align=center>username:
<input type=text name=user_name>
<br>
password:
<input type=password name=password>
<br>
<input type=submit value=submit>
</div>
</form>";
}
?>
EROARE:
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/mancare/public_html/validate.php:12) in /home/mancare/public_html/validate.php on line 22
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/mancare/public_html/validate.php:12) in /home/mancare/public_html/validate.php on line 22
Warning: Cannot modify header information - headers already sent by (output started at /home/mancare/public_html/validate.php:12) in /home/mancare/public_html/validate.php on line 44
CE ar trebuie sa fac??? Poate sa ma ajute cineva? |
|
| Sus |
|
danovidiu
Data înscrierii: 26/Mai/2002
Mesaje: 35
Locație: Tg-Mures, Romania
|
| Trimis: Sâm Sep 27, 2003 5:27 pm Titlul subiectului: |
|
|
| Problema ta e foarte simpla. Nu ma uit peste cod din lipsa de timp, dar stiu sigur ce e gresit. Undeva inainte de session_start(), este trimis ceva text catre browser, care poate fi si un singur caracter. Daca te uiti la eroare, iti spune si linia unde trimiti text catre browser [ 22 ] |
|
| Sus |
|
computershop
Data înscrierii: 01/Sep/2003
Mesaje: 19
|
| Trimis: Vin Feb 27, 2004 9:46 pm Titlul subiectului: Re: Eroare: Cannot send session cookie - headers already sen |
|
|
| ai rezolvat problema intre timp ? daca nu, ce versiune de php folosesti ?? |
|
| Sus |
|
computershop
Data înscrierii: 01/Sep/2003
Mesaje: 19
|
| Trimis: Vin Feb 27, 2004 9:49 pm Titlul subiectului: Re: Eroare: Cannot send session cookie - headers already sen |
|
|
| ma scuzi am vazut pe urma ca 4.3.3. de aici e problema din fisierul de configurare a php-ului <<php.ini>> . Nu mai stiu foarte bine dar uita-te ca exista in sectiunea [session] ai o chesatie de genul auto.start.sesion = 0, pune-o pe 1 si o sa mearga. |
|
| Sus |
|
gibi
Data înscrierii: 27/Iul/2007
Mesaje: 38
|
| Trimis: Vin Aug 03, 2007 1:53 pm Titlul subiectului: |
|
|
m-am dat si eu cu capul de pereti:
Cod:
echo '<pre>';
session_start();
$_SESSION['error_message'][] = 'No Upload!';
print_r($_SESSION);
si nu intelegeam de ce !!!
Merci pentru raspuns si lui google :) |
|
| Sus |
|
ebogdan
Data înscrierii: 27/Iul/2006
Mesaje: 151
|
| Trimis: Lun Aug 06, 2007 8:37 am Titlul subiectului: |
|
|
| Un mic sfat: Incercati eventual sa folositi ob_start() si ob_end_flush() / ob_flush() ca sa scapati permanent de probleme de genul acesta. |
|
| Sus |
|
PHPRomania Bot
Bot Member
Data înscrierii: 27/Dec/2007
Mesaje: 1
Locaţie: Server Google |
| Trimis: Mie Dec 26, 2007 7:01 pm Titlul subiectului: Ad |
|
|
|
|
|
| Sus |
|
| |
|