PDA

View Full Version : Database SQl statement prObLem??


fireblade
05-27-2007, 04:35 AM
I am using the foLLowing cOde to INSERT DATAS.


$fname=$_POST['txtFName'];
$lname=$_POST['txtLName'];
$email=$_POST['txtEmail'];
$pass=$_POST['txtPass'];
$address1=$_POST['txtAddress1'];
$address2=$_POST['txtAddress2'];
$city=$_POST['txtCity'];
$country=$_POST['txtCountry'];

$SQL = "INSERT INTO user(fname, lname, email, password, address1, address2, city, country)";
$SQL .= " VALUES ('$fname', '$lname', '$email', PASSWORD('$pass'), '$address1', '$address2', '$city', '$country')";

if(mysql_query($SQL, $id))



My database is as follows..


+----------+--------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------------+------+-----+---------+-------+
| fname | varchar(20) | | | | |
| lname | varchar(20) | YES | | NULL | |
| email | varchar(50) | | PRI | | |
| password | varchar(20) binary | | | | |
| address1 | varchar(30) | | | | |
| address2 | varchar(20) | YES | | NULL | |
| city | varchar(15) | YES | | NULL | |
| Country | varchar(15) | YES | | NULL | |
+----------+--------------------+------+-----+---------+-------+


I am getting errOr with this statment cOntinuesLy.. I tried mOre & mOre changing the wayss.. But it ends up with errOr.

What is the wrOng with my SQL statment??

Any One pLease heLp me...

firepages
05-27-2007, 05:23 AM
what does <?php echo mysql_error();?> say ?

fireblade
05-27-2007, 05:57 AM
what does <?php echo mysql_error();?> say ?

ShOuLd I enter it and try the message??

Isn't there any errOrs in My SQL statment?

Fumigator
05-27-2007, 06:14 AM
Isn't there any errOrs in My SQL statment?

That's what we'd like to know....

do "echo mysql_error();" and do "echo $SQL;" to find out.