<?php
if (isset($_POST['submit'])) {
$email = $_POST['email'];
$fname = $_POST['fname'];
$sname = $_POST['sname'];
$tellno = $_POST['tellno'];
$mobno = $_POST['mobno'];
$homeadd = $_POST['homeadd'];
$busadd = $_POST['busadd'];
echo "ok";
$select_details = mysql_query("select * from cont_info WHERE email='$email'");
$fetch_details = mysql_fetch_object($select_details);
$p_email = $fetch_details->email;
$p_fname = $fetch_details->fname;
$p_sname = $fetch_details->sname;
echo $p_email . $p_fname;
if ($select_details == TRUE) {
echo $email .'is associated with ' .$P_fname;
}else{
if ($email == ""){
echo " Enter email address";
}else {
mysql_query("insert into `cont_info` (fname, sname, email, tellno, mobno, homeadd, busadd) values ('$fname', '$sname', '$email', '$tellno', '$mobno', '$homeadd', '$busadd')");
}
}
}else { echo "enter all fields"; }
?>
错误讯息:
警告:mysql_fetch_object():提供的参数不是38行/var/www/html/reg/test.php中的有效MySQL结果资源
注意:尝试在第40行的/var/www/html/reg/test.php中获取非对象的属性
注意:尝试在第41行的/var/www/html/reg/test.php中获取非对象的属性
注意:尝试在第42行的/var/www/html/reg/test.php中获取非对象的属性
答案 0 :(得分:0)
将您的代码更改为下一个
<?php
if (isset($_POST['submit'])) {
$email = $_POST['email'];
$fname = $_POST['fname'];
$sname = $_POST['sname'];
$tellno = $_POST['tellno'];
$mobno = $_POST['mobno'];
$homeadd = $_POST['homeadd'];
$busadd = $_POST['busadd'];
echo "ok";
$select_details = mysql_query("select * from cont_info WHERE email='$email'");
if ($select_details === false) {
die('Invalid query: ' . mysql_error());
}
$fetch_details = mysql_fetch_object($select_details);
$p_email = $fetch_details->email;
$p_fname = $fetch_details->fname;
$p_sname = $fetch_details->sname;
echo $p_email . $p_fname;
if ($select_details == TRUE) {
echo $email .'is associated with ' .$P_fname;
}else{
if ($email == ""){
echo " Enter email address";
}else {
mysql_query("insert into `cont_info` (fname, sname, email, tellno, mobno, homeadd, busadd) values ('$fname', '$sname', '$email', '$tellno', '$mobno', '$homeadd', '$busadd')");
}
}
}else {
echo "enter all fields";
}
?>
因为mysql_query可以返回FALSE