Very strange. I can't see what's going wrong here. The connection to the MySQL database has been made but it won't INSERT from PHP. It's fine if I run the query in Phpmyadmin.
$rawquery = "
INSERT INTO $log_table_name
(ref, timestamp, txn_id, email, item_name, item_number, custom, mc_gross, mc_currency, paypal_message)
VALUES
(NULL, CURRENT_TIMESTAMP, '$txn_id', '$payer_email', '$item_name', '$item_number', '$custom', '$payment_amount', '$payment_currency', 'INVALID');
";
echo $rawquery;
$query = mysql_query($link, $rawquery) or die('Could not access table');
Produces:
INSERT INTO wp_ipn_log
(ref, timestamp, txn_id, email, item_name, item_number, custom, mc_gross, mc_currency, paypal_message)
VALUES
(NULL, CURRENT_TIMESTAMP, '', '', '', '', '', '', '', 'INVALID');Could not access table
I'm expecting the INVALID message, I just want it to be inserted into the database.
Is the problem the format of the query, or is there an issue with the database, or something else?
ADDITIONAL INFO (as requested by vinodadhikary):
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db(DB_NAME, $link) or die ("Could not open db ".mysql_error());
This is working fine.
mysqlto develop new code.mysqliisntead.mysqlioriginally but it didn't work so I triedmysqlinstead. Same results.mysql_error()/mysqli_error($link)to yourdie(). Also,mysql_queryismysql_query(query, link), wheremysqli_queryismysql_query(link, query). So it should be$query = mysql_query($rawquery,$link) or die(mysql_error());OR usingmysqli->$query = mysqli_query($link, $rawquery) or die(mysqli_error($link));