Hi everyone.

Please Please Please can someone help me?

I am trying to set up a php page that updates product qty's in the database. I almost have it working, however seem to have hit a brick wall.

The php simply reads an XML file which contains Product Codes & Qtys, and then $variable echo's are used in the mysql queery to UPDATE the database.

All works perfectly apart from when I have a product code that is alpha numeric.

For Example, My php file reads the XML and will find product codes as they are in the XML: i.e $productcode will echo 28923 or 28374S.

Now, the mysql syntax im using that works fine with numbers is:

UPDATE products_with_attributes_stock SET quantity = 100 WHERE product_code = 28923

This updates the quatity as it should as does the PHP file for any $productcode that echo's as just a number with:

mysql_query("UPDATE products_with_attributes_stock SET quantity = $stock WHERE product_code = $productcode");

What doesnt work is:

UPDATE products_with_attributes_stock SET quantity = 100 WHERE product_code = 28374S

this returns the error -

************************
Error

SQL query:

UPDATE products_with_attributes_stock SET quantity =100 WHERE product_code = 28374S

MySQL said: Documentation
#1054 - Unknown column 'product_code' in 'where clause'
************************
the value 28374S does exist! - I dont understand why mysql is returning this result..

I have noted that if I repeat the syntax with double quotations i.e "28734S" it works! BUT this is no good as my $productcode is not echoing that!???

In addition, I have managed to make my php echo the codes in double quotatons by doing $quote = '"'.$productcode.'"'; and using the following code for the syntax:

mysql_query("UPDATE products_with_attributes_stock SET quantity = $stock WHERE product_code = $quote");

BUT THIS ALSO DOESNT WORK!

Please please please let there be someone out there that can tell me why this isn't working!???

Is it my php code? is it the syntax? is it the way I have my table set up?? IM STUCK..

Kind Regards
Phil