Click to See Complete Forum and Search --> : No variable stored on table?


Perfidus
12-10-2003, 09:12 PM
Why this is storing nothing on my table?
For me seems to be ok.

<?php
session_start();
if (session_is_registered('usuario')){
}
$Sesion = session_id;
$conexion=mysql_connect('', '', '');
mysql_select_db("",$conexion);
$sql = "INSERT INTO Reservas ( Ref, ene1t, ene2t, ene3t, ene4t, ene5t, feb1t, feb2t, feb3t, feb4t, feb5t, mar1t, mar2t, mar3t, mar4t, mar5t, abr1t, abr2t, abr3t, abr4t, abr5t, may1t, may2t, may3t, may4t, may5t, jun1t, jun2t, jun3t, jun4t, jun5t, jul1t, jul2t, jul3t, jul4t, jul5t, ago1t, ago2t, ago3t, ago4t, ago5t, sep1t, sep2t, sep3t, sep4t, sep5t, oct1t, oct2t, oct3t, oct4t, oct5t, nov1t, nov2t, nov3t, nov4t, nov5t, dic1t, dic2t, dic3t, dic4t, dic5, Sesion)".
"VALUES ('$Ref', '$ene1t', '$ene2t', '$ene3t', '$ene4t', '$ene5t', '$feb1t', '$feb2t', '$feb3t', '$feb4t', '$feb5t', '$mar1t', '$mar2t', '$mar3t', '$mar4t', '$mar5t', '$abr1t', '$abr2t', '$abr3t', '$abr4t', '$abr5t', '$may1t', '$may2t', '$may3t', '$may4t', '$may5t', '$jun1t', '$jun2t', '$jun3t', '$jun4t', '$jun5t', '$jul1t', '$jul2t', '$jul3t', '$jul4t', '$jul5t', '$ago1t', '$ago2t', '$ago3t', '$ago4t', '$ago5t', '$sep1t', '$sep2t', '$sep3t', '$sep4t', '$sep5t', '$oct1t', '$oct2t', '$oct3t', '$oct4t', '$oct5t', '$nov1t', '$nov2t', '$nov3t', '$nov4t', '$nov5t', '$dic1t', '$dic2t', '$dic3t', '$dic4t', '$dic5t', '$Sesion')";
$result = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
$result2 = mysql_query("SELECT * FROM Reservas WHERE (Sesion='$Sesion')", $conexion);
while($row = mysql_fetch_array($result2)) {
?>

Zibings
12-10-2003, 10:56 PM
mysql_select_db("",$conexion);

It'd probably help if you selected a database, unless they put crazy standards on these things too! ;)

Perfidus
12-11-2003, 04:35 AM
I just removed database name as a security measure, but normally it is there...

YoN
12-11-2003, 06:06 PM
In the query, you are concatenating two strings... When PHP concatenates the two strings, the resulting query would be: INSERT INTO Reservas (blah)VALUES (blah) <- there's no space between ")" and "VALUES". put a space between the two strings, be at the end of the first or at the begining of the second string.
Try that and see if it works.

Two more things having a second look to your code...
The use of session_register(), session_is_registered() and session_unregister() is deprecated and for security reasons it is better to use $_SESSIONFrom PHP.net (http://us2.php.net/manual/en/ref.session.php):
Use of $_SESSION (or $HTTP_SESSION_VARS with PHP 4.0.6 or less) is recommended for improved security and code readablity. With $_SESSION, there is no need to use the session_register(), session_unregister(), session_is_registered() functions. Session variables are accessible like any other variables. Also change this line:$Sesion = session_id; to:$Sesion = session_id();
HTH