Jump to content

Recommended Posts

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;

 

Link to comment
https://forums.phpfreaks.com/topic/235868-insert-into-wont-work/
Share on other sites

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());

 

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')

 

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')

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.