TheStalker Posted February 28, 2008 Share Posted February 28, 2008 hi, i am having trouble making an insert statment work. i know the database is conected etc because i have other staments working above the one i am having trouble with. I have a large if esle stament that produces a total sorted in a variable called $total i am trying to insert the total into table accounts into collum WeelyCharge. the code i have is as follows $sql = "INSERT INTO accounts WeeklyCharge VALUES $total"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } the error i seem to get is this 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 'WeeklyCharge VALUES 18.2' at line 1 i have tried many diffrent ways of doing this and still cant get this insert to work. If anyone has any ideas that would be great many thanks! Link to comment https://forums.phpfreaks.com/topic/93548-help-with-insert-pls/ Share on other sites More sharing options...
premiso Posted February 28, 2008 Share Posted February 28, 2008 $sql = "INSERT INTO accounts (WeeklyCharge) VALUES ($total)"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } Try that. Link to comment https://forums.phpfreaks.com/topic/93548-help-with-insert-pls/#findComment-479359 Share on other sites More sharing options...
revraz Posted February 28, 2008 Share Posted February 28, 2008 Or $sql = "INSERT INTO accounts (WeeklyCharge) VALUES ('$total')"; Link to comment https://forums.phpfreaks.com/topic/93548-help-with-insert-pls/#findComment-479365 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.