Page 1 of 1

Why this stores nothing in DB?

Posted: Wed Dec 10, 2003 9:15 pm
by Perfidus
Why this is storing nothing on my table?
For me seems to be ok.

Code: Select all

<?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))  {
?>

Posted: Thu Dec 11, 2003 1:52 am
by aquila125
you get an error?

Posted: Thu Dec 11, 2003 2:35 am
by twigletmac
Have you checked the SQL query to make sure that all the variables are being passed correctly? Just do

Code: Select all

echo $sql;
before you do the query.

For the second query, are you sure that $Sesion is set correctly? Have you echoed that to check?

Mac

I can`t insert data

Posted: Thu Dec 11, 2003 8:47 am
by Perfidus
OK, I'm checking the sql but nothing is echoed, maybe the form is wrong and no info reach the page? How can I be sure, Am I echoing sql right?

Code: Select all

<?php
$Sesion = session_id();
$conexion=mysql_connect("","",""); 
mysql_select_db("aa3968",$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')"; 
echo $sql;
$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))  {
?>

Posted: Thu Dec 11, 2003 9:05 am
by twigletmac
When you say nothing is echoed, do you mean nothing at all, or just that the variables aren't echoed?

Mac

Posted: Thu Dec 11, 2003 12:22 pm
by aquila125
where do the variables come from? A form?

Posted: Thu Dec 11, 2003 2:22 pm
by AnsonM
Is the page blank? Are there no errors displayed??

Looks weird how hes using the session..

also have you even connected to the database?? you actually need to connect to it to store data in it...