I’ve pieced together some code I’ve gleaned from the internet: I’m trying to scan a directory to insert file names and index into MariaDB table. My last hurdle it seems is this PDO error: PDO::exec() …
Tag: sql-insert
Inserting data into a table using foreign keys in MySQL
I am trying to insert data into a contacts table using foreign keys in mysql, the structure of tables are as follows CONTACTS TABLE id contactname phone_number fk_id USERS TABLE pers_id …
ON DUPLICATE KEY UPDATE in oracle or equiv (defining key/column?)
I have the below working insert statement, where I am essentially mapping the column data from an uploaded .csv file through a loop into my VALUES variables below… All worked fine, except now I am just trying to add a tweak INSERT or UPDATE – if ‘app_id’ first column, value is found in the uploaded .csv, i.e. duplicate is found
NEWID function causing error for prepared statement in MYSQL
I am trying to create a forgot password system, so I am using the NEWID() function to create a random code to be sent to the user’s email. I am using prepared statements to prevent SQL injections, but …
How to avoid code repetition with PHP SQL prepared statements?
In most examples of SQL PHP prepared statements that I see, such as: the field names are nearly repeated … 4 times! once after the INSERT INTO(…): task_name (column name in SQL) once after the VALUES(…): :task_name once in the dictionary key: :task_name once in the dictionary value: $taskName (local variable) I understand that each of these have a different
Loop two arrays and access one-at-a-time from first array and three-at-a-time from the second array
I have two sets of data which are in two different arrays and I need to combine them in groups then insert the results into my database. In above I have two set of data.$arr contains the name and $code contains a numeric code. Here I need to insert the code per name into the table as per the user
MySQL and PHP – insert NULL rather than empty string
I have a MySQL statement that inserts some variables into the database. I recently added 2 fields which are optional ($intLat, $intLng). Right now, if these values are not entered I pass along an empty string as a value. How do I pass an explicit NULL value to MySQL (if empty)? Answer To pass a NULL to MySQL, you do