0

I haven't really messed with $wpdb before, but I'm stuck hard on one part. I'm trying to get the values returned in an associative array.

I've tried both of these

$datarow = $wpdb->get_results("SELECT class_name FROM wp_wcs2_class WHERE id=$classnumber");
$datarow = $wpdb->get_results("SELECT class_name FROM wp_wcs2_class WHERE id=$classnumber",ARRAY_A);

but print_r $datarow; just errors out with Parse error: syntax error, unexpected T_VARIABLE

Any idea what's going wrong? I know the data is there because this returns the correct value:

$nameresult = $wpdb->get_var($wpdb->prepare("SELECT class_name FROM wp_wcs2_class WHERE id=$classnumber",ARRAY_A));
  • Please echo the query and check for the syntax. – Maruti Mohanty Dec 4 '13 at 10:08
1

It has nothing to do with $wpdb. It's PHP parse error.

print_r is a function, so you can't do print_r $datarow; You should use print_r( $datarow ); instead.

  • Lol, wow. A half hour, just to find out it's time for bed. Thanks mate! I'll mark it as answer in 7 mins when it lets me – KingRichard Dec 4 '13 at 9:56

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.