php里面无法使用insert into来插入数据库!
不管是$query="insertintocustomersvalues('','".$name."','".$address."','".$city."')";$res...
不管是
$query = "insert into customers values
('', '".$name."','".$address."','".$city."')";
$result = $conn->query($query);
还是
$sql="INSERT INTO custmmoers (customerid,name,address,city) VALUES ('',
'$name','$address','$city')";
$result=mysql_query($sql);
打印$result都没东西
还有以下这段文字是什么意思
$query = "select customerid from customers where
name = '".$name."' and address = '".$address."'
and city = '".$city."'";
$result = $conn->query($query);
//这里打印$result就打印出mysql_result object--------------
if($result->num_rows>0) {
$customer = $result->fetch_object();
$customerid = $customer->customerid;
} 展开
$query = "insert into customers values
('', '".$name."','".$address."','".$city."')";
$result = $conn->query($query);
还是
$sql="INSERT INTO custmmoers (customerid,name,address,city) VALUES ('',
'$name','$address','$city')";
$result=mysql_query($sql);
打印$result都没东西
还有以下这段文字是什么意思
$query = "select customerid from customers where
name = '".$name."' and address = '".$address."'
and city = '".$city."'";
$result = $conn->query($query);
//这里打印$result就打印出mysql_result object--------------
if($result->num_rows>0) {
$customer = $result->fetch_object();
$customerid = $customer->customerid;
} 展开
2个回答
展开全部
$result 插入操作的结果,应该返回false或者true,表示成功或者失败,
下面的select是从数据库中返回与指定的客户名字和地址和城市相符合和资料!
下面的select是从数据库中返回与指定的客户名字和地址和城市相符合和资料!
追问
直接打印$result,例如prinit_r($result),正常情况下会输出什么?
$query = "select customerid from customers where
name = '".$name."' and address = '".$address."'
and city = '".$city."'";
$result = $conn->query($query);
if($result->num_rows>0) {
$customer = $result->fetch_object();
$customerid = $customer->customerid;
}
这个if后面的意思能再详细地谢谢!
追答
var_dump($result); //看输出
if语句表示如果查询的结果不为空的话,就获取查询结果客户的ID
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询