Jump to content

Issue in dbconnect


Bea

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.