Bea Posted July 1, 2009 Share Posted July 1, 2009 I am getting the error: Warning: session_start() [function.session-start]: open(/var/sessions/sess_8f695bfd3ffcd2603ae76cdc45b5ca40, O_RDWR) failed: No such file or directory (2) in /home/rh/public_html/glory/nlogin.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/rh/public_html/glory/nlogin.php:2) in /home/rh/public_html/glory/nlogin.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/rh/public_html/glory/nlogin.php:2) in /home/rh/public_html/glory/nlogin.php on line 2 Line two of the code says: include('dbconnect.php'); The code of dbconnect.php is: <?php $dbh=mysql_connect ("localhost", "rh_glory", "bamcleopatra") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("rh_Glory"); ?> I know there is a thread about the Header error, but I'm not sure exactly if that has to do with this, since I see no way it could? Why is it doing this? Link to comment https://forums.phpfreaks.com/topic/164409-issue-in-dbconnect/ Share on other sites More sharing options...
Bea Posted July 2, 2009 Author Share Posted July 2, 2009 anyone? Link to comment https://forums.phpfreaks.com/topic/164409-issue-in-dbconnect/#findComment-867466 Share on other sites More sharing options...
Bendude14 Posted July 2, 2009 Share Posted July 2, 2009 can you show us the file that this file is included into? Ben Link to comment https://forums.phpfreaks.com/topic/164409-issue-in-dbconnect/#findComment-867535 Share on other sites More sharing options...
johnathanhebert Posted July 2, 2009 Share Posted July 2, 2009 The "headers already sent" error means that the HTTP headers have already been sent to the browser, and then somewhere in your script you attempted to send more HTTP headers. In this case, it looks like the first header warning is because you are trying to send another Cookie header when it has already been sent... headers are sent with the header() function so you may want to search for that. Also, you can use the output buffering functions to keep from sending content to the browser until you tell it. Just call ob_start() at the beginning of your script and ob_end_flush() at the end... there are other output buffering functions you can also take a look at... Link to comment https://forums.phpfreaks.com/topic/164409-issue-in-dbconnect/#findComment-867539 Share on other sites More sharing options...
Bea Posted July 2, 2009 Author Share Posted July 2, 2009 It is in included into this: <?php include('inc/membersonly.php'); include('inc/dbconnect.php'); $active = 'results'; if ($_GET['active'] != '') { $active = $_GET['active']; } ?> <title>Glory Racing Sim ;; Burning up the track since June 2007</title> <link rel="stylesheet" href="glory.css" type="text/css" media="screen" /> </head> <body> <p align="center"> <table width=750px> <tr><td> <div id="page"> <div id="header"> <?php include("header.php"); ?> </div> <?php include("nav.php"); ?> <table width="750"> <tr> <td><div align="center"><a href="account.php?active=results" class="loggedin">RESULTS</a></div></td> <td><div align="center"><a href="bank.php" class="loggedin">BANK</a></div></td> <td><div align="center"><a href="account.php?active=horses" class="loggedin">HORSES</a></div></td> <td><div align="center"><a href="account.php?active=facility" class="loggedin">FACILITIES</a></div></td> <td><div align="center"><a href="account.php?active=entry" class="loggedin">ENTER RACES</a></div></td> <td><div align="center"><a href="account.php?active=manage" class="loggedin">MANAGE ENTRIES</a></div></td> <td><div align="center"><a href="logout.php" class="loggedin">LOGOUT</a></div></td> </tr> <tr> <td colspan="7"> <? include('inc/act/'.$active. '.php'); ?> </td> </tr> </table> <div id="footer"> <?php include("disclaim.php"); ?> </div> </div> </td></tr> </table> </p> </body> The membersonly.php file has a header() in it, but I'm not quite sure what I should do about it? <?php include('dbconnect.php'); //if the person looking at this page is not logged in, they will be taken to the login page $mid = $_SESSION['mid']; $sql ="SELECT * FROM `members2` WHERE mid='$mid'"; $query = mysql_query($sql) or die( mysql_error() . "<br />" . $sql ); $row = mysql_fetch_array($query); $username=$row['username']; if (!$mid) { header("Location: login.php?expire=yes"); exit; } ?> Link to comment https://forums.phpfreaks.com/topic/164409-issue-in-dbconnect/#findComment-867551 Share on other sites More sharing options...
abdfahim Posted July 2, 2009 Share Posted July 2, 2009 Do you have any header in header.php, nav.php or disclaim.php? If so, it'll create problem definitely. Link to comment https://forums.phpfreaks.com/topic/164409-issue-in-dbconnect/#findComment-867556 Share on other sites More sharing options...
Bea Posted July 2, 2009 Author Share Posted July 2, 2009 Unless I'm missing something, they do not contain any header Link to comment https://forums.phpfreaks.com/topic/164409-issue-in-dbconnect/#findComment-867561 Share on other sites More sharing options...
PFMaBiSmAd Posted July 2, 2009 Share Posted July 2, 2009 The first error message is the output being sent that is causing the second two errors. The first error - open(/var/sessions/sess_8f695bfd3ffcd2603ae76cdc45b5ca40, O_RDWR) failed: No such file or directory, means that either the session.save_path setting is correct and the directory /var/sessions/ does not exist or that the session.save_path is incorrect and needs to be changed to match a directory that does exist. You should probably check with your web host to find out if session.save_path is supposed to be /var/sessions/ and then create that folder or if session.save_path is needs to be changed to a different value to match your account. Link to comment https://forums.phpfreaks.com/topic/164409-issue-in-dbconnect/#findComment-867565 Share on other sites More sharing options...
Bea Posted July 5, 2009 Author Share Posted July 5, 2009 I did talk to my host, and the session.save_path was wrong, now that is fixed and those errors have gone. But, I still have these: Notice: Undefined index: mid in /home/rh/public_html/glory/inc/membersonly.php on line 4 Warning: Cannot modify header information - headers already sent by (output started at /home/rh/public_html/glory/inc/membersonly.php:4) in /home/rh/public_html/glory/inc/membersonly.php on line 10 The code of membersonly.php is above Link to comment https://forums.phpfreaks.com/topic/164409-issue-in-dbconnect/#findComment-869311 Share on other sites More sharing options...
Bea Posted July 7, 2009 Author Share Posted July 7, 2009 bumping. Link to comment https://forums.phpfreaks.com/topic/164409-issue-in-dbconnect/#findComment-870193 Share on other sites More sharing options...
AwptiK Posted July 7, 2009 Share Posted July 7, 2009 mysql_select_db ("rh_Glory",$dbh); That probably won't change anything ^, but it gives me errors sometimes. Add session_start(); to the very top of the membersonly.php. I also moved the header(); up. <?php session_start(); include('dbconnect.php'); //if the person looking at this page is not logged in, they will be taken to the login page if (!isset($_SESSION['mid'])) { header("Location: login.php?expire=yes"); exit; } $mid = $_SESSION['mid']; $sql ="SELECT * FROM `members2` WHERE mid='$mid'"; $query = mysql_query($sql) or die( mysql_error() . "<br />" . $sql ); $row = mysql_fetch_array($query); $username=$row['username']; ?> Link to comment https://forums.phpfreaks.com/topic/164409-issue-in-dbconnect/#findComment-870210 Share on other sites More sharing options...
Bea Posted July 7, 2009 Author Share Posted July 7, 2009 Thank you, it got rid of those stupid errors. But of course, more were created >.< Notice: Undefined index: join in /home/rh/public_html/glory/nlogin.php on line 31 Notice: Undefined index: Login in /home/rh/public_html/glory/nlogin.php on line 32 <?php include('dbconnect.php'); // declare and fill variables $join = $_POST['join']; $login = $_POST['Login']; $username=$_POST['username']; $pass=$_POST['pass']; $time = time(); // compare login information to DB information $sql = "SELECT * FROM `members2` WHERE username='$username' AND pass='$pass' "; $query = mysql_query($sql) or die( mysql_error() . "<br />" . $sql ); $count = mysql_num_rows($query); $row = mysql_fetch_array($query); $mid = $row['mid']; if ($count == 1){ $cookie = $mid; $_SESSION['mid'] = $cookie; echo "Please wait...."; ?> <center><a href="account.php">Click here to continue</a> </center> <?php $time2 = strtotime("now"); $sql2 = "UPDATE `stables` SET `login` = $time2 WHERE `user_name` = '$name'"; $query2 = mysql_query($sql2) or die( mysql_error() . "<br />" . $sql2 ); } else { echo "Authentication Failed"; exit; } ?> <?php //<script language="JavaScript"><!-- //setTimeout('Redirect()',550); //function Redirect() //{ location.href = 'http://derbyfever.zorayah.com/';} // -->//<//cript> ?> One thing changes and another starts. Link to comment https://forums.phpfreaks.com/topic/164409-issue-in-dbconnect/#findComment-870512 Share on other sites More sharing options...
AwptiK Posted July 7, 2009 Share Posted July 7, 2009 Thank you, it got rid of those stupid errors. But of course, more were created >.< Notice: Undefined index: join in /home/rh/public_html/glory/nlogin.php on line 31 Notice: Undefined index: Login in /home/rh/public_html/glory/nlogin.php on line 32 <?php include('dbconnect.php'); // declare and fill variables $join = $_POST['join']; $login = $_POST['Login']; $username=$_POST['username']; $pass=$_POST['pass']; $time = time(); // compare login information to DB information $sql = "SELECT * FROM `members2` WHERE username='$username' AND pass='$pass' "; $query = mysql_query($sql) or die( mysql_error() . "<br />" . $sql ); $count = mysql_num_rows($query); $row = mysql_fetch_array($query); $mid = $row['mid']; if ($count == 1){ $cookie = $mid; $_SESSION['mid'] = $cookie; echo "Please wait...."; ?> <center><a href="account.php">Click here to continue</a> </center> <?php $time2 = strtotime("now"); $sql2 = "UPDATE `stables` SET `login` = $time2 WHERE `user_name` = '$name'"; $query2 = mysql_query($sql2) or die( mysql_error() . "<br />" . $sql2 ); } else { echo "Authentication Failed"; exit; } ?> <?php //<script language="JavaScript"><!-- //setTimeout('Redirect()',550); //function Redirect() //{ location.href = 'http://derbyfever.zorayah.com/';} // -->//<//cript> ?> One thing changes and another starts. That's debugging for you. When you get an error in one line of code, you don't see the other because it doesn't execute yet(most times). So when you fix line X, the errors on line Y show up. Link to comment https://forums.phpfreaks.com/topic/164409-issue-in-dbconnect/#findComment-870527 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.