Parse error: parse error, unexpected $end in...
Posted: Tue Jun 29, 2004 3:44 pm
Hi, shown below, is the source-code in a file(extension 'php'). When I use the function require() on this file, I get the error : "Parse error: parse error, unexpected $end in line 52". Line 52 has only the following two characters: ?>
Can you please tell me what the problem is and what the solution would be? Already, I've spent quite a while trying to fix this problem.
feyd | use
Can you please tell me what the problem is and what the solution would be? Already, I've spent quite a while trying to fix this problem.
Code: Select all
<?php
session_start();
header("Cache-control: private");
$ses_table = "RAJ_Users";
$db_con = "Y";
$db_host = 'localhost';
$db_user = $_SESSION['username'];
$db_pass = $_SESSION['password'];
$db_dbase = 'sessions';
$_path = "C:\Program Files\Apache Group\Apache2\htdocs\SessionSupport";
/* Create a connection to a database. */
function db_connect() { $mysql_connect_var = mysql_pconnect($db_host, $db_user, $db_pass);
$mysql_db = mysql_select_db($db_dbase, $mysql_connect_var);
if (!$mysql_connect_var) { mysql_error(); return FALSE; }
if (!$mysql_db) {mysql_error(); return FALSE; }
return TRUE;
}
/* Open session, if you have your own db connection code, put it in here! */
function _open($_path, PHPSESSID) { if ($db_con == 'Y') { $db_connect(); }
return TRUE;
}
/* Close session. */
function _close() { $_gc(0);
return TRUE;
}
/* Read session data from database. */
function _read($User_ID, $pwd) { $session_sql = 'SELECT * FROM $ses_table WHERE User_ID = $db_user AND Password = $db_pass';
$session_res = mysql_query($session_sql);
if (!$session_res) { mysql_error(); return ' '; }
$session_num = 0;
$session_num = mysql_num_rows($session_res);
$session_row = mysql_fetch_assoc($session_res);
return $session_row;
}
/* Garbage collection; deletes old sessions. */
function _gc($life) { $ses_life = strtotime('-5 minutes');
$session_sql = 'DELETE FROM $ses_table WHERE ses_time < $ses_life';
$session_res = mysql_query($session_sql);
if (!$session_res) { return FALSE; }
else { return TRUE; }
}
session_set_save_handler('_open', '_close', '_read', '', '', '_gc');
?>feyd | use
Code: Select all
tags.[/color]