Jump to content

syntax error... ARGH I WILL SHOOT THIS THING!!!!


netman182

Recommended Posts

i am having problems with this. i can't seem to figure it out.

 

I am getting this error: You have an error in your SQL syntax

 

phpmyadmin server version: Server version: 5.1.37

PHP version: 5.3

 

here is the code. can anyone help? it is probably a simple problem.

ID is an auto increment field.

the rest are text

 

<?php
$host="localhost"; // Host name 
$username="root"; // Mysql username 
$password="95887rj"; // Mysql password 
$db_name="bccsl"; // Database name 
$tbl_name="managers2"; // Table name 

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$sql="INSERT INTO Managers2 (ID, First, Last, City, Address, Postal, Home, Cell, Email, Username, Password, Church, Team)
VALUES
('',$_POST[firstname]','$_POST[lastname]','$_POST[city]','$_POST[address]','$_POST[postal]','$_POST[home]','$_POST[cell]','$_POST[church]','$_POST[team]','$_POST[username]','$_POST[password]')";

if (!mysql_query($sql))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($con)
?> 

Link to comment
Share on other sites

to avoid confusion in the query I would suggest this

 

$sql = sprintf("INSERT INTO Managers2 (First, Last, City, Address, Postal, Home, Cell, Email, Username, Password, Church, Team)
VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')", $_POST['firstname'],$_POST['lastname'],$_POST['city'],$_POST['address'],$_POST['postal'],$_POST['home'],$_POST['cell'],$_POST['church'],$_POST['team'],$_POST['username'],$_POST['password']);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.