wpdb Insert unknown post data dynamic foreach loop
wpdb Insert unknown post data dynamic foreach loop
wpdb Insert unknown post data dynamic foreach loop
MySQL ‘duplicate entry’ error
This is an incorrect use of prepare, that function is used to safely insert variables into queries. However the code in your question does this beforehand, bypassing the security function. E.g. What you did: $unsafesql = “INSERT $dangerousvariable”; $still_unsafe_sql = $wpdb->prepare( $sql, ” ); What it should be: $safe_sql = $wpdb->prepare( “INSERT %s”, $dangerousvariable );
Use the sanitize field sanitize_text_field($_POST[‘c_name’]); more info https://developer.wordpress.org/reference/functions/sanitize_text_field/
I have been trying to return a $wpdb->insert_id; but unfortunately, it is returning null; That’s not true, you haven’t been returning $wpdb->insert_id at all. // insert $toevoegen = $wpdb->insert( … ); $lastinsertid = $toevoegen->insert_id; You’ve been returning $toevoegen->insert_id, which is wrong. According to the docs $wpdb->insert will return either false or it will return the … Read more
Passing a SQL query to the WP Query
duplicated posts when using pagination
How to display specific data from a custom table to logged in users with a custom role
WordPress SQL Prepare
How do I get specific readable results from this query and array results