Solved

PG4WP is wrongly wrappling the SQL statement in the visitor maps plugin

Posted on 2014-02-02
1
492 Views
Last Modified: 2014-02-04
I have wordpress 3.8.1 with postgres, I have modified the php in visitors-maps.php for the create table part however for the rest of the queries (insert and update) the query is sent to the database with an additional keyword at the end, for example
The query in the visitors-maps.php looks:

        $query = "INSERT INTO " . $wo_table_wo . "
        (session_id,
        ip_address,
        user_id,
        name,
        country_name,
        country_code,
        city_name,
        state_name,
        state_code,
        latitude,
        longitude,
        last_page_url,
        http_referer,
        user_agent,
        hostname,
        time_entry,
        time_last_click,
        num_visits)
        values (
                '" . esc_sql($ip_address) . "',
                '" . esc_sql($ip_address) . "',
                '" . esc_sql($wo_user_id) . "',
                '" . esc_sql($name) . "',
                '" . esc_sql($country_name) . "',
                '" . esc_sql($country_code) . "',
                '" . esc_sql($city_name) . "',
                '" . esc_sql($state_name) . "',
                '" . esc_sql($state_code) . "',
                '" . esc_sql($latitude) . "',
                '" . esc_sql($longitude) . "',
                '" . esc_sql($last_page_url) . "',
                '" . esc_sql($http_referer) . "',
                '" . esc_sql($user_agent) . "',
                '" . esc_sql($hostname) . "',
                '" . esc_sql($current_time) . "',
                '" . esc_sql($current_time) . "',
                '1');";

Open in new window


But in the postgres log I can see it sent to the DB as:
STATEMENT:  INSERT INTO wp_visitor_maps_wo
               (session_id,
               ip_address,
               user_id,
               name,
               country_name,
               country_code,
               city_name,
               state_name,
               state_code,
               latitude,
               longitude,
               last_page_url,
               http_referer,
               user_agent,
               hostname,
               time_entry,
               time_last_click,
               num_visits)
               values (
                       '0.0.0.0',
                       '0.0.0.0',
                       '1',
                       'Me',
                       'Home',
                       'HO',
                       'CITY',
                       'AREA',
                       '00',
                       '0000',
                       '0000',
                       '/wp-admin/?loggedout=true',
                       'http://www.mydomain.com',
                       'Client',
                       'ISP',
                       '000',
                       '000',
                       '1'); VALUES

Open in new window


It has added the word VALUES at the end.

Also Query is in the visitors-maps.php looks:

 $wpdb->query("UPDATE " . $wo_table_st . "
  SET
  count = '" . absint($visitors_count) . "',
  time = '".$mysql_now."'
  WHERE (time !='".$mysql_now."' 
     OR count < '" . absint($visitors_count) . "') AND type = 'day';");

Open in new window


But in the postgres log I can see it sent to the DB as:

STATEMENT:  UPDATE wp_visitor_maps_st
         SET
         count = '0',
         time = '2014-02-02 12:47:50'
         WHERE (time !='2014-02-02 12:47:50'
            OR count < '0') AND type = 'day'; SET

Open in new window

It has added the word SET at the end.

Is there a way to correct this issue?
0
Comment
Question by:Ashraf Hassanein
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
Ashraf Hassanein earned 0 total points
ID: 39832292
PG4WP is not working properly if values is written in lower case and for the update all the command has to be written in one line.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question