hi....i am doing a php project.but lately, i have been in a dilemma bcoz i am receiving this kind of error after hitting the submit button.
Error: 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
this is my coding.....
i have re-write this code but the error still appear after i hit the submit button. i'm very glad if anyone could help me plz....
Error: 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
this is my coding.....
Code:
<?php
/* include db connection file */
include("dbconn.php");
if(isset($_POST['submit']))
{
/* capture values from HTML form */
$icnumber = $_POST['icnumber'];
$name = $_POST['name'];
$position = $_POST['position'];
$department = $_POST['department'];
$email = $_POST['email'];
$phoneno = $_POST['phoneno'];
$username = $_POST['username'];
$password = $_POST['password'];
$sql0 = "SELECT stafficnumber FROM staff WHERE stafficnumber= $icnumber";
$query0 = mysql_query($sql0) or die ("Error: " . mysql_error());
$row0 = mysql_num_rows($query0);
if($row0 != 0)
{
echo "Record is existed";
}
else
{
/* execute SQL INSERT command */
$sql2 = "INSERT INTO staff ( stafficnumber, staffname, staffposition, staffdepartment, staffemail, staffphoneno, staffusername, staffpassword )
VALUES ('".$icnumber."','".$name."',','".$position."','".$department."','".$email."','".$phoneno."''".$username."','".$password."')";
mysql_query($sql2) or die ("Error: ".mysql_error());
/* display a message */
echo "Data has been saved";
}
}// close if isset()
/* close db connection */
mysql_close($dbconn);
?>
Comment