Jump to content

[SOLVED] if statement error?


bhavin_85

Recommended Posts

hey guys ive written an if statement to check for inputs from a form

 

the first statement works perfectly and prints the right info but the second is giving me this 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

 

<?
$cust_id=$_POST['cust_id'];
$uname=$_POST['uname'];

include('../../config.php');
if(empty($custid)){
$sql = "SELECT * FROM customer WHERE cust_id=$cust_id";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($result);
echo $row['uname'];
echo $row['first_name'];
}
elseif(empty($uname)) {
$sql1 = "SELECT * FROM customer WHERE uname=$uname";
$result1 = mysql_query($sql1) or die(mysql_error());
$row1 = mysql_fetch_assoc($result1);
echo $row1['first_name'];
}

?>

 

thats the code, i dont get where im gonig wrong  ???

Link to comment
https://forums.phpfreaks.com/topic/42344-solved-if-statement-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.