469,890 Members | 1,967 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

parse error

hi,
i am getting a message Parse error:parse error, unexpected $...please help with this code:
<?php
require_once('db_login.php');
$sdbh = "";
$expire = 900;
function sess_open($save_path, $session_name){
global $dbhost, $dbuser, $dbpasswd, $sdbh;
if (! $sdbh = mysql_pconnect($dbhost, $dbuser, $dbpasswd)){
echo mysql_error();
exit;
}
return true;
}
function sess_close(){
return true;
}
function sess_read($key){
global $sdbh, $dbname, $tb_sessions;
$query = "
select
data
from
$tb_sessions
where
id = '$key'
and
expire > UNIX_TIMESTAMP()
";
$result = mysql_query($query);
if($record = mysql_fetch_row($result)){
return $record;
}else {
print (mysql_error());

}
function sess_write($key, $val){
global $sdbh, $dbname, $tb_sessions, $expire;
$value = addslashes($val);
$query = "
replace into
$tb_sessions
values (
'$key',
'$value',
UNIX_TIMESTAMP() + $expire
)
";
$result = mysql_query($query);
echo mysql_error();
return $result;
}
function sess_destroy($key){
global $sdbh, $dbname, $tb_sessions;
$query = "
delete from
$tb_sessions
where
id = '$key'
";
$result = mysql_query($query);
return $result;
}
function sess_gc($maxlifetime){
global $sdbh, $dbname, $tb_sessions;
$query = "
delete from
$tb_sessions
where
expire < UNIX_TIMESTAMP()
";
$result = mysql_query($query);
return mysql_affected_rows($sdbh);
}
session_set_save_handler("sess_open","sess_close", "sess_read","sess_write","sess_destroy","sess_gc") ;
session_start();
$sn = session_name();
$sid = session_id();

?>
Feb 25 '07 #1
0 913

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by H.L Bai | last post: by
21 posts views Thread by BWIGLEY | last post: by
AdrianH
5 posts views Thread by AdrianH | last post: by
AdrianH
1 post views Thread by AdrianH | last post: by
5 posts views Thread by goldtech | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.