(致命错误:在非对象上调用成员函数 bind_param()) [英] (Fatal error: Call to a member function bind_param() on a non-object)

查看:26
本文介绍了(致命错误:在非对象上调用成员函数 bind_param())的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此文本的错误:(对不起,我的英语不好,我来自德国!)

I get an error with this text:(sorry for my bad english I am from germany!)

错误:致命错误:在第 44 行的/users/ftf/www/ccache.php 中的非对象上调用成员函数 bind_param()

来自 ccache.php 的部分代码

A part of the Code from ccache.php

     // Neues Datenbank-Objekt erzeugen
    $db = @new mysqli( 'localhost', 'ftf', '***', 'ftf' );
    // Pruefen ob die Datenbankverbindung hergestellt werden konnte
    if (mysqli_connect_errno() == 0)
    {
        $sql = "INSERT INTO cache
('name', 'user', 'veroefentlichung', 'beschreibung', 'FTFcode', 'STFcode', 'TTFcode', 'type', 'lat', 'lon', 'address', 'link')
VALUES ('?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?')";
$eintrag = $db->stmt_init();
$eintrag = $db->prepare( $sql );

        $eintrag->bind_param($titel, $user, $datum, $desc, $FTF, $STF, $TTF, $type, $Lat, $Lon, $shortdesc, $genlink); // line 44

        $eintrag->execute();
        // Pruefen ob der Eintrag efolgreich war
        if ($eintrag->affected_rows == 1)
        {
            echo 'Der neue Eintrage wurde hinzugefügt.';
        }
        else
        {
            echo 'Der Eintrag konnte nicht hinzugefügt werden.';
        }
    }

推荐答案

  $eintrag->bind_param($titel, $user, $datum, $desc, $FTF, $STF, $TTF, $type, $Lat, $Lon,       $shortdesc, $genlink); // line 44

你需要这样定义参数的类型:

You need to the define the type of parameters as this:

$eintrag->bind_param("ssssssiiss", $titel, $user, $datum, $desc, $FTF, $STF, $TTF, $type, $Lat, $Lon, $shortdesc, $genlink); // line 44

s - 字符串我 - 整数还要检查文档:http://php.net/manual/en/mysqli-stmt.bind-param.php

s - string i - int Also check documentation: http://php.net/manual/en/mysqli-stmt.bind-param.php

这篇关于(致命错误:在非对象上调用成员函数 bind_param())的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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