由于某种原因,我的SQL命令显然没有正常运行。当这个叫做:
$title = $_POST['event_title'];
$title = mb_convert_encoding($title, "HTML-ENTITIES", 'UTF-8');
$event_id = $db->query("SELECT event_id FROM events WHERE event_title = '{$title}'")->fetch_object()->event_id;
我得到0结果,但我知道我应该得到一个。我已经回答了SELECT event_id FROM events WHERE event_title = 'Improving young people’s health'
的查询,这正是我想要的。如果我打开PHPMyAdmin并复制粘贴该查询,我会按预期返回一行,但出于某种原因,当我在query()
上调用$db
时,它没有返回