search

Home  >  Q&A  >  body text

Wordpress queries the database get_var for non-existent records and reports a fatal error. How to set it to only return null without reporting an error?

// $rs = $wpdb->get_var($wpdb->prepare("SELECT * FROM $table WHERE number = $number"));

$rs = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table "));

报下面的错

Fatal error: Uncaught Error: Call to a member function get_var() on null in D:\phpStudy22\WWW\wordpress5.9\wp-content\themes\lsm2022\from.php:23 Stack trace: #0 {main} thrown in D:\phpStudy22\WWW\wordpress5.9\wp-content\themes\lsm2022\from.php on line 23

一直走一直走1038 days ago877

reply all(0)I'll reply

No reply
  • Cancelreply