我想了解为什么下面的脚本不起作用。不断获取错误:致命错误:函数wpdb::prepare()的参数太少,传递了1个。。。应为2。。。不知道我需要从哪里得到第二个论点。
<?php
$zoekvn = $_POST[\'zoekvn\']
if(isset($_POST[\'submit\'])):
try{
$result = $wpdb->get_results($wpdb->prepare("SELECT id, geslacht, voornaam, familienaam, email, tel, afile, app_datum FROM sollicitatie_form WHERE voornaam = $zoekvn"));
foreach ($result as $row){?>
<form>
<tr>
<td><?php echo "{$row -> id}"; ?></td>
<td><?php echo "{$row -> geslacht}"; ?></td>
<td><?php echo "{$row -> voornaam}"; ?></td>
<td><?php echo "{$row -> familienaam}"; ?></td>
<td><?php echo "{$row -> email}"; ?></td>
<td><?php echo "{$row -> tel }"; ?></td>
<td><a href="sollicitatie/uploads/<?php echo "{$row -> afile}" ?>" target="_blank">view file</a></td>
<td><?php echo "{$row -> app_datum}"; ?></td>
</tr>
</form>
<?php
}
}
// use exec() because no results are returned
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
endif;
?>
SO网友:WouterS
经过无数次尝试,我终于找到了它。。。
$result = $wpdb->get_results($wpdb->prepare("SELECT id, geslacht, voornaam, familienaam, email, tel, afile, app_datum FROM sollicitatie_form WHERE voornaam = %s", $zoekvn));
我想,当你自己找到解决方案时,你不太可能忘记它:-)