Help with strange database issue

[ad_1]

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.

[ad_2]
1 Comment

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer