Hi, Can anyone help me with the syntax in this line of code? $query = mysql_query("INSERT INTO orders (order_product1ID) VALUES ('".$_SESSION['order_productID1']."') or die(mysql_error()); Code (markup): I'm trying to insert a session variable. Thanks go to anyone who can help me with this!
Have you tried to echo your statement string and then test it with phpmyadmin or somthing like that? That's what i do to check my statements if they have errors
<?php /* Note: Ensure $_SESSION['order_productID1'] exists, and you have connected to the database... */ //escape slashes to avoid sql parsing issues and to secure... $product_id = mysql_real_escape_string($_SESSION['order_productID1']); //notice the use trigger_error() instead of die() ? - its more useful. mysql_query("INSERT INTO orders (order_product1ID) VALUES ('{$product_id}')") or trigger_error(mysql_error()); ?> PHP:
Thanks chaps! It's working now. Boy I find the PHP syntax fiddly. Reps all around. Appreiate your help