0

my sql query returns empty

$sql = $wpdb->get_results('SELECT * from table1 WHERE id = ' .$bransId);

And im sure that $bransId is not empty. ( i checked)

1
  • Did you define global $wpdb? Does the table1 exist? Does the id exist in that table? – Emetrop Jul 20 '15 at 22:01
0

If you can answer 'yes' to the questions in Emetrop's comment, then try:

$sql = $wpdb->get_results('SELECT * from table1 WHERE id = $bransId');
1
  • 1
    I'm afraid this won't work, since the variable isn't inside double quotes. Additionally we shouldn't trust the user input and use $wpdb->prepare(). – birgire Jul 21 '15 at 0:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.