【发布时间】:2013-01-16 17:54:07
【问题描述】:
嗯,我正在开发一个带有复制中心系统 (this is the form) 的基于 CMS 的表单,但我需要 $cookie->id_customer。 但我得到一个错误:
致命错误:在第 13 行的 /home/papelari/public_html/modules/mymodule/submit.php 中的非对象上调用成员函数 isLogged()
<?php
/*
$con = mysql_connect("localhost","papelari","509494218");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("papelari_Veloso", $con); */
global $cookie;
if(!$cookie->isLogged())
{
echo 'Please login';
exit;
}
else
{
echo 'Hi, ' . $cookie->customer_firstname. ' ' .$cookie->customer_lastname . '<br/>';
echo 'We contact to you: '. $cookie->email;
}
/* $sql="INSERT INTO ps_copias (id_customer, file, cor, copias, pags, papel, gramagem, flag) VALUES('$cookie- >id_customer','$_POST[file]','$_POST[cor]','$_POST[copias]','$_POST[pags]','$_POST[papel]','$_POST[gramagem]', 0)";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Enviado com sucesso!";
mysql_close($con); */
?>
【问题讨论】:
-
Please, don't use
mysql_*functions in new code。它们不再维护,deprecation process 已开始使用。看到red box?改为了解prepared statements,并使用PDO 或MySQLi - this article 将帮助您决定哪个。如果你选择 PDO,here is a good tutorial.
标签: php html mysql cookies prestashop