Well, this is PHP & mySQL - Error, wrong syntax?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
katcarvell
Forum Newbie
Posts: 1
Joined: Sun Jan 25, 2009 7:51 pm

Well, this is PHP & mySQL - Error, wrong syntax?

Post by katcarvell »

Well, at first I would like to say hello to everyone, I'm Kat and I'll be around.


Anyway,
I get the error about the syntax here:


Could not execute query : INSERT INTO (id, business_name, representative_name, business_address, city, state, zip_code, phone_number_daytime, phone_number_evening, email, username, password, confirm_password) VALUES ('', 'test', 'test', 'test', 'test', 'TT', '12345', '2485555555', '5552505555', '', 'testtest', 'testpassword', 'testpassword').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 '(id, business_name, representative_name, business_address, city, state, zip_code' at line 1


Here is the code:

Code: Select all

<a href="index.php">Back to List</a>
 
<?php
/// In order to use this script freely
/// you must leave the following copyright
/// information in this file:
/// Copyright 2006 http://www.turningturnip.co.uk
/// All rights reserved.
 
include("connect.php");
$business_name = $_POST['business_name'];
$representative_name = $_POST['representative_name'];
$business_address = $_POST['business_address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip_code = $_POST['zip_code'];
$phone_number_daytime = $_POST['phone_number_daytime'];
$phone_number_evening = $_POST['phone_number_evening'];
$email = $_POST['email'];
$username = $_POST['username'];
$password = $_POST['password'];
$confirm_password = $_POST['confirm_password'];
 
$query = "INSERT INTO  (id, business_name, representative_name, business_address, city, state, zip_code, phone_number_daytime, phone_number_evening, email, username, password, confirm_password)
VALUES ('', '$business_name', '$representative_name', '$business_address', '$city', '$state', '$zip_code', '$phone_number_daytime', '$phone_number_evening', '$email', '$username', '$password', '$confirm_password')";
 
$results = mysql_query($query) or die 
("Could not execute query : $query." . mysql_error());
 
if ($results)
{
echo "Details added.";
}
mysql_close();
?>


Yeah, I'm not quite sure what to make of that.

(please bear with me, I'm starting in PHP and mySQL right now, so pardon me if my questions are obvious.)


Thanks!
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Well, this is PHP & mySQL - Error, wrong syntax?

Post by s.dot »

Your query should start with INSERT INTO tablename (id, ............
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply