• Resolved chab0tais

    (@chab0tais)


    Hello Eli,

    Thank you for your smart plugin, it is great.

    Unfortunately, I got the same problem you answer 7 month ago. I have read your answer and tried to impplement it :

    I think I found out why you are having this problem. WordPress automatically changes your content and replaces your single quotes with something they call smart quotes ??

    You will need to remove the filter for the wptexturize function before this shortcode will work with quotes in it. You’ll need to add this line of code to a PHP file where it can run in the init action hook:
    remove_filter (‘the_content’, ‘wptexturize’);

    If you can’t find a better place to put this code you can add it to my plugin inside the ELISQLREPORTS_init function on line 899 of elisqlreports/trunk/index.php

    The problem is clearly that : if I use a query with quote or double quote, sqlgetvar do not answer anything.
    But unfortunately, your suggestion to add remove_filter in index.php of your pluging, do not change anything…

    Do you have any other solution ? Or do you intend to implement a solution in your pluging, by changing back any character modification made by WP in sqlgetvar?
    Last thing : I use WP 4.6.1 with theme twenty fourteen.

    Thanks for your answer.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Eli

    (@scheeeli)

    I won’t ever put that particular fix in my plugin release because it’s only needed for a few users who have that problem and it’s a personalization that wouldn’t be right to inflict on everyone else who may not want the “smart quotes” feature disabled.

    I’m not sure why it’s not working for you though. maybe you have a different issue like unescaped quotes within your quotes. Can you post your shortcode so I can see what else might be wrong.

    Thread Starter chab0tais

    (@chab0tais)

    Here it is:

    Nombre d’inscrits actuel : [sqlgetvar]SELECT COUNT(*) FROM mod182_cb_frontend_data_table where form_id=2 and dynamic_control_id=6[/sqlgetvar]/150

    Open A : [sqlgetvar]
    SELECT COUNT(*) FROM mod182_cb_frontend_data_table WHERE form_id=2 AND dynamic_frontend_value LIKE ‘%A%’
    [/sqlgetvar]
    Open B : [sqlgetvar]
    SELECT COUNT(*) FROM mod182_cb_frontend_data_table WHERE form_id=2 AND dynamic_frontend_value LIKE “%B%”
    [/sqlgetvar]

    This code displays:

    Nombre d’inscrits actuel : 1/150

    Open A :
    Open B :

    The first query is working properly.
    The second and the third are not working with sqlgetvar, and they work fine on phpmyadmin. I tried also the syntax:

    dynamic_frontend_value=”Open B”

    or

    dynamic_frontend_value LIKE “Open B”

    that works on phpmyadmin, but not with sqlgetvar.
    If I suppress:

    AND dynamic_frontend_value LIKE ‘%A%’

    sqlgetvar returns a value (that is not what I want tot do, but that shows the problem comes probably from the incorrect encoding of quotes characters by WP).

    • This reply was modified 8 years, 1 month ago by chab0tais.
    • This reply was modified 8 years, 1 month ago by chab0tais.
    • This reply was modified 8 years, 1 month ago by chab0tais.
    Thread Starter chab0tais

    (@chab0tais)

    A last think : if I create a report qith the same query, it works properly. But I can’t insert the result into a text paragraph with [SQLREPORT name=”nbinscritsopena”]

    Plugin Author Eli

    (@scheeeli)

    Yes, I see, it doesn’t sound like my original hack worked for you. Where did you put that code I had posted?
    remove_filter ('the_content', 'wptexturize');

    Maybe it not in the right place so it is not affecting the filter. Also maybe there is another why you could encode those quotes, like using the HTML codes for single and double quotes or something.

    Thread Starter chab0tais

    (@chab0tais)

    I wrote it here :

    function ELISQLREPORTS_init() {
    remove_filter (‘the_content’, ‘wptexturize’);
    if (isset($GLOBALS[“ELISQLREPORTS”][“reports_array”]) && is_array($GLOBALS[“ELISQLREPORTS”][“reports_array”])) {
    $Report_Number = 0;
    if (isset($GLOBALS[“ELISQLREPORTS”][“settings_array”][“menu_sort”]) && $GLOBALS[“ELISQLREPORTS”][“settings_array”][“menu_sort”])

    khunglarsen

    (@khunglarsen)

    /*
    I was having the same problem, I resolved this by using the tag <tt></tt> this will override the wptexturize function..

    Text enclosed in the tags

    , `, <kbd>, <style>, <script>, and <tt> will be skipped. This list of tags can be changed with the 'no_texturize_tags' filter.
    
    Her is an example of they way I use it and notice the placement of <tt></tt>..
    
    <td style="text-align: center;"><tt>[sqlgetvar]SELECT COUNT(*) 
    FROM <code>wp_shwcp_leads_1` 
    WHERE creation_date 
    BETWEEN'2016-06-01' AND '2016-07-01' 
    AND l_status='2' AND l_source= '1' 
    AND owned_by= 'ULMS'[/sqlgetvar]</tt></td>
    */
    neworleansradio

    (@neworleansradio)

    khunglarsen, I used those tags and it did work for taking out the box formatting, but it only returned 1 record, instead of all records that meet the criteria. Does anyone happen to know how we get all of the records to show, like the reports do?

    Plugin Author Eli

    (@scheeeli)

    If your query starts with SELECT COUNT(*) FROM and you are not using GROUP BY then you will just have one row returned as a result.

    neworleansradio

    (@neworleansradio)

    Here is the sql code and tags

    <tt>[sqlgetvar]select distinct site_contents FROM history_today_birthday_use[/sqlgetvar]</tt>

    Plugin Author Eli

    (@scheeeli)

    oh, yes, sqlgetvar is designed to get only one value. If you don’t want the table format but you still want all the site_contents then try this:

    <tt>[sqlgetvar]select group_concat(distinct site_contents) FROM history_today_birthday_use GROUP BY site_contents[/sqlgetvar]</tt>

    Plugin Author Eli

    (@scheeeli)

    Ops, maybe just the first part:

    <tt>[sqlgetvar]select group_concat(distinct site_contents) FROM history_today_birthday_use[/sqlgetvar]</tt>

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘sqlgetvar does not return result – the return !’ is closed to new replies.