homepage Welcome to WebmasterWorld Guest from 54.227.34.0
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Session being lost only sometimes in new host
helenp

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4431521 posted 9:53 pm on Mar 20, 2012 (gmt 0)

Hi,
In beginning of february I changed host,
I know in previous host I had a higer php version than in my new host.
I have a database mysql where I insert clients booking and owner can access the intranet login in with session and they can book there property for themself.
Since some week ago simetimes I find in my bookinglist an entry without any propertyname (this comes with the session), everything else is inserted except the id (propertyname) this has happen 4 times, maybe 10% of all owners insert or less.

I been in contact with the host and he think there is a bug in my script, this script I used for years and with a higer php version.
Just checked and I am currently using php 5.2.17, in previous host I was using php 5.3
So I wonder what can make loosing the session, not always only sometimes?
If the script worked in 5.3 shouldnt it work in 5.2?

I use this script after the user filled in a form to log in using sessions:
<?
include("conex/conexion.php");

$usuario = @mysql_real_escape_string($_POST['usuario']);
$pass = @mysql_real_escape_string($_POST['pass']);
$ssql = "SELECT * FROM usuarios WHERE usuario='$usuario' and pass='$pass'";
//I execute the sentence
$rs = mysql_query($ssql);
if (mysql_num_rows($rs)!=0){
//user and pass valid
//I do the session and save the dates
session_start();
$_SESSION['usuario'] = $usuario;
$_SESSION["autentificado"]= "SI";
header ("Location: loginpage_esp.php");
}else {
//If it does not exist I send them back to startpage
header("Location: span.php?errorusuario=no");
}
mysql_free_result($rs);
mysql_close($dbh);


?>


Then on all pages I start with this:
<?php
session_start();
?>

later in the script this can be seen
<?php
include("conex/conexion.php");
$usuario =$_SESSION['usuario'];
$id_property =$_REQUEST['id_property'];
?>
$casas = mysql_query("SELECT id_property, email FROM usuarios WHERE usuarios.usuario = '$usuario'", $dbh);
if ($row = mysql_fetch_array($casas)) {


To insert the booking I use this code, the property var change name as the table have diferent name for property id:

<?php
session_start();
ob_start();
?>
then:
<?php
include("conex/conexion.php");
$usuario =$_SESSION['usuario'];
$id_property =$_REQUEST['id_property'];
?>
then
$property = $_REQUEST[property];
$casas = mysql_query("SELECT id_property FROM usuarios WHERE usuarios.usuario = '$usuario'", $dbh);

$casa=mysql_result($casas,0);
$property = $casa;
$casa = str_replace("_", " ", $casa);
$property = str_replace("", "_", $property);
then process form:
check if available:
$result = mysql_query ("SELECT llegada, salida, property from bookings where ( property = '$property' ) etc...
insert booking and send automatic email:
$query1= "SELECT id_property, email FROM usuarios WHERE usuarios.usuario = '$usuario'";
$casas = $row['id_property'];
$casa2 = $row['id_property'];
$casa = $casa2;
email sent insert booking:
$query = "insert into bookings (id, llegada, tipo, tiporeserva, salida, tipo_sal, hora_llegada, hora_salida, property, cliente, reservado)" .
"values ('$id', '$llegada', '$tipo', '$tiporeserva', '$salida', '$tipo_sal', '$hora_llegada', '$hora_salida', '$property', '$cliente', '$reserv_date')";


Any help apreciated,
thanks

 

eelixduppy

WebmasterWorld Senior Member eelixduppy us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4431521 posted 6:35 pm on Apr 4, 2012 (gmt 0)

>> If the script worked in 5.3 shouldnt it work in 5.2?

This is generally a bad assumption. Perhaps you can assume this the other way around, but not this way. Although, nothing immediately pops out at me regarding these two.


$query = "insert into bookings (id, llegada, tipo, tiporeserva, salida, tipo_sal, hora_llegada, hora_salida, property, cliente, reservado)" .
"values ('$id', '$llegada', '$tipo', '$tiporeserva', '$salida', '$tipo_sal', '$hora_llegada', '$hora_salida', '$property', '$cliente', '$reserv_date')";


Which variable here is not populating with a value correctly?

rainborick

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4431521 posted 6:51 pm on Apr 5, 2012 (gmt 0)

Check this line:

$property = $_REQUEST[property];

to see if it should be:

$_REQUEST['property'];

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved