开发者

$wpdb insert big problem, very weird

I use $wpdb to insert some rows with information in a specific table... Everything works fine until I add some img tags without a value (a picture), in the theme, or post.

Eample: <img src="">

I think that this refreshes (the browser tries to find the image and opens the html file again..) the page and recalls insert options that duplicates the rows in the table.

In Chrome the row is duplicated 3 times, in Firefox 2 times and in Opera, IE works fine, how to fix it and how to prevent duplicate/multiple inserts?

For inserting I use this code:

$data_array = array('aff_id' => $aff_id, 'remote_addr' => $remoteaddress, 'url' => $curentpage, 'referrer' => $httpreferer);
    $wpdb->insert( 'amember_aff_clicks', $data_array );

it connects to an external 开发者_Go百科$table but the same database.


escape your values: $remoteaddress = $wpdb->escape($remoteaddress));. Better yet use $wpdb->prepare();

look here for a quick example and read the $wpdb class reference

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜