I've read a lot on other forums, they said that the error was that there was White-space before the session_start but I'm extremely sure there isn't, my file is encoded in UTF8 without BOM so that white-space problem should be fine and it's working perfectly on local (I'm using easyphp). Still, as soon as I put it online, it pops me those problem.anyone can help? They're telling those two lines of error online :
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent
This is my code:
<?php
session_start();
?>
The warning means that the HTTP headers were already sent and they cannot be modified anymore. You have to make sure you do not send any content before session_start
. Put it on top of your very first PHP script, before any echo
or HTML and you will be fine.
There is certainly an error in your code - you have an else condition attached to a while loop and perhaps you posted it in error but why are there two session_start() calls? Assuming that this is one page!
<?php
session_start();
$uname=$_SESSION['name'];
?>
<?php
/*session_start();*/
$servername = "68.178.143.40";
$username = "applicant123";
$password = "Applicant@123";
$dbname = "applicant123";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); }
$uname=$_SESSION['name'];
$sql = "SELECT * FROM consultant WHERE username='uname' ";
$result = $conn->query( $sql );
if ( $result->num_rows > 0 ) {
/* Here is a problem - there should be no "else" */
/*
while( $row = $result->fetch_assoc() ) {
} else {
echo "0 results";
}
*/
while( $row = $result->fetch_assoc() ) {
/* do stuff with recordset */
}
$conn->close();
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.