This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 9 years ago.
I'm getting this error again and again i try everything but i can't found solution
Warning: Cannot modify header information - headers already sent by (output started at /home/xxxx/xxxx/forum/index.php:90) in /home/pappu/public_html/forum/index.php on line 93
here is my index.php code
<?php
include_once("connect.php");
session_start();
?>
<html>
<head>
<title>MyForum</title>
<style type="text/css">
body {
background-color: #333;
margin-top: 150px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
.content {
background-color: #666;
width: 960px;
margin-right: auto;
margin-left: auto;
border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
padding: 20px;
}
.content .categories {
width: 700px;
background-color: #333;
border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
margin: 0px;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
color: #FFF;
}
.categories .community_heading {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-variant: normal;
text-transform: capitalize;
color: #CCC;
margin: 0px;
padding-top: 7px;
padding-right: 7px;
padding-bottom: 7px;
padding-left: 14px;
font-size: 18px;
font-weight: bold;
}
.content .categories hr {
background-color: #666;
height: 3px;
border: 0px;
width: 700px;
margin: 0px;
}
.content .categories .cat_links {
border-bottom-width: thin;
border-bottom-style: solid;
border-bottom-color: #000;
padding-top: 7px;
padding-right: 7px;
padding-bottom: 7px;
padding-left: 14px;
font-size: 14px;
color: #000;
}
.content .categories .cat_a {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 18px;
font-variant: normal;
text-transform: capitalize;
color: #777;
text-decoration: none;
}
.content .categories .cat_a:hover {
text-decoration: underline;
color: #DDD;
}
.content .categories .desc {
margin: 0px;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
color: #CCC;
}
</style>
</head>
<body>
<?php
if(!isset($_SESSION['password']))
{
include_once("Location:header.php");
}
else
{
header("Location:member.php");
}
?>
<div class="content">
<div class="categories">
<h3 class="community_heading">Community</h3>
<hr />
<?php
$query = "SELECT * FROM categories ORDER BY cat_id ASC";
$result = mysql_query($query) or die(mysql_error());
$categories = "";
if(mysql_num_rows($result) > 0 )
{
while($row = mysql_fetch_array($result))
{
$cat_id = $row['cat_id'];
$cat_title = $row['cat_title'];
$cat_desc = $row['cat_description'];
$categories .="
<div class='cat_links'>
<a href='view_category?cid=".$cat_id."' class='cat_a'>$cat_title</a>
<p class='desc'>$cat_desc</p>
</div>";
}
echo $categories ;
}
else
{
}
?>
</div>
</div>
</body>
</html>
You can't call Header() after including ANY code that is outputted to the page. You need to rewrite what you are doing so the Header() call is above all the HTML code.
Related
I'm using php to display an error message to the user. The code is sitting at the top of the page and once the error message displays, it affects the height of my textboxes. I coded the height in a style sheet. Also, my error message is sitting inside of a div. I tried using the span tag but that isn't working either since its still sitting at the top line of the page. This is the error message in php:
if($result != "")
{
echo "<div id='Error'>";
echo "<b>The following errors occured:</b><br>";
echo $result;
echo "</div>";
}
Registration div css:
#RegBody
{
background-color: white;
background-image: url(LilyPads.jpg);
height: 82.7vh;
}
#RegContents
{
position: absolute;
margin: 39px auto 0 402px;
border-radius: 20px;
background-color: white;
width: 500px;
height: 455px;
padding-left: 57px;
}
#RegisterUser
{
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: 15px;
margin-top: 14px;
margin-left: 112px;
color: #1A3D5B;
width: 215px;
height: 30px;
color: white;
background-color: #1A3D5B;
border-color: #1A3D5B;
border-style: solid;
border-radius: 20px;
}
Error message css:
#Error
{
position: absolute;
background-color: white;
border: 2px solid red;
border-radius: 20px;
width: 200px;
padding: 15px;
margin: 147px 0 0 70px;
color: red;
}
Here's the css for the textboxes:
input[type='text']
{
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
text-indent: 10px;
width: 210px;
height: 25px;
border-color: #1A3D5B;
border-style: solid;
border-radius: 20px;
}
Before the error message:
I was thinking that maybe its the font size that's the issue but regardless...a white line also appears at the bottom of the page:
Please have patience with me. I'm a student and new to php. Thank you
i can tell you how to rectify the error (though i am still looking for the reason because of which it happens).
what i did is that i inserted the php code inside body tag and it work fine no change in Textbox dimensions.Below is the code i wrote to prove the same
<?php
$result=1;
echo "<div id='Error'>";
echo "<b>The following errors occured:</b><span>";
echo $result;
echo "</span></div>";
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
input[type='text']
{
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
text-indent: 10px;
width: 210px;
height:25px;
border-color: #1A3D5B;
border-style: solid;
border-radius: 20px;
}
</style>
</head>
<body>
<input type='text' name=''>
</body>
</html>
These are some of the inline-styles.
body{
font-family: helvetica;
font-size: 12px;
font-weight: normal;
color: gold;
margin: 0;
padding:0;
background: black;
}
p{
font-family: helvetica;
font-size: 12px;
font-weight: normal;
color: white;
margin: 0;
padding-top: 5px;
line-height: 14px;
}
header{
width: 100%;
height: 300px;
background-color: red;
border-bottom: 2px solid gold;
}
/* I would like to add a height to this wrapper, but when I do, the while loop doesn't stack the products in a row of 3. It just lists the products straight down the page. */
#wrapper{
width:618px;
margin: 10px auto;
/*background: yellow;*/
}
#stack{
width:201px;
height:200px;
float: left;
margin-right:5px;
margin-bottom:0px;
padding:0;
text-align:center;
/* background:pink;*/
}
a{
cursor:pointer;
color: gold;
text-decoration: none;
}
h3{
width:618px;
height:30px;
font-family: helvetica;
font-size: 16px;
font-weight: bold;
color:21a4ff;
margin: 0 auto;
text-align:center;
padding-top:10px;
}
p.price{
font-weight: bold;
color: tomato;
font-size: 14px;
line-height:10px;
}
p.name{
font-family: helvetica;
font-size: 13px;
font-weight: bold;
color: gold;
margin:0;
padding:0;
line-height: 12px;
}
</style>
<?php
include("mysql.connect.php");
$stmt = $mysqli->prepare("SELECT sku, name, price, sm_image
FROM products ORDER BY price");
$stmt->execute();
$stmt->bind_result($sku, $name, $price, $sm_image);
This is where my problem is. How can I set this while loop to list results in rows of three using the $stmt-fetch()) method?
while($stmt->fetch()){
echo "<div id='wrapper'>
<div id='stack'>
<img src='$sm_image'></img><br>
<p>$sku</p>
<p class='name'>$name</p>
<p class='price'>$$price<br></p>
</div>";
echo "</div>";
}
// Recuperate the statement resources
$stmt->close();
// Close the connection
$mysqli->close();
?>
Please I do not really know what I am doing wrong here. I have a page for image upload. It's working perfectly on localhost but as soon as I uploaded it to remote server, It's not working as I want it. I have changed the folder permission, I have changed the directly still not working. It's not giving me any error. it's showing file uploaded successfully but anytime I check the folder, It's empty. Please help me out. This my code below.
if(isset($_POST['upload']))
{
$tmp_name = $_FILES['passport']['tmp_name'];
if (empty($tmp_name) == false){
$name = $_FILES['passport']['name'];
$type = $_FILES['passport']['type'];
$size = $_FILES['passport']['size'];
list($width, $height, $typeb, $attr) = getimagesize($tmp_name);
if($width<=160 || $height<=160)
{
if($type=='image/jpeg' || $type=='image/jpg' || $type=='image/png')
{
if($size<='20000')
{
if(!get_magic_quotes_gpc())
{
$name = addslashes($name);
$extract = fopen($tmp_name, 'r');
$content = fread($extract, $size);
$content = addslashes($content);
fclose($extract);
//Place image in the folder
$newname="$studentID.jpg";
move_uploaded_file($_FILES['passport']['tmp_name'],"../passports/$newname");
$msg = "<center><p style ='color: #4F8A10; background-color: #DFF2BF; border-radius:.5em; width: 350px; border: 1px solid #D8D8D8; padding: 5px; border-radius: 5px; font-family: Arial; font-size: 11px; text-transform: uppercase; text-align: center; text-transform: uppercase; padding-left: 12px'>Passport uploaded successfully.. Click the link below to continue</p></center>";
} else {
$uploaderror = "<p style='color: #D8000C; background-color: #FFBABA; border-radius:.5em; width: 300px; border: 1px solid #D8D8D8; padding: 5px; border-radius: 5px; margin-left: auto; margin-right: auto; font-family: Arial; font-size: 11px; text-transform: uppercase; text-align: center; text-transform: uppercase'>Error has occured... Please try again</p>";
}
} else {
$uploaderror = "<p style='color: #D8000C; background-color: #FFBABA; border-radius:.5em; width: 300px; border: 1px solid #D8D8D8; padding: 5px; border-radius: 5px; margin-left: auto; margin-right: auto; font-family: Arial; font-size: 11px; text-transform: uppercase; text-align: center; text-transform: uppercase'>$name is more than 20kb</p>";
}
} else {
$uploaderror = "<p style='color: #D8000C; background-color: #FFBABA; border-radius:.5em; width: 300px; border: 1px solid #D8D8D8; padding: 5px; border-radius: 5px; margin-left: auto; margin-right: auto; font-family: Arial; font-size: 11px; text-transform: uppercase; text-align: center; text-transform: uppercase'>$type is not in acceptable format</p>";
}
} else {
$uploaderror = "<p style='color: #D8000C; background-color: #FFBABA; border-radius:.5em; width: 300px; border: 1px solid #D8D8D8; padding: 5px; border-radius: 5px; margin-left: auto; margin-right: auto; font-family: Arial; font-size: 11px; text-transform: uppercase; text-align: center; text-transform: uppercase'>$name should be 160px * 160px</p>";
}
} else {
$uploaderror = "<p style='color: #D8000C; background-color: #FFBABA; border-radius:.5em; width: 300px; border: 1px solid #D8D8D8; padding: 5px; border-radius: 5px; margin-left: auto; margin-right: auto; font-family: Arial; font-size: 11px; text-transform: uppercase; text-align: center; text-transform: uppercase'>Please choose a file to upload</p>";
}
}
I'm doing a database project for university, but actually my question is related to html or css (I think).
Here's the thing: I have a navigation bar around the website but when I'm in some some pages I can't access others, for example when I'm in "change password" page and I put the mouse over "Log Out" it's impossible to click.
Thanks in advance, André
Here's the code:
<div id="linking">
<ul>
<li>
Home
</li>
<li>
Search for trips
</li>
<?php
if (isset($_SESSION['user_logged_in'])) {
if (($_SESSION['user_email']) === "admin#email.com") {
?>
<li>
Create tour
</li>
<li>
Create service
</li>
<?php
}
?>
<li>
<a href='profile.php'>Change settings</a>
</li>
<li>
<a href='change_password.php'>Change password</a>
</li>
<li>
<a href='logout.php'>Log out</a>
</li>
<label>Hello <?php print_r($_SESSION['user_name']) ?>!</label>
<?php
}
else {
?>
<li>
<a href='login.php'>Log In</a>
</li>
<li>
Register
</li>
<label>Hello visitor!</label>
<?php
}
?>
</ul>
</div>
And here's the css:
/* common properties */
body{
background-color: #d8d8d8;
}
hr{
color: firebrick;
background-color: firebrick;
border-color: transparent;
}
.registering {
position: absolute;
left: 30%;
top: 0%;
}
.loging {
position: absolute;
left: 33%;
top: 25%;
}
td{
vertical-align: middle;
}
/* .loging class properties */
body .loging{
position:absolute;
left:32%;
top:25%;
}
.loging td{
padding: 5px;
text-align: center;
font-size: 20px;
font-family: sans-serif;
color: firebrick;
}
.loging td input{
width: 500px;
height: 23px;
border-bottom-right-radius: 10px;
border-top-left-radius: 10px;
border-style: solid;
border-color: transparent;
text-align: center;
font-size: 16px;
}
.loging td input[type="submit"]{
width: 120px;
height: 30px;
background-color: firebrick;
color: #FFFFFF;
font-size: 18px;
font-weight: bold;
border-radius: 0px;
}
.loging td input[type="password"]{
font-size: 24px;
}
/*. registering class properties */
.registering td{
padding: 5px;
text-align: center;
font-size: 18px;
font-family: sans-serif;
color: firebrick;
}
.registering td input{
width: 500px;
height: 23px;
border-bottom-right-radius: 10px;
border-top-left-radius: 10px;
border-style: solid;
border-color: transparent;
text-align: center;
font-size: 16px;
}
.registering td input[type="submit"]{
width: 120px;
height: 30px;
background-color: firebrick;
color: #FFFFFF;
font-size: 18px;
font-weight: bold;
border-radius: 0px;
}
.registering td input[type="password"]{
font-size: 24px;
}
/* .linking properties */
#linking label{
color: firebrick;
font-weight: bold;
float:right;
position: fixed;
left: 90%;
font-family: sans-serif;
font-size: 16px;
}
li{
display: inline;
padding-right: 2px;
padding-left: 2px;
}
a{
color:firebrick;
font-weight: bold;
position: relative;
display: inline-block;
font-family: sans-serif;
font-size: 14px;
text-decoration: none;
}
/* section properties */
section{
padding:5px;
position: absolute;
width:30%;
}
section table{
padding: 8px;
}
section hr{
background-color: #FFFFFF;
}
section td, th{
width:32%;
text-align: center;
}
/* search for trips */
body .search{
position:absolute;
left:32%;
top:25%;
}
.search td{
padding: 5px;
text-align: center;
font-size: 20px;
font-family: sans-serif;
color: firebrick;
}
.search td input{
width: 500px;
height: 23px;
border-bottom-right-radius: 10px;
border-top-left-radius: 10px;
border-style: solid;
border-color: transparent;
text-align: center;
font-size: 16px;
}
.search td input[type="submit"]{
width: 120px;
height: 30px;
background-color: firebrick;
color: #FFFFFF;
font-size: 18px;
font-weight: bold;
border-radius: 0px;
}
Logout.php code:
<?php
session_start();
unset($_SESSION['user_logged_in']);
session_destroy();
header("Location:index.php");
echo "<script>alert('You have been logged out! Please come back anytime!')</script>";
?>
i think you have not added the link(logout.php) to every page..
Hello I am making a chat application, so whenever i click on a online user a chatbox should open, similarly whenever multiple chatbox should open when i click a different users. I am appending div for a each time a user click on a online user. I am facing some issues with css.
Is this because i am using same css for each new chatbox. Here is my code for adding a chatbox dynamically.
$(".shout_msg").click(function(){
var id = $(this).attr('id');
var name = $(this).text();
alert("name is "+ name + "id is " +id);
$('body').append("<div class = 'shout_box'></div>");
$(".shout_box").append("<div class = 'header'>'"+name+"'</div>");
$(".header").append("<div class='close_btn'> </div>")
$(".shout_box").append("<div class = 'toggle_chat'></div>");
$(".toggle_chat").append("<div class = 'message_box'></div>");
$(".toggle_chat").append("<div class = 'user_info'></div>");
$(".user_info").append('<input name = "shout_message" id = "shout_message" type = "text" placeholder = "Type Message Hit Enter" />');
})
shout_msg is a paragraph which show a single online user.
This is my css
<style type="text/css">
.shout_box {
background:#627BAE; width:260px; overflow:hidden;
position:fixed; bottom:0; right:20%; z-index:9;
}
.shout_box .header .close_btn {
background: url(close_icon.png) no-repeat 0px 0px;
float:right; width:15px;
height: 15px;
}
.shout_box .header .close_btn:hover {
background: url(images/close_btn.png) no-repeat 0px -16px;
}
.shout_box .header .open_btn {
background: url(images/close_btn.png) no-repeat 0px -32px;
float:right; width:15px;
height:15px;
}
.shout_box .header .open_btn:hover {
background: url(images/close_btn.png) no-repeat 0px -48px;
}
.shout_box .header{
padding: 5px 3px 5px 5px;
font: 11px 'lucida grande', tahoma, verdana, arial, sans-serif;
font-weight: bold; color:#fff;
border: 1px solid rgba(0, 39, 121, .76);
border-bottom:none; cursor:pointer;
}
.shout_box .header:hover{
background-color: #627BAE;
}
.shout_box .message_box {
background: #FFFFFF; height: 200px;
overflow:auto; border: 1px solid #CCC;
}
.shout_msg{
margin-bottom: 10px; display: block;
border-bottom: 1px solid #F3F3F3; padding: 0px 5px 5px 5px;
font: 11px 'lucida grande', tahoma, verdana, arial, sans-serif; color:#7C7C7C;
}
.message_box:last-child {
border-bottom:none;
}
.time{
font: 11px 'lucida grande', tahoma, verdana, arial, sans-serif;
font-weight: normal; float:right; color: #D5D5D5;
}
.shout_msg .username{
margin-bottom: 10px;margin-top: 10px;
}
.user_info input {
width: 98%; height: 25px; border: 1px solid #CCC; border-top: none; padding: 3px 0px 0px 3px;
font: 11px 'lucida grande', tahoma, verdana, arial, sans-serif;
}
.shout_msg .username{
font-weight: bold; display: block;
}
.userdisplay{
width: auto;
height: 30px;
border-radius: 10px;
background-color: #627BAE;
}
.userdisplay p{
width: auto;
//background-color: yellow;
padding : 10px;
}
.userdisplay a{
float : right;
}
</style>