Error in syntax, I cant figure out where.

06-30-06, 02:09 AM
|
|
New Member
|
|
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
Error in syntax, I cant figure out where.
Here is the code where I am recieving my error.
do_createtable.php
The error I get is:
You have an error in your SQL syntax near ')' at line 1
Obviously, my code is dying. What it should be doing is adding a table to "testDB". I use a form page where I enter in the field name, the field type, the field length, and whether it is a primary key and/or auto increment. Then I click the submit button where it should create my table no problem. I get this error instead.
If anyone could point me in the right direction, that would be great.
Thanks.
|

06-30-06, 03:21 AM
|
 |
Community Liaison
|
|
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
|
|
try echoing the query before entering it into mysql. most of te time you'll see what's wrong
just a small note: if you are going to allow user's to create a table, i don't think that's very wise: it is better to do it yourself, for security reasons.
Show me the query, and i'll see what's wrong
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks
|

06-30-06, 12:04 PM
|
|
New Member
|
|
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
|
Originally Posted by UnrealEd
try echoing the query before entering it into mysql. most of te time you'll see what's wrong
just a small note: if you are going to allow user's to create a table, i don't think that's very wise: it is better to do it yourself, for security reasons.
Show me the query, and i'll see what's wrong
UnrealEd
|
I totally understand the severity in security. Actually, this is not for users to use, its for my use. Im trying to teach myself PHP, since that is one language on my list to learn, and I have a book telling me to enter this code, and obviously, the book is wrong. I have checked over the code mulitple times to verify if i have what the book has, and I even tried using previous programming knowledge to see if I could figure out the error. I dont know if this is what you wanted but I put this line
and commented out the execution statement. This is the result I get when its ran.
CREATE TABLE)
Adding table to testDB...
I double checked everything to try to see if the syntax is correct and I guess if there is a mistake, im just not that PHP savvy to find it. Thanks for your help.
|

06-30-06, 12:25 PM
|
 |
Community VIP
|
|
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
UnrealEd: Hope you don't mind if I jump in here.
It appears that the $_POST variables are empty, probably due to a mismatch in the names used or some problem in the form code. If you post the form code it would help.
You can also add the following, right after the <? opening PHP tag, to get PHP to tell you more info about what is going on and to show you the actual POST variables -
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
|

06-30-06, 10:13 PM
|
|
New Member
|
|
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks. That worked. I entered in the code you told me to enter, and looked at the do_showfielddef.php and noticed this error:
The extra spaces were what was giving me troubles. Thanks for all of your help.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|