dimanche 1 mars 2015

Query does not return results in wordpress, but running manually does

I have the following code in WordPress



$wpdb->show_errors();
$testQuery = $wpdb->prepare("SELECT * FROM $table_name
WHERE service_id = %d
AND token = %s" , $service_id, $token);
$testResult = $wpdb->get_results($testQuery,ARRAY_A);

echo "<pre>testQuery\n$testQuery\n";
echo "testResult: "; print_r($testResult);
echo "db error: . $wpdb->last_error;
echo "</pre>";


When I copy-paste the result printed in my echo to phpmyadmin and run the query, it shows results, however, when running the query within wordpress, my $testResult is an empty array. $wpdb->last_error does not print any error message.


Can anyone point me in the right direction?


Aucun commentaire:

Enregistrer un commentaire