divinedesigns1 Posted April 25, 2012 Share Posted April 25, 2012 (edited) hey sup guys, yup its me once again, i am having a little problem with the header() function <--- it really hates me hehehe anyway im getting this error on the browser Warning: Cannot modify header information - headers already sent by (output started at /home/content/14/8709614/html/demo/admin.php:9) in ..../html/demo/admin.php on line 16 Warning: Cannot modify header information - headers already sent by (output started at /home/content/14/8709614/html/demo/admin.php:9) in ..../html/demo/admin.php on line 17 ScoreKeeper Sorry, Your Password & Username is all wrong Access This Page not too sure how to fix this kind of error, i solve the rest but when it comes to headers i have no idea where to start, i went to line 16 and 17 and i dont see anything wrong with the code <?php//user name and password for authentication$username = 'babybaby';$password = 'heartheart';if(!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) || ($_SERVER['PHP_AUTH_USER'] != $username) || ($_SERVER['PHP_AUTH_PW'] != $password)){//The user name/password are incorrect so send the authentication headersheader('HTTP/1.1.401 Unauthorized');header('WWW-Authenticate:Basic realm="scorekeeper"');exit('<h2>ScoreKeeper</h2> Sorry, Your Password & Username is all wrong ' . ' Access This Page');}?><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">....</html><?php require_once('skimg.php'); require_once('my_connect.php'); // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Retrieve the score data from MySQL $query = "SELECT * FROM scorekeeper ORDER BY score DESC, date ASC"; $data = mysqli_query($dbc, $query); // Loop through the array of score data, formatting it as HTML echo '<table>'; while ($row = mysqli_fetch_array($data)) { // Display the score data echo '<tr class="scorerow"><td><strong>' . $row['name'] . '</strong></td>'; echo '<td>' . $row['date'] . '</td>'; echo '<td>' . $row['score'] . '</td>'; echo '<td><a href="remove.php?id=' . $row['id'] . '&date=' . $row['date'] . '&name=' . $row['name'] . '&score=' . $row['score'] . '&screenshot=' . $row['screenshot'] . '">Remove</a></td></tr>'; } echo '</table>'; mysqli_close($dbc);?> or does it need to be in the same <?php?> tags and not in a different <?php?> tagkindly let me know so i can write how to solve this problem or give me a hint on where the error is...........yes give me a hint where the error is i know its on line 16 and 17 Edited April 25, 2012 by DDs1 Link to comment Share on other sites More sharing options...
Ingolme Posted April 25, 2012 Share Posted April 25, 2012 Make sure you don't have any whitespace (line breaks or spaces) before your opening <?php tag Link to comment Share on other sites More sharing options...
divinedesigns1 Posted April 25, 2012 Author Share Posted April 25, 2012 i got it fix, but im having problem logging in with the username and password i set 0.o how do i fix that? Link to comment Share on other sites More sharing options...
Ingolme Posted April 25, 2012 Share Posted April 25, 2012 I guess it has something to do with the $_SERVER['PHP_AUTH_USER'] variables. Do you know where they're being set and what values they have? Try printing them out. Link to comment Share on other sites More sharing options...
divinedesigns1 Posted April 25, 2012 Author Share Posted April 25, 2012 yeah i think thats the problem im not too sure where its set but i know the value of it, also how do i print it out? Link to comment Share on other sites More sharing options...
Ingolme Posted April 25, 2012 Share Posted April 25, 2012 echo $_SERVER['PHP_AUTH_USER']; Link to comment Share on other sites More sharing options...
divinedesigns1 Posted April 25, 2012 Author Share Posted April 25, 2012 ok thanks foxy Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now