Jump to content

INSERT INTO won't work


Nuv

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
Share on other sites

 

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

its better to do it with them than without, cuz lets face it, you wouldnt have posted this thread if ya had  :P

 

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

 

Link to comment
Share on other sites

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.