可捕获的致命错误:无法将类mysqli_stmt的对象转换为字符串 [英] Catchable fatal error: Object of class mysqli_stmt could not be converted to string

查看:74
本文介绍了可捕获的致命错误:无法将类mysqli_stmt的对象转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是PHP OOP的新手,所以这个问题一定很愚蠢. 我无法通过PHP创建SQL查询.我已经阅读了很多次代码,但是找不到任何差异,甚至编辑器也没有显示任何错误.我正在使用PHP 5.5.13,MYSQL 5.5.24和APCHE Server 2.2.22.

I'm new to PHP OOP so this question must be quite dumb. I'm unable to create an SQL query through PHP. I've read the code many times but I'm unable to find any discrepancy and even the editor isn't displaying any error. I'm using PHP 5.5.13, MYSQL 5.5.24 and 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;
?>

尝试运行此代码时,出现错误:

When trying to run this code, I'm receiving an error:

mysqli_stmt类的对象无法转换为字符串

Object of class mysqli_stmt could not be converted to string

当然,原始查询要比此处发布的查询大得多.由于发现问题出在SQL"SELECT"语句中,所以我编辑了查询的后半部分,但无法解决.请帮助我. 谢谢你.

Of course the original query is much larger than posted here. I've edited the later part of the query as I figured out that the problem resides within the SQL "SELECT" statement but I'm unable to figure it out. Kindly help me on this. Thank you.

推荐答案

您无法回应此问题

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 ;
  .....

这篇关于可捕获的致命错误:无法将类mysqli_stmt的对象转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆