$table = mysql_query($query,$connection) or die(mysql_error());
// echo "<table border='1'>"; // echo "<tr> <th>id</th> <th>name</th> </tr>"; // // keeps getting the next row until there are no more to get // while($row = mysql_fetch_array( $query )) { // // Print out the contents of each row into a table // echo "<tr><td>"; // echo $row['id']; // echo "</td><td>"; // echo $row['name']; // echo "</td></tr>"; // }
// echo "</table>";
?>
ERROR MESSAGE:
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
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
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.
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?
Last edited by loopsnhoops; 04-25-2012 at 10:01 PM..
Reason: Thoughts
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.