2013-09-07 11 views
5

ho ricevuto un errore sul mio codice php qualcosa di simile:Warning: session_start() [function.session-start]: Impossibile inviare sessione di limitatore di cache - headers already sent

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home4/iamden83/public_html/loop/signup.php:1) in /home4/iamden83/public_html/loop/signup.php on line 2 

E il codice è questo

<?php 
session_start(); 
// If user is logged in, header them away 
if(isset($_SESSION["username"])){ 
    header("location: message.php?msg=NO to that weenis"); 
    exit(); 
} 
?><?php 
// Ajax calls this NAME CHECK code to execute 
if(isset($_POST["usernamecheck"])){ 
    include_once("php_includes/db_conx.php"); 
    $username = preg_replace('#[^a-z0-9]#i', '', $_POST['usernamecheck']); 
    $sql = "SELECT id FROM users WHERE username='$username' LIMIT 1"; 
    $query = mysqli_query($db_conx, $sql); 
    $uname_check = mysqli_num_rows($query); 
    if (strlen($username) < 3 || strlen($username) > 16) { 
     echo '<strong style="color:#F00;">3 - 16 characters please</strong>'; 
     exit(); 
    } 
    if (is_numeric($username[0])) { 
     echo '<strong style="color:#F00;">Usernames must begin with a letter</strong>'; 
     exit(); 
    } 
    if ($uname_check < 1) { 
     echo '<strong style="color:#009900;">' . $username . ' is OK</strong>'; 
     exit(); 
    } else { 
     echo '<strong style="color:#F00;">' . $username . ' is taken</strong>'; 
     exit(); 
    } 
} 

risposta

12

hmmm, penso che ci deve essere qualche ASCII o white-space nascondiglio carattere prima <?php, basta aprire il blocco note, copiare il contenuto di session_start(); alla fine e incolla, ora aggiungere manualmente <?php, e assicurarsi che non vi siano spazi vuoti prima <?php alla linea n 1

+0

Risposta perfetta :) Helped ME –

+0

Grazie per questo !! – Amrit

5

uso ob_start(); nella parte superiore della pagina, la sua per buffer di uscita e può essere risolvere questo problema.

+0

mi hai salvato amico! molte grazie – wiLLiamcastrO

Problemi correlati