PHP MySQL Insert Into query not working

user3613603

Anything wrong with this query?

sql = "INSERT INTO creditpurchasehistory (usercode, dollar_amount, payment_id, description, age, request_id, currency, time, currency_amount, quantity) VALUES (code360, 6.97, 4565425552154, Buy_Credits_For_Access, 347162, 7bd92f9489acbff04f80484d94c63282_9354, USD, 1376952971, 12.5, 1 )"

That is the echoed version of the query. The original sql statement was

mysqli_query($con,"INSERT INTO creditpurchasehistory (" . $Fieldnames . ") VALUES (" . $Fieldvalues . ")");

$Fieldnames is a variable containing the field names separated by commas and $Fieldvalues is for the values. I made sure the field names exists in the table. The problem is it's not inserting records into the table, the table is still empty. There's no error or anything, it just finished processing but no records were added to the table.

Funk Forty Niner

(To close the question and mark as solved)

You need to use quotes in some of your VALUES.

Some of the values you presently have are clearly text, so wrap those in quotes.

Add error reporting to the top of your file(s) when in production mode, which will help tremendously.

error_reporting(E_ALL);
ini_set('display_errors', 1);

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related