身份不明的财产;试图获取非对象的属性

发布于 2024-12-02 17:34:09 字数 2472 浏览 0 评论 0原文

这是我尝试运行它时经常看到的内容!

嗨。我一直在尝试使用 Savant 模板引擎创建一个 PHP 页面,该引擎通过 XAMPP 执行一些 CRUD 操作。当我对页面进行编码并尝试运行该页面时,我发现出现了上述错误。但是当我将值分别插入文本框和文本区域并单击发布按钮时,我发现数据库正在成功更新。上述问题的可能原因是什么?我如何摆脱这个问题。
我尝试搜索与此相关的现有线程,但它们似乎都不能解决我的问题。如果任何现有线程解决了我的问题,请帮助引用下面的链接。谢谢。 :)

------------------------------------------------------ - - - - - - - - - -更新 - - - - - - - - - - - - - - - --------------------------------

view.html

<html>
    <head>
        <title>Create Post: Blog: Design & Social Media</title>
    </head>
    <body>
        <form action="../../applications/create/index.php" method="POST">
            <input type="text" name="title" value="<?php echo $this->b->title; ?>"/>
            <input type="submit" value="Publish" />
            <br/>
            <textarea rows="2" cols="20" name="content"><?php echo $this->b->content; ?></textarea>
        </form>
    </body>
</html>

index.php

<?php
    include_once ('../../classes/models/blog.php');
    include_once ('../../resources/libraries/savant3.php');
    $s=new savant3();
    $s->method=$_SERVER['REQUEST_METHOD'];
    $b=new blog();
    if($_SERVER['REQUEST_METHOD']=="GET")
    {
    }
    else
    {
        $b->title=$_POST['title'];
        $b->content=$_POST['content'];
        Blog::create($b);
        header('location:../../applications/success/index.php');
        return;
    }
    $s->display('view.html');
?>

博客.php

<?php
    class Blog
    {
        public $id;
        public $title;
        public $content;
        public $created;

        public static function create(Blog $b)
        {
            $title=$b->title;
            $content=$b->content;
            $m=new mysqli("localhost","root","","kartik_iyer");
            $s=$m->prepare("insert into blog values(null,?,?,null)");
            $s->bind_param('ss', $title, $content);
            $s->execute();
        }

        public static function readSingle($id)
        {
        }

        public static function readAll()
        {
        }

        public static function update(Blog $b)
        {
        }

        public static function delete($id)
        {
        }
    }
?>

This is What I tend to see when I try to run it!

Hi. I've been trying to create a PHP page using Savant Templating Engine that performs some CRUD operations via XAMPP. As I coded the page and tried to run the page, I found the above errors that showed up. But as I inserted the values into the textbox and textarea respectively and hit the publish button, I found that the database is being updated successfully. What is the probable reason for the above issue? And How do I get out of the problem.
I tried to search for existing threads regarding the same, but none of them seemed to address my problem. Please do help out citing the link below if any of the existing threads addresses my issue. Thanks. :)

-------------------------------------------------------------update--------------------------------------------------------------

view.html

<html>
    <head>
        <title>Create Post: Blog: Design & Social Media</title>
    </head>
    <body>
        <form action="../../applications/create/index.php" method="POST">
            <input type="text" name="title" value="<?php echo $this->b->title; ?>"/>
            <input type="submit" value="Publish" />
            <br/>
            <textarea rows="2" cols="20" name="content"><?php echo $this->b->content; ?></textarea>
        </form>
    </body>
</html>

index.php

<?php
    include_once ('../../classes/models/blog.php');
    include_once ('../../resources/libraries/savant3.php');
    $s=new savant3();
    $s->method=$_SERVER['REQUEST_METHOD'];
    $b=new blog();
    if($_SERVER['REQUEST_METHOD']=="GET")
    {
    }
    else
    {
        $b->title=$_POST['title'];
        $b->content=$_POST['content'];
        Blog::create($b);
        header('location:../../applications/success/index.php');
        return;
    }
    $s->display('view.html');
?>

Blog.php

<?php
    class Blog
    {
        public $id;
        public $title;
        public $content;
        public $created;

        public static function create(Blog $b)
        {
            $title=$b->title;
            $content=$b->content;
            $m=new mysqli("localhost","root","","kartik_iyer");
            $s=$m->prepare("insert into blog values(null,?,?,null)");
            $s->bind_param('ss', $title, $content);
            $s->execute();
        }

        public static function readSingle($id)
        {
        }

        public static function readAll()
        {
        }

        public static function update(Blog $b)
        {
        }

        public static function delete($id)
        {
        }
    }
?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尛丟丟 2024-12-09 17:34:09

您收到此消息是因为您的错误报告设置为 -1 = error_reporting(-1); 或者至少启用了通知。这意味着,将显示所有可能的错误消息,尤其是通常未启用的通知。我最近刚刚询问此主题<中的错误报告/strong>.
结论是,您应该编写符合最高标准的代码,但您不应该修复某人现有的代码。

我建议找到将错误报告设置为 -1 的行并将其删除。或者使用以下代码覆盖它:error_reporting(E_ERROR | E_WARNING | E_PARSE);。这会将其设置为默认值。

或者,您可以使用 empty()isset() 和/或将某些变量预设为 NULL 来优化代码。

无论如何,阅读我关于程序员的链接,你就会明白需要-关于错误报告的了解基础。

You are getting this messages because your error reporting is set to -1 = error_reporting(-1); or at least the notices are enabled. This means, that all possible error messages get displayed, especially the notices, that usually are not enabled. I just recently asked about error reporting in this topic.
Conclusion was, that you should write your code to fit the highest standards, but you shouldn't fix somebody existing code.

I would recommend to find the line, that is setting error reporting to -1 remove it. Or override it with: error_reporting(E_ERROR | E_WARNING | E_PARSE);. This will set it as default.

Or you can optimize your code with empty(), isset() and or presetting some variables to NULL.

Anyways, read my link on Programmers and you will understand the need-to-know-basis about error reporting.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文