I need to insert banner data into a table wp_rdp_banners. To work with the banner data I insert the full affiliate link and also split it to save the banner url and banner image location into separated fields.

Somehow there is no data inserted. Also get no error reports in debug.log file. When I print_r($POST) all seems okay. Correct amount of fields + data. But nothing is insert at all.

Does someone of you have an idea what I do wrong or forget in the code below?

<a href="https://mobico.nl/telefoon/?tt=26156_1144596_250041_&amp;r=" target="_blank" rel="nofollow"><img src="http://ti.tradetracker.net/?c=26156&amp;m=1144596&amp;a=250041&amp;r=&amp;t=html" width="300" height="250" border="0" alt="" /></a>

global $wpdb;
$fulllink = htmlspecialchars($aff_link);

$fulllink = stripslashes($fulllink) ;

preg_match_all('!https?://\S+!', $fulllink, $matches); 

$affUrl =$matches[0][0]; // URL link of the banner
$imgLink =$matches[0][1]; // img link from the banner st

$company_name = get_user_meta($customer_id,'company_name',true);

                'banner_type'   => $banner_type,            
                'customer_id'   => $customer_id,            
                'company_name'  => $company_name,
                'start_date'    => $start_date,
                'end_date'      => $end_date,
                'price'         => $price,
                'aff_link'      => htmlspecialchars($aff_link),
                'aff_customer'  => $aff_customer,                   
                'aff_url'       => $affUrl,
                'aff_target'    => $aff_target,
                'aff_rel'       => $aff_rel,
                'aff_img'       => $imgLink,
                'aff_img_width' => $aff_img_width,
                'aff_img_height'=> $aff_img_height,
                'aff_img_alt'   => $aff_img_alt,
                'banner_link'   => $banner_link,
                'picture'       => $picture     
             array( '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')
exit( var_dump(  $wpdb->prepare  ) );

result = NULL

  • Check this topic wordpress.stackexchange.com/questions/141627/… to see mysql errors. Did your $wpdb declared globally? Aug 24, 2017 at 17:36
  • yes see it at top of the code. Forget to paste it there.
    – jtermaat
    Aug 24, 2017 at 17:50
  • Have you tried to display wpdb errors? Aug 24, 2017 at 17:51
  • How do i do this. Tried this piece : exit( var_dump( $wpdb->last_query ) ); but get only string(39) "SHOW FULL COLUMNS FROM wp_rdp_banners"
    – jtermaat
    Aug 24, 2017 at 18:12
  • 2
    extract($_POST); is extremely dangerous, anybody can overwrite anything in the global namespace here, this is a super critical vulnerability. Don't use extract
    – Tom J Nowell
    Aug 24, 2017 at 19:52

1 Answer 1


I found the problem. Apparently with the new WP update if you try to insert into a VARCHAR column and the column length is less than what you are trying to insert it just won’t work. Prior to this update it will insert it but trim off the excess characters.

  • Thanks for your time and idea. Will try and test it. Project was already delivered.
    – Hermants
    Aug 9, 2018 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.