louma333
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: $wpdb->insert – Not workingbcworkz strangely enough, i actually solved this issue by… sending the data of the form to the database of my other wordpress website. So i can’t event understand why it didn’t work on his own database but it surely work perfectly in the database of my other website
Forum: Developing with WordPress
In reply to: $wpdb->insert – Not workingbcworkz i tried to insert the data through my form to another working database tied to another plugin and it didn’t work. I had exactly the same issue. Everything seems to work, but nothing is inserted.
Now i’m trying to create a database table though the activation of my plugin so i could try to insert data in it, but it doesn’t work. And again, same problem, i don’t have error, it just doesn’t create the table :register_activation_hook(__FILE__, 'creer_table_reponses'); function creer_table_reponses() { try { error_log('La fonction creer_table_reponses est appelée'); global $wpdb; $wpdb->show_errors(); if(is_null($wpdb)) { error_log('Objet global $wpdb non disponible'); return; } error_log('Objet global $wpdb chargé'); $charset_collate = $wpdb->get_charset_collate(); $table_majeurs = 'wp_inscriptions_majeurs'; $table_mineurs = 'wp_inscriptions_mineurs'; $sql_majeurs = "CREATE TABLE {$table_majeurs} ( id mediumint(9) NOT NULL AUTO_INCREMENT, nom text NOT NULL, prenom text NOT NULL, adresse text NOT NULL, PRIMARY KEY (id) ) {$charset_collate} ENGINE=InnoDB;"; $sql_mineurs = "CREATE TABLE {$table_mineurs} ( id mediumint(9) NOT NULL AUTO_INCREMENT, nom text NOT NULL, prenom text NOT NULL, adresse text NOT NULL, PRIMARY KEY (id) ) {$charset_collate} ENGINE=InnoDB;"; $error = $wpdb->print_error(); if (!empty($error)) { error_log($error); } error_log('Requêtes SQL créées'); require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); error_log('Fichier upgrade.php inclus'); dbDelta($sql_majeurs); error_log('Requête SQL pour table majeurs exécutée'); dbDelta($sql_mineurs); error_log('Requête SQL pour table mineurs exécutée'); error_log('La fonction creer_table_reponses a terminé avec succès'); } catch (Exception $e) { error_log('Erreur lors de la création des tables : ' . $e->getMessage()); } }
In my error_log i have everything except the catch (Exception $e) sentence. Meaning everything is currently working but nothing is added. I’m going insane lol. I already checked if the database was the right one connected to my wordpress and it is. So why does it say it is adding data but doesn’t ?
Also : I finally managed to find where i could see the prilivedge of the user i’m connected with (so basically the wp user, since that’s the user in wp-config), and it says : No priviledge.
But then how is it possible that my other plugin can add data to the database through wordpress ?- This reply was modified 1 year, 5 months ago by louma333.
Forum: Developing with WordPress
In reply to: $wpdb->insert – Not workingbcworkz i’ll test something right away, i’ll try to insert my data in another plugin database just to see if it can be added here. If so, then you are prolly right and we know what to do.
I’ll be back with result soon
Forum: Developing with WordPress
In reply to: $wpdb->insert – Not workingbcworkz > Thanks for your reply.
I’m currently contacting my host to see what i can get from them.One thing i don’t get is, why would my other plugins work with the database and not the one i did code personally ? I mean there are other plugin on my wp website that i did install from internet. Those plugins insert data in the data base. So why those plugin work but when i do it myself it doesnt ?
If anything those plugin working are the proof that my wp have the priviledge to insert data, right ?For the table, i did create via mysql directly in the phpmyadmin. Is it bad ? I did it like that :
CREATE TABLE wp_inscriptions_majeurs ( id INT AUTO_INCREMENT PRIMARY KEY, FirstName VARCHAR(255) NOT NULL, LastName VARCHAR(255), Adress VARCHAR(255) )
Forum: Developing with WordPress
In reply to: $wpdb->insert – Not workingbcworkz >
To be fair, i don’t know too much. I connect myself to phpmyadmin using the logs that are in my wp_config. And i since i coded this php code as a plugin, by default, i think the code is ran with the same user defined in wp_config right ? I mean the user that is defined there is supposed to be the one using the database through wordpress. So i don’t understand how it could be different.
If it’s really about priviledge, i suppose i have to contact my host ? Since the database is provided by the hosting service it’s about them right ?
Thanks again for your help
Forum: Developing with WordPress
In reply to: $wpdb->insert – Not workingHello to both of you.
Thanks for your help.To Aminul >
As you can see at the start of the code i already check my database and table name. Both are perfectly exact.
You asked me if i established the proper connection, but my code is in a plugin activated, so the connection to the database should normally be done automatically.
When you ask me if i included the wordpress files to do it i’m confuse as i dont think i need to include anything else, and if so, what are those files ?
For the fieldName and the data, i already checked everything here and everything is exactly right.To bcworkz >
When im in my phpmyadmin, i can find no option, window or table related to priviledge.
I know my acc username, and know my acc password. They are in the wp_config and i easly acess to the database. But there is nothing related to database priledge here. I don’t know why and if it’s normal.
When i work on my localhost phpmyadmin, i always have all those option but in my wordpress database i don’t have it.
However : If i do the mysql request to insert data into the database it actually work. I can’t insert data through my php code since the data doesn’t appear. But if i do a mysql code directly on my database and insert data in my table it 100% work.Do you have an idea of what it could be ?