-4
我試圖爲我的項目創建一個註冊表單,但不幸的是我得到了這個錯誤,而我找不到代碼中的任何錯誤!請幫助我獲得從這個問題騎!可捕捉的致命錯誤:類mysqli的對象無法轉換爲字符串
我的代碼
<?php
// this file is connected with regform.php
$firstname= $_POST['firstname'];
$lastname =$_POST['lastname'];
$email =$_POST['email'];
$password =$_POST['password'];
$confirmpassword =$_POST['confirmpassword'];
$address =$_POST['address'];
$balance =$_POST['balance'];
$password_hash = md5($password);
$bookConn = mysqli_connect("localhost", "root","", "bookstore") OR die("wrong execution");
$queryS = "SELECT Email FROM customer";
$resultSQ = mysqli_query($bookConn , $queryS);
$flag=0;
while($row=mysqli_fetch_array($resultSQ))
{
if($email == $row['Email'])
{
$flag=1;
}
}
if($flag==0)
{
if($password == $confirmpassword)
{
$query = "INSERT INTO user (firstName , LastName ,Email , Password , Address , Balance)values('".$firstname."', '".$lastname."' ,'".$email."' , '".$password_hash."', '".$address."' , '".$balance."')";
$result = mysqli_query($bookConn , $query) OR die($bookConn);
if ($result)
{
echo "successfuly Registered";
}
else {
echo "something went wrong!";
}
}
else{
echo "Passowrd does not match!";
}
}
else{
echo "Email is already existed in the Database!";
}
mysqli_close($dbc);
?>
沒有代碼,調試是不可能的。請編輯您的帖子幷包含相關的代碼部分。 –
對不起,我只是添加了我的代碼! – ShKar
該問題可能是SQL錯誤。你正在調用'die($ bookConn)'。 'die'接受一個字符串參數,所以它試圖隱式地將'$ bookConn'轉換爲一個字符串。而且,這段代碼很不安全。 –