<?php
include 'connect.php';
$conn = mysqli_connect($host, $user, $pass, $db);
if (!$conn) {
die("KO" . mysqli_connect_error());
}
$id = $_GET['id'];
$sql = "select * from tblabc where id = '$id'";
if (mysqli_num_rows($sql)==0){
echo 'ok';
} else {
$data = mysqli_fetch_assoc($sql);
}
?>
这是我编辑表记录的代码。但是当它执行时发生错误“notice:Undefined index:id”。 如何解决这个问题。 THX
答案 0 :(得分:0)
import simpy
class Machine:
def __init__(self,env):
self.machine = simpy.Resource(env,capacity=1)
self.load_proc = env.process(self.load(env))
def load(self,env):
"Load machine 1 when it's empty"
while True:
print("Waiting for machine at %d" %env.now)
req = self.machine.request()
yield req
print("Load machine at %d" %env.now)
self.process_proc = env.process(self.process(env,req))
def process(self,env,req):
"Machine does process and is then emptied"
print("Machine starts process at %d" %env.now)
yield env.timeout(10)
print("Machine finished process at %d" %env.now)
self.machine.release(req)
print("Machine released at %d" %env.now)
env = simpy.Environment()
M1 = Machine(env)
env.run(until=100)
使用上面的代码在使用之前检查get变量的有效性。这样你就可以知道错误的来源。
答案 1 :(得分:0)
你应该试试这个
$id = '';
if(isset($_GET['id']) && $_GET['id'] != '')
{
$id = $_GET['id'];
$sql = "select * from tblabc where id = '$id'";
if (mysqli_num_rows($sql)==0){
echo 'ok';
} else {
$data = mysqli_fetch_assoc($sql);
}
}
else
{
echo 'Id Not Defined';
}