View Single Post
Old 04-25-2012, 08:04 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
The problem is how you are building your INSERT query. Each value needs to be enclosed in single quotes (except columns that are integers, doubles, floats and decimals), and because you are not including these quotes in the string, the last value of " " is causing a syntax error with your query. Your query looks like this:

Code:
INSERT INTO tablename (name,type,size) VALUES (Y,1,)
It needs to look like this:

Code:
INSERT INTO tablename (name,type,size) VALUES ('Y','1',' ')
Whenever you run into a syntax error like this, echo out the _actual_ query (the string where you've put all the variables in) and the error will most likely jump right out at you.

PHP Code:
$query "INSERT INTO " $gradetable " (name,type,size) VALUES (" $name "," $type "," $size ")";

$table mysql_query($query,$connection);
if (!
$table)
{
    die(
"SQL Error! Query is $query<br />Error is ".mysql_error());

__________________

Last edited by Fumigator; 04-25-2012 at 08:06 PM..
Fumigator is offline   Reply With Quote
Users who have thanked Fumigator for this post:
loopsnhoops (04-26-2012)