php – Catchable致命错误:类mysqli_stmt的对象无法转换为字符串

前端之家收集整理的这篇文章主要介绍了php – Catchable致命错误:类mysqli_stmt的对象无法转换为字符串前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我是 PHP OOP的新手,所以这个问题一定很愚蠢.
我无法通过PHP创建SQL查询.我已多次阅读代码,但我无法找到任何差异,甚至编辑器也没有显示任何错误.我使用的是PHP 5.5.13,MysqL 5.5.24和APCHE Server 2.2.22.

以下是代码

Test_signup.PHP

<!DOCTYPE HTML>
    <html>
        <head>
            <title>
            Test Sign Up
            </title>
        </head>
        <body>
                <form action = "Signup.PHP" method = "POST" name = "test_signup">
                Full Name: <input type = "text" name = 'full_name'>
                User Name: <input type = 'text' name = 'user_name'>
                Email: <input type = 'text' name = 'email_add'>
                <input type = "submit" name = "submit">
            </form>

        </body>
    </html>

现在来到Signup.PHP

<?PHP
$con = new MysqLi('localhost','root','','my_database');
      if ($con->connect_error)
      {
        echo 'Failed to connect' . $con->connect_error;
      }
      else
      {
        echo 'Connected';
        $stmt_chk_email = $con->prepare('SELECT * FROM `user_information` WHERE `Email` = ?');
        $stmt_chk_email->bind_param('s',$_POST['email_add']);
        echo $stmt_chk_email;
?>

尝试运行此代码时,我收到一个错误

Object of class MysqLi_stmt could not be converted to string

当然原始查询比这里发布的要大得多.我已经编辑了查询的后半部分,因为我发现问题存在于sql“SELECT”语句中,但我无法弄明白.请帮助我.
谢谢.

你不能回应这个

echo $stmt_chk_email;

你可能想要回应这个

$stmt_chk_email = $con->prepare('SELECT column1,column2,... FROM `user_information` WHERE `Email` = ?');
     $stmt_chk_email->execute();
     $stmt_chk_email->store_result();
     $stmt_chk_email->bind_result($column1,$column2,.....);
     $stmt_chk_email->fetch();
  echo $column1;
  echo $column2 ;
  .....
原文链接:https://www.f2er.com/php/138737.html

猜你在找的PHP相关文章