身份不明的财产;试图获取非对象的属性
嗨。我一直在尝试使用 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)
{
}
}
?>
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您收到此消息是因为您的错误报告设置为
-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 toNULL
.Anyways, read my link on Programmers and you will understand the need-to-know-basis about error reporting.