I have a database with a few thousands keyword fields that have 10 space delimited keywords. I would like to explode them into an array and save the parts into individual fields within the database. I know I need to normalize the database and upgrade to mysqli, but that’s not important yet. I’m new at this, and I can’t figure out what is wrong with my code. For instance, after assigning the portions of the array to strings, I can echo the strings, but I can’t save those strings to my database.
You are probably getting array key doesn’t exist or undefined index error if less that ten words are searched for or defined. Check for the KEY when setting variable.
I tested sending less than 10 keywords as well as 10 keywords, and both behaved the same … a new empty row in the table. So I deleted the table and made it again using PHPMyAdmin. Same behavior.
So I again deleted the table and instead used a PHP create table function, and now the saving array bit works. I don’t know what setting I had wrong when I created the table in PHPMyAdmin, but it wouldn’t allow anything to be saved. Now it saves to the keyword slots, and anything fewer than ten remains empty.
Not sure what the problem was. I created the original table via PHPMyAdmin. I deleted and recreated the table, and when it still didn’t work, I deleted the table but recreated it using a PHP / MySQL script. The code is now saving to the database as desired. I’m unsure why the PHPMyAdmin table wouldn’t allow entries, but this newly created table does. Thanks!