Skip to:
Content
Pages
Categories
Search
Top
Bottom

have problem with SEND TO box


  • Riolec
    Participant

    @riolec

    I compose a message to a friend … the problem is when I write the Name at SEND TO box, some message shown below my friend’s name

    WordPress Database error you have an errorin your SQL syntax; check the manual that correstponds to your MySQL server version for the right syntax to use near ‘) AND initiator_user_id) OR (initiator_user_id IN () AND friend_user_id = 1)’ at line 1 for query SELECT count(id) FROM wp_bp_friends WHERE (friend_user_id IN () AND initiator_user_id = 1) OR (initiator_user_id IN () AND friend_user_id = 1) made by friend_search_friends, BP_friends_friendship->search_friends

    how can i fix it? Does anybody could help me?

Viewing 7 replies - 1 through 7 (of 7 total)

  • John James Jacoby
    Keymaster

    @johnjamesjacoby

    Looks to me like the file bp-friends-classes.php asks for $filtered_fids in the SQL query inside the search_friends function, but it isn’t a global variable and isn’t declared in the function…

    $total_friends = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->friends->table_name} WHERE (friend_user_id IN ($filtered_fids) AND initiator_user_id = %d) OR (initiator_user_id IN ($filtered_fids) AND friend_user_id = %d)", $user_id, $user_id ) );

    It is however used in the search_users function on apx line 221.

    $filtered_fids = $wpdb->get_col($sql);

    I might be missing something, but if this isn’t in the trac it might be a bug…

    Do you know what version of PHP your website is hosted on? And what version of MySQL your database uses? Approximate versions are fine, 4.x, 5.x, etc… If you are unsure, the name of your host might be enough also. I’ve tried to duplicate the bug searching for quotes and weird characters on my test site but couldn’t break it myself…

    Curious also what is the username of the friend you’re sending the message to? Does it happen with all user names you try to compose a message to?


    Riolec
    Participant

    @riolec

    johnjamesjacoby, thanks for your concern,

    I use PHP 5 and MySQL 5 for my database and yes .. it does happen with all user names i try to compose. I don’t know why … all functions run well thou

    i give you the screen shot at this link: http://kiomino.com/screenshot.jpg

    thank you for help


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    How comfortable are you editing a file to help me test?

    I have no way right now to validate if this is a fix for anything, but it hasn’t broken anything for me yet. :)

    open mu-plugins/bp-friends/bp-friends-classes.php

    Near line 157…

    ABOVE

    $filtered_friends = $wpdb->get_results( $sql, ARRAY_A );

    INSERT

    $filtered_fids = $wpdb->get_col($sql);

    Upload and replace. Try again and let me know what happens. Be prepared for it to break something, just in case. :)


    In the same file, same area, a better solution MIGHT be to…

    FIND

    $total_friends = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->friends->table_name} WHERE (friend_user_id IN ($filtered_fids) AND initiator_user_id = %d) OR (initiator_user_id IN ($filtered_fids) AND friend_user_id = %d)", $user_id, $user_id ) );

    REPLACE WITH

    $total_friends = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->friends->table_name} WHERE (friend_user_id IN ($filtered_friends) AND initiator_user_id = %d) OR (initiator_user_id IN ($filtered_friends) AND friend_user_id = %d)", $user_id, $user_id ) );

    Since $filtered_friends is an array, it seems to work that way also.

    Try both ways, let me know what results you achieve?


    Riolec
    Participant

    @riolec

    Thank you johnjamesjacoby,

    have try both way … the message still shown .. both this time is shorter than before:

    WordPress database error Unknown column ‘Array’ in ‘where clause’ for query SELECT count(id) FROM wp_bp_friends WHERE (friend_user_id IN (Array) AND initiator_user_id = 1) OR (initiator_user_id IN (Array) AND friend_user_id = 1) made by friend_search_friends, BP_friends_friendship->search_friends

    is their any other way to solve this problem?


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Riolec, I’m heading to bed at the moment (yes, I do sleep occasionally) but if no one has solved this with you by the time I make it back, I’ll continue where we are leaving off.

    I think I have an idea of what to try next, but I’d like to test it before I make you chase down any more code.


    Riolec
    Participant

    @riolec

    ok … thank you …


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Lets try this in the same area…

    // Get the total number of friendships
    $total_friends = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {". $bp->friends->table_name ."} WHERE (friend_user_id IN (". $filtered_friends .") AND initiator_user_id = %d) OR (initiator_user_id IN (". $filtered_friends .") AND friend_user_id = %d)", $user_id, $user_id ) );

    I should also ask if you’re using any custom or particular plugins or modifications to your website, even in your functions.php. Just trying to rule everything out if we can.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘have problem with SEND TO box’ is closed to new replies.
Skip to toolbar