SQL addage

KingAdora said:
What pray tell is this:

'$C ustEmail'

You also left off the ; at the end of the query line............. Helps if you spend 10 seconds reading it :)

yeah, the boards have a maximum word length...if you quote it, it comes out right.

and as Beansprout says, there's no ; in the query, and there isn't supposed to be. you can run the query 2 ways, my preference is

Code:
if (@mysql_query("INSERT INTO customer ('CustName','CustAddress','CustTelNo','CustEmail')   values('$Custname','$CustAddress','$CustTelNo','$CustEmail')"))

oh, and delete any spaces that vb might insert.
 
hmmmmmmmmmmmmmmm

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 ''CustName','CustAddress','CustTelNo','CustEmail') values('andrew','asdasd','1231' at line 1

Code:
<?php
include("db_connect.php");
// Connect to the database.
//If the form was submitted, process it.
//Pick up the values from the previous form
var_dump($_POST);
$CustName =$_POST['forename'];
$CustAddress =$_POST['surname'];
$CustTelNo =$_POST['maiden'];
$CustEmail =$_POST['email'];


if (@mysql_query("INSERT INTO Customer ('CustName','CustAddress','CustTelNo','CustEmail') values('$CustName','$CustAddress','$CustTelNo','$CustEmail')"))
    {
	echo 'The Customer has been added.';
	}
  else
    {
	echo 'The Customer could not be added because - ' . mysql_error();
	}
?>
 
the only difference i can see between mine (that works) and yours is having VALUES in caps. didn't think that mattered but it might be worth a try

also, when putting static info into a database like that, i dont think you need the inverted commas. only when putting variables in
 
hmmmmmmmmmmmmmm

Ok i have got it down to just this error now.

ou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@asdas.com)' at line 1

Thats the part where i enter the e-mail address.

Code:
<?php
include("db_connect.php");
// Connect to the database.
//If the form was submitted, process it.
//Pick up the values from the previous form
var_dump($_POST);
$CustName =$_POST['forename'];
$CustAddress =$_POST['surname'];
$CustTelNo =$_POST['maiden'];
$CustEmail =$_POST['email'];


if (@mysql_query("INSERT INTO Customer(CustName,CustAddress,CustTelNo,CustEmail) values($CustName, $CustAddress, $CustTelNo, $CustEmail)"))
    {
	echo 'The Customer has been added.';
	}
  else
    {
	echo 'The Customer could not be added because - ' . mysql_error();
	}
?>
 
hmmmmmmmmmmm

Code:
<?php
include("db_connect.php");
// Connect to the database.
//If the form was submitted, process it.
//Pick up the values from the previous form
var_dump($_POST);
$CustName = mysql_real_escape_string($_POST['forename']);
$CustAddress = mysql_real_escape_string($_POST['surname']);
$CustTelNo = mysql_real_escape_string($_POST['maiden']);
$CustEmail = mysql_real_escape_string($_POST['email']);


if (@mysql_query("INSERT INTO Customer(CustName, CustAddress, CustTelNo, CustEmail) VALUES($CustName, $CustAddress, $CustTelNo, $CustEmail)"))
    {
	echo 'The Customer has been added.';
	}
  else
    {
	echo 'The Customer could not be added because - ' . mysql_error();
	}
?>

Escaped it. Still got the same problem as above.
 
Back
Top Bottom