gammaman Posted April 26, 2008 Share Posted April 26, 2008 I am having no luck today. I have an insert statement and I could sware it is correct. mysql_query("Insert into CustomerOrder (ProductID,Amount) Values ('$Item','$Amt')"); Quote Link to comment https://forums.phpfreaks.com/topic/103039-solved-error-with-insert-statement/ Share on other sites More sharing options...
BlueSkyIS Posted April 26, 2008 Share Posted April 26, 2008 php/mysql will give you a clue about the error if you use or die(mysql_error()): mysql_query($some_sql) or die(mysql_error() . " $some_sql"); Quote Link to comment https://forums.phpfreaks.com/topic/103039-solved-error-with-insert-statement/#findComment-527777 Share on other sites More sharing options...
dooper3 Posted April 26, 2008 Share Posted April 26, 2008 It looks fine here... make sure your database columns are of exactly the same names as you have said in the query, and it's good practice to use capital letters for mySQL commands... so your code should look more like this: myql_query("INSERT INTO CustomerOrder (ProductID,Amount) VALUES ('$Item','$Amt')"); ; Also try to avoid using capital letters in variables, they are more often used for classes and functions (I think!). If it's still not working, show us what the actual error is that is coming up when you execute the query. Hope that helps Quote Link to comment https://forums.phpfreaks.com/topic/103039-solved-error-with-insert-statement/#findComment-527779 Share on other sites More sharing options...
gammaman Posted April 26, 2008 Author Share Posted April 26, 2008 Works fine Now, weird but the only thing I added was the or die. Quote Link to comment https://forums.phpfreaks.com/topic/103039-solved-error-with-insert-statement/#findComment-527791 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.