Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I can't give you an <em>exact</em> solution, because I'm not sure if the value returned by <code>$_REQUEST['fb_friend_uid']</code> is a PHP array printed using <code>json_encode()</code>, or the value is actually a json string.</p> <p>In either case, where is an example which makes use of both circumstances, so use whichever one makes sense in your scenario:</p> <p><b>If PHP Array:</b></p> <p>Assumes PHP Array has a format similar to:</p> <p>array('returned_val' => array('47483647', '47483647', '47483647', '665414807', '263901486', '665414807', '665414807', '665414807'));</p> <pre><code>&lt;?php $original_arr = $_REQUEST['fb_friend_uid']['returned_val']; </code></pre> <p><b>If JSON String:</b></p> <p>Assumes the JSON String has a format similar to:</p> <p>{"returned_val":["47483647","47483647","47483647","665414807","263901486","665414807","665414807","665414807"]}</p> <pre><code>&lt;?php $json_arr = json_decode($_REQUEST['fb_friend_uid'], True); $original_arr = $json_arr['returned_val']; </code></pre> <p><b>Then, use this code:</b></p> <pre><code>&lt;?php // Extract only whole number values, omit anything which is not a 0-9 character. $filtered_arr = array_filter($original_arr, 'ctype_digit'); // Escape values to remove possibility of SQL injection. $filtered_arr = array_map('mysql_real_escape_string', $filtered_arr); // Convert the array to a string $string_arr = "'" . implode("','", $filtered_arr) . "'"; // Perform SQL Query mysql_query("SELECT * FROM vote WHERE vote_fb_uid IN ($string_arr)"); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload