PHP - Php Warning: Session_start(): Cannot Start Session When Headers Already Sent In And Warning: Cannot Modify Header Information
Hi Everyone I am having a few issues with my website. I have developed in on my xampp local host and it works ok but when I upload the files and try to renew a membership using stripe I get the following messages. Warning: session_start(): Cannot start session when headers already sent in /customers/a/d/f/mywebsite.co.uk/httpd.www/mywebsite/inc/settings.php on line 2 Warning: Cannot modify header information - headers already sent by (output started at /customers/a/d/f/mywebsite.co.uk/httpd.www/mywebsite/procedures/payments/charge.php:1) in /customers/a/d/f/mywebsite.co.uk/httpd.www/mywebsite/procedures/payments/charge.php on line 141 I have some includes that appear on every page. This is the bootstrap.php file. This file holds the settings.php which connects to my database and other function files. In this settings page I call the session_start() php function and then connect to my database. I call the bootstrap.php file on every page to there for call the session_start() on every page. I am using sessions alot so is this the right thing to do? I have attached the renew_membership payment page which holds the form. The user fills out the payment page and the form data gets sent to a script called charge.php which uses the stripe objects to make the payment. I then want to do a redirect to the paymentSuccess.php page to output to the user that the payment was made successfully. This is where the issues arrise. I have split the charge file into 3 screen shots so it is more readable. Hope someone can help me. Thanks a lot David
Edited April 26 by Irish_Dave Similar TutorialsHello, Im having a little trouble with this coding I need it to goto this page after an if statement but get this dreaded error Warning: Cannot modify header information - headers already sent by (output started at /home/fightwa1/public_html/fightlivecommentaryrd1.php:15) in /home/fightwa1/public_html/fightlivecommentaryrd1.php on line 57 there are no whitespaces before or after the start and endin <?php, as previously read about. Really struggling with this problem, if anyone can help will be much appreciated. I am getting this error: Warning: Cannot modify header information - headers already sent by on my pvp.php script, this is it: <?PHP include('top.php'); if(!isset($_SESSION['UsersID'])) { echo "You need to be logged into view this page."; include('bottom.php'); exit; } if(isset($_POST['battleplayer'])) { $battleplayer=$_POST['battleplayer']; if($_POST['battlepick']=="username") { $Battling_Result=mysql_query("SELECT * FROM users WHERE Username='$battleplayer'"); $Battling_Rows=mysql_fetch_array($Battling_Result); $battleplayer=$Battling_Rows['ID']; } elseif($_POST['battlepick']=="id") { $Battling_Result=mysql_query("SELECT * FROM users WHERE ID='$battleplayer'"); $Battling_Rows=mysql_fetch_array($Battling_Result); } if(!empty($Battling_Rows)) { $Enemy_ID=$Battling_Rows['ID']; $Enemy_Name=$Battling_Rows['Username']; $Enemy_Level=$Battling_Rows['Level']; $Enemy_HP=$Battling_Rows['HP']; $Enemy_MHP=$Battling_Rows['Max_HP']; $Enemy_Energy=$Battling_Rows['Energy']; $Enemy_MEnergy=$Battling_Rows['Max_Energy']; $Battling_Result2=mysql_query("SELECT * FROM items WHERE Owner='$battleplayer' AND Slot='1'"); $Battling_Rows2=mysql_fetch_array($Battling_Result2); $Battling_Result3=mysql_query("SELECT * FROM items WHERE Owner='$battleplayer' AND Slot='2'"); $Battling_Rows3=mysql_fetch_array($Battling_Result3); $Battling_Result4=mysql_query("SELECT * FROM items WHERE Owner='$battleplayer' AND Slot='3'"); $Battling_Rows4=mysql_fetch_array($Battling_Result4); $Battling_Result5=mysql_query("SELECT * FROM items WHERE Owner='$battleplayer' AND Slot='4'"); $Battling_Rows5=mysql_fetch_array($Battling_Result5); $Battling_Result6=mysql_query("SELECT * FROM items WHERE Owner='$battleplayer' AND Slot='5'"); $Battling_Rows6=mysql_fetch_array($Battling_Result6); $Enemy_Attack1=$Battling_Rows2['Name']; $Enemy_Attack2=$Battling_Rows3['Name']; $Enemy_Attack3=$Battling_Rows4['Name']; $Enemy_Attack4=$Battling_Rows5['Name']; $Enemy_Attack5=$Battling_Rows6['Name']; $Enemy_Power=$Battling_Rows['Power']; $Enemy_Defense=$Battling_Rows['Defense']; $Enemy_Magic=$Battling_Rows['Magic']; $Enemy_Race=$Battling_Rows['Race']; $Enemy_Class=$Battling_Rows['Class']; $Battle_Start="No"; $User_ID=$_SESSION['UsersID']; mysql_query("DELETE from battle_info WHERE User_ID='$User_ID'"); mysql_query("INSERT into battle_info(Enemy_ID, Enemy_Name, Enemy_Level, Enemy_HP, Enemy_MHP, Enemy_Energy, Enemy_MEnergy, Enemy_Attack1, Enemy_Attack2, Enemy_Attack3, Enemy_Attack4, Enemy_Attack5, Enemy_Power, Enemy_Defense, Enemy_Magic, Enemy_Race, Enemy_Class, Battle_Start, User_ID) VALUES('$Enemy_ID', '$Enemy_Name', '$Enemy_Level', '$Enemy_HP', '$Enemy_MHP', '$Enemy_Energy', '$Enemy_MEnergy', '$Enemy_Attack1', '$Enemy_Attack2', '$Enemy_Attack3', '$Enemy_Attack4', '$Enemy_Attack5', '$Enemy_Power', '$Enemy_Defense', '$Enemy_Magic', '$Enemy_Race', '$Enemy_Class', '$Battle_Start', '$User_ID')") or die(mysql_error()); header('Location: battle.php'); } else { echo "This user does not exist.<br />"; echo "Enter the Username/ID of the person you want to battle below:"; echo "<br /><form method='POST'><input type='text' name='battleplayer'><select name='battlepick'><option value='username'>Username</option><option value='id'>ID</option></select>"; echo "<br /><input type='submit' name='Submit' id='Submit' value='Submit' onclick='this.disabled=true; this.form.submit;'>"; echo "</form>"; } } else { echo "Enter the Username/ID of the person you want to battle below:"; echo "<br /><form method='POST'><input type='text' name='battleplayer'><select name='battlepick'><option value='username'>Username</option><option value='id'>ID</option></select>"; echo "<br /><input type='submit' name='Submit' id='Submit' value='Submit' onclick='this.disabled=true; this.form.submit;'>"; echo "</form>"; } include('bottom.php'); ?> and this is my top.php script: <?PHP include('connect.php'); $ID = $_SESSION['UsersID']; $ID = mysql_real_escape_string($ID); if (!isset($_SESSION['UsersID'])) { echo " <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"> <font face='verdana'> <head> <link rel='stylesheet' type='text/css' href='style.css'> </style> </head> <title>Shadow of the Eternal - Text Based RPG</title> <body> <div id='banner'><a href='index.php'><img src='banner.png'></a></div> <div id='quicklinks'>Test</div> <div id='leftmenu'> <ul> <li>Main <ul> <li><a href='index.php'>Home</a></li> <li><a href='login.php'>Login</a></li> <li><a href='signup.php'>Sign Up</a></li> </ul> </li> </ul></div> <div id='content'> </font>"; } else { echo " <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"> <font face='verdana'> <head> <link rel='stylesheet' type='text/css' href='style.css'> </style> </head> <title>Shadow of the Eternal - Text Based RPG</title> <body> <div id='banner'><a href='index.php'><img src='banner.png'></a></div> <div id='quicklinks'>Test</div> <div id='leftmenu'> <ul> <li>CryptoWare <ul> <li><a href='http://furiousflash.com'>Furious Flash</a></li> <li><a href='http://crypto-ware.com'>CryptoWare</a></li> </ul> </li> <li>Main <ul> <li><a href='index.php'>Home</a></li> <li><a href='viewcomments.php'>News Comments</a></li> <li><a href='logout.php'>Logout</a></li> <li><a href='http://furiousflash.com/forum'>Forums</a></li> </ul> </li> </ul></div> <div id='content'> </font>"; } ?> And just in case this is my connect.php script: <?PHP mysql_connect('localhost','*****','*****'); mysql_select_db('*****'); session_start(); ?> Any idea why? So last night I was changing the amount of posts I wanted on my Thesis Themed Wordpress blog. I went to click the Save button within wordpress and got this message on the next page. "Warning: Cannot modify header information - headers already sent by (output started at /home/content/50/8403650/html/wp-content/themes/thesis_18/custom/custom_functions.php:2) in /home/content/50/8403650/html/wp-includes/pluggable.php on line 934" Now my nav menu doesn't show up and when I go to archives, it gives me the same warning. Can someone please help me with this? Any help would be appreciated. I've added both custom_functions.php and pluggable.php as an attachment, I don't think it has anything to do with pluggable but added just in case. Thanks for your help. Briannyc [attachment deleted by admin] <?php header('Refresh: 5; URL=http://www.miraculousmedalapostolate.com'); exit(); ?> i dont know what to do with this! i have tried using other hosting and the code was working fine... please help me, i have been stuck on this problem for 2 days now. I am having a problem with my login page when I set cookies I get this error. Quote Warning: Cannot modify header information - headers already sent by (output started at /login.php:10) in /loginform.php on line 66 Warning: Cannot modify header information - headers already sent by (output started at /login.php:10) in /loginform.php on line 67 Warning: Cannot modify header information - headers already sent by (output started at /login.php:10) in /loginform.php on line 68 Warning: Cannot modify header information - headers already sent by (output started at /login.php:10) in loginform.php on line 72 I do have ob_start() at the beginning and ob_flush() and the end but i still get the error <?phpinclude('config.php');ob_start();@session_start();if (!isset($_POST['login'])) {?><form method="post" action="<?php $_SERVER['PHP_SELF'] ?>"> <fieldset> <legend>Login</legend> <table> <tr> <td>Email </td> <td><input type="text" name="email" /></td> </tr> <tr> <td>Password </td> <td><input type="password" name="password" /></td> </tr> <tr> <td><input type="submit" name="login" value="Login" /></td> </tr> <tr> <td><a href="<?=$siteurl?>/register.php">Register</a></td> </tr> </table> </fieldset></form><?php}else{ //Declare some variables $email = secure($_POST['email']); $password = secure($_POST['password']); //Check if the form is filled out if (!$email || !$password) { echo 'Please fill out the form completely'; echo '<a href="'. $siteurl .'/login.php">Go Back</a>'; } else { $user = mysql_query("SELECT * FROM `users` WHERE email = '$email'"); if (! mysql_num_rows($user)) { echo 'That user doe not exist'; } else { //Encrypt the password $encpass = sha1($password . $salt); //Find the user $superquery = mysql_query("SELECT * FROM `users` WHERE email = '$email' AND password = '$encpass'"); if (mysql_num_rows($superquery) == 1) { //If the user is found, set the cookies setcookie("username", $email, 0); setcookie("password", $encpass, 0); setcookie("is_logged_in", true, 0); //send the user to the home page header("Location: " . $siteurl . "members.php"); } else { echo 'Password was incorrect. Please try again.'; } } }}ob_flush();?>() what am i doing wrong? I am having trouble resolving an error. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/s519970/public_html/header.php:27) in /home/s519970/public_html/admin/login.php on line 2 What I can gather is I can't use "header (Location: 'admin.php')" after i've used session_start(). I have tried to replace the header (Location: 'admin.php') with this: echo "<script>document.location.href='admin.php'</script>"; echo "<script>'Content-type: application/octet-stream'</script>"; I've been trying to read up on solutions but haven't been able to get it sorted. If anyone can offer some advice that would be greatly appreciated as im new to php. Code: [Select] <?php session_start(); if(isset($_SESSION['user'])) echo "<script>document.location.href='admin.php'</script>"; echo "<script>'Content-type: application/octet-stream'</script>"; ?> <div id="loginform"> <form action="dologin.php" method="post"> <table> <tr> <td><span>Username:</span></td> <td><input type="text" name="username" /></td> </tr> <tr> <td><span>Password:</span></td> <td><input type="password" name="password" /></td> </tr> <tr> <td colspan="2" align="right"><input type="submit" name="login" value="Login" /></td> </tr> </table> </form> </div> I have tried using require_once('yourpage.php'); before my <head></head> tags in the header document where I've specified the html information but this doesn't seem to work. I've been advised to use ob_start("ob_gzhandler"); but I am not sure how to implement this. Any advice is greatly appreciated! in this page http://maximaart.com/newscp/ i have this problem Code: [Select] Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/maximasy/public_html/newscp/index.php:1) in /home/maximasy/public_html/newscp/index.php on line 2 my source code is <?php session_start(); include_once("config.php"); include_once("functions.php"); $errorMessage = ''; if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) { if ($_POST['txtUserId'] === "$user" && $_POST['txtPassword'] === "$pass") { // the user id and password match, $_SESSION['basic_is_logged_in'] = true; require("main.php"); exit;?> I get an error stating that I cannot modify header information when I try to add a title to my login page. Here's <?php session_start(); require_once("includes/dbconn.php"); include("includes/htmlheader.php"); mysql_select_db(center); $user = $_POST['username']; $pass = $_POST['password']; $sql = "select username, password from users"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $isuser = $row['username']; $ispass = $row['password']; if(isset($_POST['submit'])){ if(($user==$isuser)&&($pass==$ispass)) { $_SESSION['username'] = $user; header("Location: home.php"); }else{ echo "Invalid Username or Password"; } } ?> The htmlheader.php has the title string. Help is appreciated Hello,
I have an error on multiple pages which looks much like this. If anyone can help that would be gratefully appreciated. I would also like to ask if you may give me an explanation as to why it is occurring and not just a solution. Also when I take the second header out the error disappears.
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\blog\blog_display_post.php:47) in C:\xampp\htdocs\blog\comments.php on line 49
Here is my code:
if(strlen($email) > 5){
mysqli_query($con, "INSERT INTO emails (email) VALUES ('$email')"); I understand the warning, but I don't get the issue on my local server, only on my live server. From what I can see in the outputted source is a space and also i'm assuming a newline, before the warning... I've traced every route in my code, no output what-so-ever. I can't believe the hosts would insert such characters. I've tried separate files within the root directory, an html and a php, neither output these characters. Eventually I commented out the inclusion of modules one by one and found that the error should be in a specific one of these... Now going through I can't find any 'echo' or 'print' statements. Everything is within functions, and this error happens before anything is called, just included. There are no erroneous spaces before or after php code tags. What else would / could produce output? (and why no issue on local server?) EDIT: There is no use of 'output buffering' either... I am trying to create an index page which contains registration and login field the problem that i get is on successful login a warning is displayed session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\Eventz.com\index.php:116) in C:\xampp\htdocs\Eventz.com\index.php on line 235 This is the login part of my index.php this tag is inside an html table below the login form I also have a registration form and its php code above the login form Code: [Select] <?php if (isset($_REQUEST['pass'])) { $id=$_POST['id']; $pass=$_POST['pass']; $conn =mysql_connect("localhost","root",""); if (!$conn) { die('Could not connect: ' . mysql_error()); } /* checking connection....success! */ $e=mysql_select_db('test', $conn); if(!$e) { die(''.mysql_error()); } else { echo 'database selected successfully'; } if (isset($_REQUEST['id']) || (isset($_REQUEST['pass']))) { if($_REQUEST['id'] == "" || $_REQUEST['pass']=="") { echo "login fields cannot be empty"; } else { $sql=mysql_query("Select email,password from login where email='$id' AND password='$pass'"); $count=mysql_num_rows($sql); if($count==1) /* $count checks if username and password are in same row */ { session_start(); $_SESSION['id']=$id; echo "</br>Login Successful</br>"; } else { echo "</br>invalid</br>"; echo "please try to login again</br>"; } } } } ?> Any help or suggestion would be appreciated So I have a login box in my header, which worked when i hosted it locally, but now everytime i try to login i get Cannot modify header information - headers already sent (output started at /home/content/06/7711706/html/index.php:15) in /home/content/06/7711706/html/includes/header.php on line 102 and 103 Which is the setcookie bit, not sure what i'm doing wrong though. Any idea what i'm doing wrong? Thanks Code: [Select] <?php include('variables/variables.php'); ?> <div id="header"> <?php include('includes/flash.php'); ?> <?php mysql_connect("XXXXXXXXX", "XXXXXXX", "XXXXXX") or die(mysql_error()); mysql_select_db("XXXXXXX") or die(mysql_error()); if(isset($_COOKIE['test'])) { $username = $_COOKIE['test']; $pass = $_COOKIE['pass']; $check = mysql_query("SELECT * FROM customers WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } else { header("Location: members.php"); } } } if (isset($_POST['submit'])) { if(!$_POST['username'] | !$_POST['pass']) { die('You did not fill in a required field.'); } $check = mysql_query("SELECT * FROM customers WHERE username = '".$_POST['username']."'")or die(mysql_error()); $check2 = mysql_num_rows($check); if ($check2 == 0) { die('That user does not exist in our database. <a href=reg.php>Click Here to Register</a>'); } while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); if ($_POST['pass'] != $info['password']) { die('Incorrect password, please try again.'); } else { $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(test, $_POST['username'], $hour); setcookie(pass, $_POST['pass'], $hour); header("Location: members.php"); } } } else { ?> <form action="<?php echo $_SERVER['includes/PHP_SELF']?>" method="post"> <table bgcolor="#6699FF" height="50" border="0" style="border:hidden" align="right"> <tr><td colspan=2 align="center"><h2>Login</h2></td></tr> <tr><td>Username:</td><td> <input type="text" name="username" maxlength="40"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="pass" maxlength="50"> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Login"> </td></tr> </table> </form> <?php } ?></div> Why do i get this error when i put code for redirection on my php code :S Warning: Cannot modify header information - headers already sent by (output started at /home/dotars/public_html/shop/includes/functions.php:3) in /home/dotars/public_html/shop/includes/functions.php on line 20 This is that code on functions.php on line 20: function confirm_logged_in() { if (!logged_in()) { redirect_to("login.php"); } } function redirect_to($location = NULL) { if ($location != NULL) { header("Location: {$location}"); exit; } } And this is the code in the other php code: <?php require_once("includes/session.php"); ?> <?php require_once("includes/connection.php"); ?> <?php require_once("includes/functions.php"); ?> <?php confirm_logged_in(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <center> Text... </center> </body> </html> And confirm_logged_in() function is: I am getting this error when I use this Code: [Select] header("Location: /"); to redirect to home page.I believe there is a javascript alert which come before this is called, that gives the below error, I cannot remove the alert so is there nay other way I can go about redirecting without giving me the below error ? Code: [Select] A PHP Error was encountered Severity: Warning Message: Cannot modify header information - headers already sent by (output started at /home/dsdsd/application/core/MY_Controller.php:dsdsds) Quote Warning: Cannot modify header information - headers already sent by (output started at /home3/nyhungry/public_html/storeprueba/storescripts/connect_to_mysql.php:2) in /home3/nyhungry/public_html/storeprueba/storeadmin/admin_login.php on line 29 What can I do to fix the error where a second header is called, needed but intervening admin_login.php Code: [Select] <?php session_start(); if (isset($_SESSION["manager"])) { header("location:index.php"); exit(); } ?> <?php if (isset($_POST["username"]) && isset($_POST["password"])) { $manager = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["username"]); // filter everything but numbers and letters $password = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["password"]); // filter everything but numbers and letters include "../storescripts/connect_to_mysql.php"; $sql = mysql_query( "SELECT id FROM admin WHERE username='$manager' AND password='$password' LIMIT 1"); $existCount = mysql_num_rows($sql); if ($existCount == 1) { while($row = mysql_fetch_array($sql)) { $id = $row["id"]; } $_SESSION["id"] = $id; $_SESSION["manager"] = $manager; $_SESSION["password"] = $password; header("location:index.php"); exit(); } else { echo 'That information is incorrect, try again <a href="index.php">Click Here</a>'; exit(); } } ?> is the second header here like below in the code clashing? because in the connect_to_mysql.php there is no headers Code: [Select] <?php $_SESSION["id"] = $id; $_SESSION["manager"] = $manager; $_SESSION["password"] = $password; header("location:index.php"); exit(); <? Hey guys I am getting a Headers error that I havent been able to get rid of for the past 3 hours. I would really appreciate some help. <?php mysql_connect("localhost", "", "")or die("cannot connect"); mysql_select_db("test")or die("cannot select DB"); $tbl_name="test_mysql"; $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <form name="form1" method="post" action=""> <tr> <td> <table width="100%" border="0" cellspacing="1" cellpadding="0"> <tr> <td align="center"><strong>Row</strong></td> <td align="center"><strong>Month - Date</strong></td> <td align="center"><strong>Message</strong></td> <td align="center"><strong>Title</strong></td> <td align="center"><strong>Icon</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center"><?php $id[]=$rows['id']; ?><?php echo $rows['id']; ?></td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="month[]" MAXLENGTH="3" size="3" type="text" id="month" value="<?php echo $rows['month']; ?>"> <input style="border: 1px solid #C3C3C3;height: 20px;" name="date[]" MAXLENGTH="2" size="2" type="text" id="date" value="<?php echo $rows['date']; ?>"> </td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="message[]" size="70" type="text" id="message" value="<?php echo $rows['message']; ?>"></td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="title[]" size="70" type="text" id="title" value="<?php echo $rows['title']; ?>"></td> <td align="center"> <select name="test[]" style="display:block; width:200px" class="mydds"> <option value="icon_phone.gif" title="icon/icon_phone.gif">Phone</option> <option value="icon_sales.gif" title="icon/icon_sales.gif">Graph</option> </select> </td> </tr> <?php } ?> <tr> <td colspan="4" align="center"><br><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </td> </tr> </form> <?php if (isset($_POST['Submit'])) { for($i=0;$i<$count;$i++){ $month = $_POST['month']; $date = $_POST['date']; $message = $_POST['message']; $title = $_POST['title']; $monthday = $month[$i]."<br>".$date[$i]; $sql1="UPDATE $tbl_name SET monthday='$monthday', month='$month[$i]', date='$date[$i]', message='" . mysql_real_escape_string($message[$i]) . "', title='" . mysql_real_escape_string($title[$i]) . "' WHERE id='$id[$i]'"; $result1 = mysql_query($sql1); } header("location:update2.php"); } ?> Please I keep having the same problem when i run my script on the server. the error is Code: [Select] Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/alliapop/public_html/ekloges2010/ekloges2010/eisagogi.php:1) in /home/alliapop/public_html/ekloges2010/ekloges2010/includes/session.php on line 1I know i have to put session start at he very first line and i did but the problem keeps showing up. What else should i check? Hi im getting the following error message in my admin area: Code: [Select] Warning: session_start() [function.session-start]: open(/home/users/web/b109/ipg.removalspacecom/cgi-bin/tmp/sess_9b495d20f1a5e1cb9eaed99c1b5dfed6, O_RDWR) failed: No such file or directory (2) in /hermes/bosweb25a/b109/ipg.removalspacecom/admin01.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /hermes/bosweb25a/b109/ipg.removalspacecom/admin01.php:2) in /hermes/bosweb25a/b109/ipg.removalspacecom/admin01.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /hermes/bosweb25a/b109/ipg.removalspacecom/admin01.php:2) in /hermes/bosweb25a/b109/ipg.removalspacecom/admin01.php on line 2 There are 1 removalspace users so far. Company Name Contact Name Contact Number Email Address Line 1 Address Line 2 Location Postcode Basic Members Upgraded Users Company Logo Approved none none none andy_b_1502@hotmail.co.uk none none none none Current level = 0 Level 1 - Free Level 2 - Basic Level 3 - Premium Level 0 - Do Not Display Warning: Unknown: open(/home/users/web/b109/ipg.removalspacecom/cgi-bin/tmp/sess_9b495d20f1a5e1cb9eaed99c1b5dfed6, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/home/users/web/b109/ipg.removalspacecom/cgi-bin/tmp) in Unknown on line 0 Admin01.php Code: [Select] <?PHP session_start(); /* really need to use a session variable to insure authorized to be here */ include ('db.php'); /* ======================================== 99% of the time it is better to put your query in a string. It makes debugging much easier ======================================== */ $query = "SELECT * FROM companies"; $result = mysql_query($query ) or die("SELECT Error: ".mysql_error()); $num_rows = mysql_num_rows($result); /* ======================================== I find it easier to locate problems if I indent code properly and drop out of PHP if there are large sections of html ======================================== */ ?> <br><br><br>There are <?PHP echo $num_rows; ?> removalspace users so far.<P> <table width="819" height="114"> <tr> <th>Company Name</th> <th>Contact Name</th> <th>Contact Number</th> <th>Email</th> <th>Address Line 1</th> <th>Address Line 2</th> <th>Location</th> <th>Postcode</th> <th>Basic Members</th> <th>Upgraded Users</th> <th>Company Logo</th> <th>Approved</th> </tr> <tr> <td colspan="6"></td> </tr> <?PHP while ( $row = mysql_fetch_array($result, MYSQL_ASSOC )) { ?> <tr> <td><?PHP echo $row['company_name']; ?></td> <td><?PHP echo $row['contact_name']; ?></td> <td><?PHP echo $row['phone']; ?></td> <td><?PHP echo $row['email']; ?></td> <td><?PHP echo $row['street1']; ?></td> <td><?PHP echo $row['street2']; ?></td> <td><?PHP echo $row['location']; ?></td> <td><?PHP echo $row['postcode']; ?></td> <td><?PHP echo $row['basicpackage_description']; ?></td> <td><?PHP echo $row['premiumuser_description']; ?></td> <?PHP /* ======================================== I presume you want to show the thumb version here ======================================== */ ?> <td><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></td> </tr> <tr> <td colspan="10"> <table> <tr> <td>Current level = <?PHP echo $row['approved']; ?></td> <td><a href="admin02.php?id=<?PHP echo $row['id']; ?>&level=1">Level 1 - Free</a></td> <td><a href="admin02.php?id=<?PHP echo $row['id']; ?>&level=2">Level 2 - Basic</a></td> <td><a href="admin02.php?id=<?PHP echo $row['id']; ?>&level=3">Level 3 - Premium</a></td> <td><a href="admin02.php?id=<?PHP echo $row['id']; ?>&level=0">Level 0 - Do Not Display</a></td> </tr> </table> </tr> <?PHP } echo "</table>"; ?></table> Then when i click to change something e.g level of user, i get this error message: Code: [Select] Warning: session_start() [function.session-start]: open(/home/users/web/b109/ipg.removalspacecom/cgi-bin/tmp/sess_d986479c3603a52a37390b24a12caf03, O_RDWR) failed: No such file or directory (2) in /hermes/bosweb25a/b109/ipg.removalspacecom/admin02.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /hermes/bosweb25a/b109/ipg.removalspacecom/admin02.php:2) in /hermes/bosweb25a/b109/ipg.removalspacecom/admin02.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /hermes/bosweb25a/b109/ipg.removalspacecom/admin02.php:2) in /hermes/bosweb25a/b109/ipg.removalspacecom/admin02.php on line 2 Warning: Cannot modify header information - headers already sent by (output started at /hermes/bosweb25a/b109/ipg.removalspacecom/admin02.php:2) in /hermes/bosweb25a/b109/ipg.removalspacecom/admin02.php on line 9 Warning: Unknown: open(/home/users/web/b109/ipg.removalspacecom/cgi-bin/tmp/sess_d986479c3603a52a37390b24a12caf03, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/home/users/web/b109/ipg.removalspacecom/cgi-bin/tmp) in Unknown on line 0 Admin02.php Code: [Select] <?PHP session_start(); /* really need to use a session variable to insure authorized to be here */ include('db.php'); $id = (int) $_GET['id']; $level = (int) $_GET['level']; $query = "UPDATE companies set approved = '$level' WHERE id = '$id'"; $result = mysql_query($query); header("Location: admin01.php"); ?> Can someone please help with this please? I am getting the following error mesages when I view the index page at http://www.voltageking.com/exams/. I have no idea why this would be ocurring. I did not write the PHP code. The code was written by an ex-employee who is no longer able to be contacted. I thought perhaps these errors are ocurring because I reinstalled the files overwriting the older files and it perhaps changed the permissions, but I went to the directory and changed the directory and file permissions to all and it still gave me the identical error messages. Below in RED is the text which apears when you view http://www.voltageking.com/exams/ . Warning: session_start() [function.session-start]: open(/var/chroot/home/content/v/o/l/voltageking/tmp/sess_b8c8479843aced59a006557ec7b499ff, O_RDWR) failed: No such file or directory (2) in /home/content/v/o/l/voltageking/html/exams/index.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/v/o/l/voltageking/html/exams/index.php:2) in /home/content/v/o/l/voltageking/html/exams/index.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/v/o/l/voltageking/html/exams/index.php:2) in /home/content/v/o/l/voltageking/html/exams/index.php on line 2 It is refering to line 2 of the index.php file which I have pasted below in BLUE: <?php session_start(); $_SESSION['logged']="none"; ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Power Learning Systems Online Practice Tests</title> <link rel="stylesheet" type="text/css" media="screen" href="css/Test-CSS.css" /> <style type="text/css" title="currentStyle" media="screen"> @import "css/Test-CSS.css"; #wrapper { position: absolute; bottom: 50%; right: 50%; height: 600px; width: 745px; } #container { position: relative; left: 50%; top: 50%; } #loginArea{ position:absolute; width:749px; height:570px; z-index:1; background-image: url(images/login-bgs.jpg); background-repeat: no-repeat; overflow: visible; } #PLSlogo { position:absolute; width:282px; height:117px; z-index:2; left: 208px; top: 97px; } #login { position:absolute; width:294px; height:32px; z-index:2; left: 269px; top: 399px; text-align: center; } #password { position:absolute; width:100px; height:25px; z-index:2; left: 163px; top: 403px; text-align: right; font-family: Verdana, Geneva, sans-serif; font-size: 14px; font-weight: normal; color: #024572; } .pass { margin-top: 0px; margin-bottom: 0px; font-family: Verdana, Geneva, sans-serif; font-size: 13px; color: #000; text-align: left; text-indent: 0px; border-top-width: 1px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #003466; border-right-color: #003466; border-bottom-color: #003466; border-left-color: #003466; width: 202px; } #intro { position:absolute; width:511px; height:36px; z-index:2; left: 122px; top: 251px; font-family: Verdana, Geneva, sans-serif; font-size: 20px; color: #064473; font-weight: bold; text-align: center; } #moreinfo { position:absolute; width:500px; height:18px; z-index:2; left: 128px; top: 282px; font-family: Verdana, Geneva, sans-serif; font-size: 12px; color: #064473; text-align: center; } #message1 { position:relative; width:540px; height:28px; z-index:2; left: 104px; top: 360px; font-family: Verdana, Geneva, sans-serif; font-weight: normal; color: #F00; text-align: center; } #apDiv1 { position:relative; width:200px; height:20px; z-index:3; left: 510px; top: 508px; font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: #666; text-align: right; } #apDiv1 a{ font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: #666; text-decoration: none; } #apDiv1 a:hover{ font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: #000000; text-decoration: none; } #apDiv2 { position:relative; z-index:1; left: 54px; top: 420px; text-align: center; height: 32px; width: 644px; } </style> <body bgcolor="#EAEDF4"> <span> <div id="wrapper"> <div id="container"> <div id="loginArea"> <div id="message1"><?php echo $_SESSION['message1']; ?></div> <div id="apDiv1">Powered by <a href="http://www.VoltageKing.com" target="_blank">VoltageKing.com</a></div> <div id="PLSlogo"><a href="http://www.4ezhelp.com/" target="_blank"><img src="http://www.4ezpass.com/images/PLS_main_logo.jpg" border="0"/></a></div> <div id="intro">Online Examination Preparation Interface</div> <div id="moreinfo">For more information about Power Learning Systems Online Tests <a href="http://www.voltageking.com/pages.php?CDpath=0&pID=54">click here</a></div> <div id="password">Password:</div> <div id="login"> <form id="form1" name="form1" method="post" action="login.php"> <input type="hidden" value="http://www.4ezpass.com" name="sender"> <input name="pass" type="password" class="pass" maxlength="20" /> <input name="login" type="submit" value="login" /> </form> </div> <div id="apDiv2"><img src="http://www.4ezpass.com/images/PPP.jpg" border="0"/></div> </div> </div> </div> </span> <?php $_SESSION['message1']=" "; $_SESSION['message2']=" "; ?> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-15438543-9"); pageTracker._trackPageview(); } catch(err) {}</script> </body> </html> Any help would be greatly appreacated! Steve :-)
I'm trying to start a session in a simple php file.
Here's *all* the code:
Here's the URL: |