Page 1 of 1

Form Variables Problem (fixed)

Posted: Sat Feb 21, 2004 12:45 pm
by efriese
I'm trying to use an online form to enter information into a mySQL database. Some of my variables are making it into the database, some of them aren't. Here's my code:

Code: Select all

mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");

@mysql_select_db("$DBName") or die("Unable to select
database $DBName");
$event = htmlspecialchars(addslashes($event));
$date = htmlspecialchars(addslashes($date));
$sponsor = htmlspecialchars(addslashes($sponsor));
$cosponsor = htmlspecialchars(addslashes($cosponsor));
$type = htmlspecialchars(addslashes($type));
$attendance = htmlspecialchars(addslashes($attendance));
$sqlquery = "INSERT INTO $table
VALUES('$event','$date','$sponsor','$cosponsor','type','attendance')";

$results = mysql_query($sqlquery);

mysql_close();
The cosponsor variable is not making it to the database and the attendance always shows up as 0. I've double checked my form code and everything seems to be right there. Any help would be appreciated!

Posted: Sat Feb 21, 2004 12:49 pm
by markl999
VALUES('$event','$date','$sponsor','$cosponsor','type','attendance')"; shouldn't that be ..
VALUES('$event','$date','$sponsor','$cosponsor','$type','$attendance')"; ?

Also put error_reporting(E_ALL); right after the first <?php in the script and echo $sqlquery before the mysql_query() line just to make sure it looks how you expect it to.

Posted: Sat Feb 21, 2004 1:25 pm
by efriese
Thanks for pointing that out! Its working fine now.