karenn1 Posted November 6, 2008 Share Posted November 6, 2008 Hey everyone, I have the following SQL statement that's giving me an error: $sql = "INSERT INTO $db.members (title, name, initials, address, house_number, area, notes, language, epd, bank, branch, account_no, cell_no, home_no, fax_no, work_no, email, username, password, authorization, active, membership_status, amount, id_number, leave, emergency, pay_method, pay_freq, month_fees, maid, gardener, cars, back_garden, house_number_missing, street_name_missing, street_lamp, services, security, monitor, membership, dogs, cancel_code, cancel_reason, member_type, patrol, contract, commence, bonus, general_comments, sign, security_no, emergency_name) VALUES ('".$_POST['title']."', '".$_POST['name']."', '".$_POST['initials']."', '".$_POST['address']."', '".$_POST['house_number']."', '".$result2['area']."', '".$_POST['notes']."', '".$_POST['language']."', '".$_POST['epd']."', '".$_POST['bank']."', '".$_POST['branch']."', '".$_POST['account_no']."', '".$_POST['cell_no']."', '".$_POST['home_no']."', '".$_POST['fax_no']."', '".$_POST['work_no']."', '".$_POST['email']."', '".$_POST['username']."', '".$_POST['password']."', '".$_POST['membership_status']."', '".$_POST['active']."', '".$_POST['membership_status']."', '".$_POST['amount']."', '".$_POST['id_number']."', '".$_POST['leave']."', '".$_POST['emergency']."', '".$_POST['pay_method']."', '".$_POST['pay_freq']."', '".$_POST['month_fees']."', '".$_POST['maid']."', '".$_POST['gardener']."', '".$_POST['cars']."', '".$_POST['back_garden']."', '".$_POST['house_number_missing']."', '".$_POST['street_name_missing']."', '".$_POST['street_lamp']."', '".$_POST['services']."', '".$_POST['security']."', '".$_POST['monitor']."', '".$_POST['membership']."', '".$_POST['dogs']."', '".$_POST['cancel_code']."', '".$_POST['cancel_reason']."', '".$_POST['member_type']."', '".$_POST['patrol']."', '".$_POST['contract']."', '".$_POST['commence']."', '".$_POST['bonus']."', '".$_POST['general_comments']."', '".$_POST['sign']."', '".$_POST['security_no']."', '".$_POST['emergency_name']."' )"; $result = mysql_query($sql); exit(header("location: success.php?type=client_add")); The error I get is the following: "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 'leave, emergency, pay_method, pay_freq, month_fees, maid, gardener, cars, back_g' at line 3" This is driving me bananas. I can't see where the problem is. All the fields match up with the values. Someone please help!!!? Thanks! Karen Quote Link to comment https://forums.phpfreaks.com/topic/131617-solved-sql-insert-statement-error/ Share on other sites More sharing options...
JasonLewis Posted November 6, 2008 Share Posted November 6, 2008 I think it may be because LEAVE is a reserved word or function in MySQL. Change the name of that field to something else. Quote Link to comment https://forums.phpfreaks.com/topic/131617-solved-sql-insert-statement-error/#findComment-683579 Share on other sites More sharing options...
karenn1 Posted November 6, 2008 Author Share Posted November 6, 2008 Hi ProjectFear, Thanks! I'll give that a try. It's just strange to me. It's been working fine for months now and all of a sudden today, it bombs out! I'll get back to you if I have any further problems. Karen Quote Link to comment https://forums.phpfreaks.com/topic/131617-solved-sql-insert-statement-error/#findComment-683612 Share on other sites More sharing options...
revraz Posted November 6, 2008 Share Posted November 6, 2008 Maybe they updated you to MySQL 5? Quote Link to comment https://forums.phpfreaks.com/topic/131617-solved-sql-insert-statement-error/#findComment-683646 Share on other sites More sharing options...
karenn1 Posted November 6, 2008 Author Share Posted November 6, 2008 Thanks guys! I've rename all the fields that my SQL manager highlighted. Now it works fine. I'll take it up with my service provider. I think they might have upgrated. Thanks again! Karenm Quote Link to comment https://forums.phpfreaks.com/topic/131617-solved-sql-insert-statement-error/#findComment-683655 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.