I am using a program 'My Contact Table' which is a code generator program. It allows you to easily create a PHP/MySQL web application without writing any code.
I am trying to create an additional data entry page. I have copied an existing page and created a new table in my database. When I run the script I get the error message "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"
Can you tell me where I should be looking for this error?
I have compared my code with the original and cannot see anywhere where this error might come from.
Here's the first part of my script....[php]
<?php
require '../mysqlvars.php';
require '../init.php';
require '../lib/db.php';
require '../lib/form_functions. php';
session_start(' MEMBERS');
$dbConn = connectDB($dbHo st, $dbUser, $dbPass, $dbDB);
if (!$dbConn) {
die('Database is currently down...please try again later');
}
require 'includes/secure_page.php ';
unset($error);
unset($confirm) ;
if (isset($_POST['submit'])) {
if (empty($_POST['last_name'])) {
$error = 'You must enter a last name';
}
if (!isset($error) ) {
$query = "INSERT INTO wsd_agent (agent_id,first _name,last_name ,add1,add2,town ,county,postcod e,bac_ref,sage_ ref,week,note,c lock,home_tel,m obile_tel) VALUES (";
$query .= 'NULL' . ',';
$dfield=prepare Data($_POST['week']);
$dfieldparts=ex plode("/", $dfield);
if(count($dfiel dparts==3)){
$insdate=$dfiel dparts[2].'-'.$dfieldparts[0].'-'.$dfieldparts[1];
$query .= "'$insdate' ,";
}
$query .= "'" . prepareData($_P OST['first_name']) . "'" . ',';
$query .= "'" . prepareData($_P OST['last_name']) . "'" . ',';
$query .= "'" . prepareData($_P OST['add1']) . "'" . ',';
$query .= "'" . prepareData($_P OST['add2']) . "'" . ',';
$query .= "'" . prepareData($_P OST['town']) . "'" . ',';
$query .= "'" . prepareData($_P OST['county']) . "'" . ',';
$query .= "'" . prepareData($_P OST['postcode']) . "'" . ',';
$query .= "'" . prepareData($_P OST['bac_ref']) . "'" . ',';
$query .= "'" . prepareData($_P OST['sage_ref']) . "'" . ',';
$query .= "'" . prepareData($_P OST['note']) . "'" . ',';
$query .= "'" . prepareData($_P OST['clock']) . "'" . ',';
$query .= "'" . prepareData($_P OST['home_tel']) . "'" . ',';
$query .= "'" . prepareData($_P OST['mobile_tel']) . "'" . ',';
$query .= ")";
if (mysql_query($q uery,$dbConn)) { ?>
<SCRIPT LANGUAGE="JavaS cript">[/php]
Any help would be appreciated.
Please read the Posting Guidelines and enclose your code within the appripriate code tags! - moderator
I am trying to create an additional data entry page. I have copied an existing page and created a new table in my database. When I run the script I get the error message "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"
Can you tell me where I should be looking for this error?
I have compared my code with the original and cannot see anywhere where this error might come from.
Here's the first part of my script....[php]
<?php
require '../mysqlvars.php';
require '../init.php';
require '../lib/db.php';
require '../lib/form_functions. php';
session_start(' MEMBERS');
$dbConn = connectDB($dbHo st, $dbUser, $dbPass, $dbDB);
if (!$dbConn) {
die('Database is currently down...please try again later');
}
require 'includes/secure_page.php ';
unset($error);
unset($confirm) ;
if (isset($_POST['submit'])) {
if (empty($_POST['last_name'])) {
$error = 'You must enter a last name';
}
if (!isset($error) ) {
$query = "INSERT INTO wsd_agent (agent_id,first _name,last_name ,add1,add2,town ,county,postcod e,bac_ref,sage_ ref,week,note,c lock,home_tel,m obile_tel) VALUES (";
$query .= 'NULL' . ',';
$dfield=prepare Data($_POST['week']);
$dfieldparts=ex plode("/", $dfield);
if(count($dfiel dparts==3)){
$insdate=$dfiel dparts[2].'-'.$dfieldparts[0].'-'.$dfieldparts[1];
$query .= "'$insdate' ,";
}
$query .= "'" . prepareData($_P OST['first_name']) . "'" . ',';
$query .= "'" . prepareData($_P OST['last_name']) . "'" . ',';
$query .= "'" . prepareData($_P OST['add1']) . "'" . ',';
$query .= "'" . prepareData($_P OST['add2']) . "'" . ',';
$query .= "'" . prepareData($_P OST['town']) . "'" . ',';
$query .= "'" . prepareData($_P OST['county']) . "'" . ',';
$query .= "'" . prepareData($_P OST['postcode']) . "'" . ',';
$query .= "'" . prepareData($_P OST['bac_ref']) . "'" . ',';
$query .= "'" . prepareData($_P OST['sage_ref']) . "'" . ',';
$query .= "'" . prepareData($_P OST['note']) . "'" . ',';
$query .= "'" . prepareData($_P OST['clock']) . "'" . ',';
$query .= "'" . prepareData($_P OST['home_tel']) . "'" . ',';
$query .= "'" . prepareData($_P OST['mobile_tel']) . "'" . ',';
$query .= ")";
if (mysql_query($q uery,$dbConn)) { ?>
<SCRIPT LANGUAGE="JavaS cript">[/php]
Any help would be appreciated.
Please read the Posting Guidelines and enclose your code within the appripriate code tags! - moderator
Comment