1
mysqli_query($con,"INSERT INTO u128337059_plod ('RequestID', 'Carrier', 'CellNumber', 'LoadAmount', 'ShortLog') VALUES ('', '', $payment_status, '', '')"); 

Can anyone help me figure out what's wrong with this query? I was able to debug and found out that connection to table works but inserting new records doesn't. No errors, just doesn't add new records.

Taryn
  • 242,637
  • 56
  • 362
  • 405
Jay
  • 590
  • 6
  • 13
  • 29

1 Answers1

3

The reason why your query won't work is because your are wrapping the column name and table name with single quotes. They are identifiers and not string literals so they shouldn't be wrap with single quote.

INSERT INTO u128337059_plod (RequestID, Carrier, CellNumber, LoadAmount, ShortLog)

If it happens that the column names and/or tables names used are reserved keywords, they can be escape with backticks not with single quotes.

In this case, the backticks aren't required since none of them are reserved keywords.

Other links:

Community
  • 1
  • 1
John Woo
  • 258,903
  • 69
  • 498
  • 492
  • Thanks JW. I just copied that from PHPMyAdmin so I thought I did the right thing. I'm updating my website now.:) – Jay Jun 24 '13 at 03:03
  • mysqli_query($con,"INSERT INTO u128337059_plod.PloadRequests (RequestID, Carrier, CellNumber, LoadAmount, ShortLog) VALUES ('', '$payment_status', '', '', '')"); The above code worked for me perfectly. I realized I should be removing the single quotes on column names but with the values to be inserted even if a variable (Like $payment_status) the single quotes must remain or else it will not add it's contents to the database. – Jay Jun 24 '13 at 04:11
  • I'm not sure why it's not recognizing my comment as a code lol! I did 4 spaces, but I guess you guys get it – Jay Jun 24 '13 at 04:15
  • can you post your code with comments? – John Woo Jun 24 '13 at 05:02
  • I mean my reply to you earlier had mysql querry in it but it got mixed up with the comment – Jay Jun 24 '13 at 07:49