Nuv Posted May 8, 2011 Share Posted May 8, 2011 I don't understand why won't my INSERT work. Nothing gets inputted to the database.Why ? Code $sql = "INSERT INTO payout (member_id, binary, tds, service, total, dues, amount_paid) VALUES ('".$memid."', '".$binary."', '".$tds."', '".$service."', '".$total."', '".$dues."', '".$amount_paid."')"; $execsql = mysql_query($sql); SQL table CREATE TABLE IF NOT EXISTS `payout` ( `member_id` int( NOT NULL, `binary` int(10) NOT NULL, `tds` decimal(7,2) NOT NULL, `service` decimal(7,2) NOT NULL, `total` int(10) NOT NULL, `dues` int(10) NOT NULL, `amount_paid` int(10) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; Quote Link to comment https://forums.phpfreaks.com/topic/235868-insert-into-wont-work/ Share on other sites More sharing options...
Zane Posted May 8, 2011 Share Posted May 8, 2011 I don't understand why won't my INSERT work. Nothing gets inputted to the database.Why ? This is exactly why PHP.net created the mysql_error function... and you can either use die to show it or just echo it out. $execsql = mysql_query($sql) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/235868-insert-into-wont-work/#findComment-1212469 Share on other sites More sharing options...
spiderwell Posted May 8, 2011 Share Posted May 8, 2011 echo out the sql statement in the php script to see acopy of exactly what it is that the insert is actually tryin to insert. that should help a lot Quote Link to comment https://forums.phpfreaks.com/topic/235868-insert-into-wont-work/#findComment-1212470 Share on other sites More sharing options...
Nuv Posted May 8, 2011 Author Share Posted May 8, 2011 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 'binary, tds, service, total, dues, amount_paid) VALUES ('1000000', '200', '10.6'' at line 1 Echo of sql statement INSERT INTO payout (member_id, binary, tds, service, total, dues, amount_paid) VALUES ('1000000', '200', '10.6', '20.4', '170', '0', '170') Quote Link to comment https://forums.phpfreaks.com/topic/235868-insert-into-wont-work/#findComment-1212472 Share on other sites More sharing options...
Zane Posted May 8, 2011 Share Posted May 8, 2011 perhaps one of your field names are reserved words. Try surrounding them in backticks INSERT INTO payout (`member_id`, `binary`, `tds`, `service`, `total`, `dues`, `amount_paid`) VALUES ('1000000', '200', '10.6', '20.4', '170', '0', '170') Quote Link to comment https://forums.phpfreaks.com/topic/235868-insert-into-wont-work/#findComment-1212480 Share on other sites More sharing options...
Nuv Posted May 8, 2011 Author Share Posted May 8, 2011 Wow Thankyou.That worked. Many of my sql statements arent working. Can i use ` in everyone of them ? Quote Link to comment https://forums.phpfreaks.com/topic/235868-insert-into-wont-work/#findComment-1212486 Share on other sites More sharing options...
spiderwell Posted May 8, 2011 Share Posted May 8, 2011 its better to do it with them than without, cuz lets face it, you wouldnt have posted this thread if ya had backticks for table names and column names, and single quotes for the data, then you won't fall over with column names that are reserved words Quote Link to comment https://forums.phpfreaks.com/topic/235868-insert-into-wont-work/#findComment-1212497 Share on other sites More sharing options...
Nuv Posted May 8, 2011 Author Share Posted May 8, 2011 Ah alright. Thankyou Quote Link to comment https://forums.phpfreaks.com/topic/235868-insert-into-wont-work/#findComment-1212503 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.