Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-05-2012, 04:50 AM   PM User | #1
newphpcoder
Regular Coder

 
Join Date: Aug 2010
Posts: 653
Thanks: 155
Thanked 0 Times in 0 Posts
newphpcoder is an unknown quantity at this point
php mysql error for the right syntax to use near

Hi..

I have this code:

PHP Code:
$Approved = isset($_POST['priority']);
if (
$Approved)
{
    
$lot_number $_POST['lot_number'];
    
$sr_number_ $_POST['sr_number_'];
    
$SubQty $_POST['SubQty'];
    
$ItemCode $_POST['ItemCode'];
    
$picked_by $_POST['picked_by'];
    
$sql "SELECT stock_item, qty FROM wms WHERE stock_item = '$ItemCode' AND lot_number = '$lot_number'";
$res mysql_query($sql$con) or die(mysql_error());

$row mysql_fetch_assoc($res);

$stock_item $row['stock_item'];
$qty $row['qty'];

if(
$qty >= $SubQty){

$output $qty $SubQty;
$qty_withdraw '0.00';
}
else{
$output '0.00';
$qty_withdraw $SubQty $qty;
}   

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 'MAT-CHE-0040'' at line 2

but when I echo the $sql;
the output is:

SELECT stock_item, qty FROM wms WHERE stock_item = 'MAT-CHE-0040' AND lot_number = 'LO120601002';

and it works.

I don't know why in php the sql query got an error:

How can I remove that error?

Thank you so much
newphpcoder is offline   Reply With Quote
Old 06-05-2012, 06:09 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Change
PHP Code:
$res mysql_query($sql$con) or die(mysql_error()); 
to
PHP Code:
$res mysql_query($sql$con) or die(mysql_error(). '<br>'.$sql); 
and post the output here.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:02 PM.


Advertisement
Log in to turn off these ads.