Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
Perfidus
Forum Contributor
Posts: 114 Joined: Sun Nov 02, 2003 9:54 pm
Post
by Perfidus » Tue Nov 25, 2003 9:18 am
I get the following error message processing this page, but I can't see where's the mistake:
Parse error: parse error in /chs/p1/costa4seasons.com/home/html/renamesession.php on line 19
Code: Select all
<?php
session_start();
$oldsession=session_id();
$link = mysql_connect('', '', '');
mysql_select_db("",$link);
$result = mysql_query("SELECT Inmo FROM Sesiones WHERE (Sesion='$oldsession')", $link);
while($row = mysql_fetch_array($result)) {
$Inmo=$row["Inmo"];
$rs = mysql_query($result,$link);
if (mysql_num_rows($rs)!=0){
}
session_regenerate_id();
$session=session_id();
$Fecha = date("Y-d-m h:i:s");
$sql = "INSERT INTO Sesiones ( Fecha, Inmo, Sesion)" .
"VALUES ('$Fecha', '$Inmo', '$session')";
$result2 = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
header ("Location: panelcontrol.html");
}else { ///ERROR SUPOSED TO BE HERE!!!
header("Location: acceso6.html?errorusuario=si");
}
mysql_close($link);
?>
d3ad1ysp0rk
Forum Donator
Posts: 1661 Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA
Post
by d3ad1ysp0rk » Tue Nov 25, 2003 9:27 am
your if statement doesnt have anything in it.
it closes before doing anything.
im assuming you want to do everything up to the else statement if the conditions are met? then do this:
Code: Select all
<?php
session_start();
$oldsession=session_id();
$link = mysql_connect('', '', '');
mysql_select_db("",$link);
$result = mysql_query("SELECT Inmo FROM Sesiones WHERE (Sesion='$oldsession')", $link);
while($row = mysql_fetch_array($result)) {
$Inmo=$row["Inmo"];
$rs = mysql_query($result,$link);
if (mysql_num_rows($rs)!=0){
session_regenerate_id();
$session=session_id();
$Fecha = date("Y-d-m h:i:s");
$sql = "INSERT INTO Sesiones ( Fecha, Inmo, Sesion)" .
"VALUES ('$Fecha', '$Inmo', '$session')";
$result2 = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
header ("Location: panelcontrol.html");
}
else {
header("Location: acceso6.html?errorusuario=si");
}
mysql_close($link);
?>
and don't forget to end your while (add another closing bracket somewhere near the end), i'd put it in, but im not sure what you're trying to do
good luck
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Tue Nov 25, 2003 9:53 am
To add to what LiLpunkSkateR has posted, you will find that the problem becomes much more evident if you indent your code and add some whitespace:
Code: Select all
<?php
session_start();
$oldsession = session_id();
$link = mysql_connect('', '', '');
mysql_select_db('', $link);
$result = mysql_query("SELECT Inmo FROM Sesiones WHERE (Sesion='$oldsession')", $link);
while ($row = mysql_fetch_array($result)) {
$Inmo = $row['Inmo'];
$rs = mysql_query($result,$link);
if (mysql_num_rows($rs)!=0){
}
session_regenerate_id();
$session = session_id();
$Fecha = date("Y-d-m h:i:s");
$sql = "INSERT INTO Sesiones ( Fecha, Inmo, Sesion) VALUES ('$Fecha', '$Inmo', '$session')";
$result2 = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
header ("Location: panelcontrol.html");
} else { ///ERROR SUPOSED TO BE HERE!!!
header("Location: acceso6.html?errorusuario=si");
}
mysql_close($link);
?>
If you make the changes suggested it looks like this:
Code: Select all
<?php
session_start();
$oldsession = session_id();
$link = mysql_connect('', '', '');
mysql_select_db('', $link);
$result = mysql_query("SELECT Inmo FROM Sesiones WHERE (Sesion='$oldsession')", $link);
while ($row = mysql_fetch_array($result)) {
$Inmo = $row['Inmo'];
$rs = mysql_query($result,$link);
if (mysql_num_rows($rs)!=0){
session_regenerate_id();
$session = session_id();
$Fecha = date("Y-d-m h:i:s");
$sql = "INSERT INTO Sesiones ( Fecha, Inmo, Sesion) VALUES ('$Fecha', '$Inmo', '$session')";
$result2 = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
header ("Location: panelcontrol.html");
} else {
header("Location: acceso6.html?errorusuario=si");
}
}
mysql_close($link);
?>
Mac