$l="SELECT * FROM $tbl_name WHERE (OrderID = '" . mysql_real_escape_string($_POST['or']) . "')";
$sql = mysql_query($l) or die(mysql_error());

Here OrderID is my table column.
I am having two columns. Name is the first column and OrderID is the secondone. Both are same datatype i used as varchar.

When I apply the above code for first column alone is not working. but when i use the same code for second column its working.
I mean if i use name column its showing error as
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 'name = 'xx')' at line 1
and
when i use OrderId column its working fine. I dont know why......??????

Please clear my error

$l="SELECT * FROM $tbl_name WHERE `name` = '" . mysql_real_escape_string($_POST['or']) . "'";

If this fails, echo the entire generated query, and paste it here, along with the error message.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.