Solved

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

Posted on 2014-02-02
1
452 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
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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

WordPress can be pretty daunting, especially for a beginner, so I thought it might be a good idea to write an article to show how easy it is to get started in WordPress and to design a custom theme.  The first step is to check with your hosting comp…
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…

930 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now