![]() |
MYSQL error (confused)
Hi,
I am trying to create an upload file system to my mysql database and I keep getting the same error message. Can you take a quick look and help please? Thanks, Eric HTML FORM Code:
<form action="show.php" method="post" enctype="multipart/form-data">PHP Code:
Connection WorkingY1 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',)' at line 1 |
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,)Code:
INSERT INTO tablename (name,type,size) VALUES ('Y','1',' ')PHP Code:
|
Hi,
Thanks for the reply and advice so far. I did what you said and I got the same error unfortunately. Here it is: Connection Working IB1 SQL Error! Query is INSERT INTO IB1FILES (name,type,size) VALUES (,,) Error is You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',)' at line 1 I think the problem is that the code isn't filling the file variables with information. Is this a reasonable thought? |
A reasonable thought. What did your debug code show?
Code:
echo "Connection Working";Incidentally, that would be really hard to figure out what is/isn't working, as written. Better: Code:
echo "Connection Working<br/>";To wit: If the name and/or type fields in your DB is a string type (e.g., VARCHAR or CHAR) then you *MUST* have apostrophes around their values. Code:
$query = "INSERT INTO " . $gradetable . " (name,type,size) " |
Yay, you guys helped me get the SQL error out of the way. The problem of the missing data in the variables $name, $type and $size remains though. When I use the echo function on them nothing appears leaving me to believe the transfer of information from my html form to the php script was void.
Sorry for continuing the thread but if you help me with just this one problem I will award thanks virtually and in reality. |
MUAHAHAHHAHAHA THANKS FOR THE HELP BUT I FINALL FIXED IT!!! retard mistake :S I didn't write
Code:
name="file"thanks for all the help guys! |
| All times are GMT +1. The time now is 08:52 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.