我有一个简单的PHP脚本连接到数据库,其表单将根据用户选择生成结果。我有一个嵌入wordpress页面的表单,一切正常,直到我对wordoress进行了更新。 我认为数据库和php脚本很好,但表单本身不再加载值,请你帮我确保我的ui表单代码是正确的,以便加载正确的值: 这是device.php文件:
<?php
$mysqli = new mysqli("xxx", "xxx", "xxx", "xxx");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: " . $mysqli->connect_error;
}
if (islet($_GET['devices'])) {
$devices = $mysqli->query("SELECT * FROM devices");
while ($device = $devices->fetch_assoc()) {
echo "<option value='{$device['id']}'>{$device['device']}</option>";
}
}
if (isset($_GET['get_device'])) {
$device = $_GET['device'];
$models = $mysqli->query("SELECT * FROM models WHERE device = " . $device . " GROUP BY model ORDER BY device DESC");
while ($model = $models->fetch_assoc()) {
echo "<option value='{$model['model']}'>{$model['model']}</option>";
}
}
if (isset($_GET['get_ios'])) {
$device = $_GET['device'];
$model = $_GET['model'];
$sql = "SELECT ios FROM models WHERE device = {$device} AND model = '{$model}'";
$o_ios = $mysqli->query($sql);
while ($ios = $o_ios->fetch_assoc()) {
echo "<option value='{$ios['ios']}'>{$ios['ios']}</option>";
}
}
if (isset($_GET['get_result'])) {
$device = $_GET['device'];
$model = $_GET['model'];
$ios = $_GET['ios'];
$sql = "SELECT url FROM models WHERE device = {$device} AND model = '{$model}' AND ios = '{$ios}' LIMIT 1";
$o_url = $mysqli->query($sql);
while ($url = $o_url->fetch_assoc()) {
if ($url['url'] == 0) {
echo "<p style='text-align: center' class='error'><b>Not Available</b><br />
Sorry, currently Jailbreak is not available for your device. To stay updated please subscribe to our Newsletters,<br /> by entering your email in the box below:</p>";
} else {
$sql1 = "SELECT url FROM urls WHERE id = {$url['url']}";
$o_row = $mysqli->query($sql1);
$row = $o_row->fetch_assoc();
echo "<p style='text-align: center' class='success'><b>Available</b><br />
Congratulations, Jailbreak is available for your device. To Jailbreak your device now, please click on the following link:<br />
<a target='_blank' href='{$row['url']}'>Jailbreak {$model} {$ios}</a></p>";
}
}
}
这是表单代码:
<div class="container_12">
<h4>To Jailbreak your device and download cydia, please select your device model, and iOS version then click Jailbreak:</h4>
<form id="form-wizard" action="devices.php">
<div class="grid_4">
<div style="padding: 20px; font-weight: bold;"><label for="idevice">iDevice:</label>
<select id="idevice" name="idevice">
<option value="0">---</option>
</select></div>
</div>
<div class="grid_4">
<div style="padding: 20px; font-weight: bold;"><label for="model">Model:</label>
<select id="model" name="model">
<option value="0">---</option>
</select></div>
</div>
<div class="grid_4">
<div style="padding: 20px; font-weight: bold;"><label for="ios">iOS:</label>
<select id="ios" name="ios">
<option value="0">---</option>
</select></div>
</div>
<class='clear'>
<p style="text-align: center;"><input type="hidden" value="submitted" />
<input type="submit" value="Jailbreak" /></p>
</form>
<p id="message-result"></p>
</div>
,这是错误日志中的错误: PHP致命错误:在第9行的devices.php中的非对象上调用成员函数fetch_assoc()