RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting

MySQL syntax error check for the right syntax to use near 'A (A) )' at line 1

Join Date: Apr 2004
Location: Tracy
Posts: 744
Reputation: Killer_Typo will become famous soon enough Killer_Typo will become famous soon enough 
Rep Power: 7
Solved Threads: 32
Killer_Typo's Avatar
Killer_Typo Killer_Typo is offline Offline
Master Poster

MySQL syntax error check for the right syntax to use near 'A (A) )' at line 1

  #1  
Jun 20th, 2004
heres the complete error that i am getting.

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 'A (A) )' at line 1

does anyone else get these errors at all?

[php]<?php
$host = "localhost"; //location of the mysql
$name = "michael"; //user name for logging into mysql
$pass = ""; //password for logging into mysql

$TBname = "$_POST[TBname]"; //name of the table for Creation
$DBname = "$_POST[DBname]"; //name of the database for working in
$field = "$_POST[field]"; //name of the field
$type = "$_POST[type]"; //type of field
$length = "$_POST[length]"; //length of field
$prim = "$_POST[primary]"; //is field primary key or not
$incr = "$_POST[auto_increment]"; //is field auto_incrementing

mysql_connect($host, $name, $pass) or die(mysql_error());
mysql_select_db($DBname) or die(mysql_error());

$sql = "CREATE TABLE $TBname ("; //creates the table

for ($count = 0; $count < count($field); $count++)
{
$sql .= $field[$count] . " " . $type[$count];

if ($incr[$count] == "y")
{
$additional = "NOT NULL auto_increment";
}
else
{
$additional = "";
}
if ($prim[$count] == "y")
{
$additional .= ", primary key (" . $field[$count] . ")";
}
else
{
$additional = "";
}
if ($length[$count] != "")
{
$sql .= " (" .$length[$count] . ") $additional ,";
}
else
{
$sql .= " $additional ,";
}
}
// clean up the end of the string
$sql = substr($sql, 0, -1);
$sql .= ")";

$result = mysql_query($sql, mysql_connect($host, $name, $pass)) or die(mysql_error()); // execute the query

if ($result)
{
$msg = "<p>" . $TBname . "has been created</p>";
}
echo "Adding $TBname to $DBname ....Done<br />";
echo "Creating fields in $TBname ....Done<br />";
echo $msg . "<br />";
echo "<a href=\"http://localhost/dbadmin/db_management.php\">Return to Database Management</a>";
?>[/php]

so far ive written most of cheap spin off of phpmyadmin without a hitch, but now ive run into this error. any help would be greatly appreciated!
!!!!! WARNING YOUR COMPUTER MAY BE INFECTED WITH SPYWARE!!!! PAY AN OVER PRICED AMMOUNT TO HAVE SOMTHING FIXED WE PLACED THERE IN THE FIRST PLACE!!!!!!!!!

sound familiar, know how to block yourself and keep yourself clean.
_____________________
http://www.lavasoftusa.com/ -->adaware
http://www.safer-networking.org/en/index.html -->spybot S&D
http://www.javacoolsoftware.com/spywareblaster.html -->spywareblaster
http://www.javacoolsoftware.com/spywareguard.html -->spywareguard
_____________________
and dont forget to spread the reputation to those that deserve!
AddThis Social Bookmark Button
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 9:18 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC