Hello friends,
I did a form and through a plugin i coded in php, i’d like to insert the result of this form into my wordpress database. But i run into a problem cause nothing is inserted in my database despite the log not pointing any error. My log tell me the insertion was sucessfull. However, my table is empty.
This is my php code that is supposed to insert it :
echo “<pre>”;
echo “Table name is :” . $table_name;
echo “</pre>”;
// Create an array with the reply
$reply= array(); $champs = [‘FirstName’, ‘LastName’, ‘Adress’];
foreach ($champs as $champ) { if (!empty($_POST[$champ])) { $reply[$champ] = sanitize_text_field($_POST[$champ]); } } $result = $wpdb->insert($table_name, $reply);
if ($result === false)
{ echo “Error : ” . $wpdb->last_error; }
else {echo “Data insertion was sucessfull”; }
echo “<pre>”;
print_r($wpdb->last_query);
echo “</pre>”;
echo “<pre>”;
echo $wpdb->last_error;
echo “</pre>”; } }
So what i get as result of all thoses echos is :
The correct name of my table which is : wp_inscriptions_majeurs
Then :
Data insertion was sucessfull
Then for print\_r($wpdb->last\_query) :
INSERT INTO wp_inscriptions_majeurs (FirstName, LastName, Adress) VALUES (‘Test’, ‘Test’, ’21 Boulevard de Larramet’)
My echo $wpdb->last\_error return an empty bloc. There is literally no error.
Can someone help me on this ?
It’s drive me crazy. When i go into my phpmyadmin and i do the same insertion through mysql everything work perfectly fine. I don’t know what to do anymore and im in a rush.

What does printing $result get you?