Form Variables Problem (fixed)

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
efriese
Forum Newbie
Posts: 9
Joined: Sun Feb 08, 2004 10:25 pm
Location: Auburn, AL

Form Variables Problem (fixed)

Post 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!
Last edited by efriese on Sat Feb 21, 2004 1:26 pm, edited 1 time in total.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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.
efriese
Forum Newbie
Posts: 9
Joined: Sun Feb 08, 2004 10:25 pm
Location: Auburn, AL

Post by efriese »

Thanks for pointing that out! Its working fine now.
Post Reply