2012-12-02 103 views
-2

我跟着这个教程:http://php.about.com/od/finishedphp1/ss/rating_script.htm评级系统PHP MYSQL

但是当我运行它,我得到

Notice: Undefined variable: mode in C:\xampp\htdocs\xxxx\index.php on line 7. 

有谁知道什么可能是错误的? http://php.about.com/od/finishedphp1/ss/rating_script_3.htm

//We only run this code if the user has just clicked a voting link 
if ($mode=="vote") 

您正在检查未定义的变量 - - $mode

+0

第7行的内容是否可以显示第7行? –

+1

您将需要发布代码 –

+1

“*有人知道什么可能是错误的吗?*” - 在您的文件“C:\ xampp \ htdocs \ xxxx \ index.php”的第7行,您指的是尚未定义的变量“模式”。 – eggyal

回答

1

如果您正是他们的复制脚本,这个问题在步骤3中找到。您需要先定义它,喜欢的东西 -

//We only run this code if the user has just clicked a voting link 
$mode = isset($_GET['mode']) ? htmlentities($_GET['mode']) : ''; 
if ($mode=="vote") 

注:我同意@azizpunjani,该代码已经过时,有很多的问题。您应该查找使用mysqli_PDO而不是mysql_函数的脚本。

+0

感谢我现在收到错误“警告:在第59行C:\ xampp \ htdocs \ xxx \ index.php中的零除”我的第59行如下:$ current = $ row ['RatingTotal']/$行[ '评分']; –

+0

你需要检查是否有超过'0'票(或'评级',根据你的代码)。尝试将其更改为 - '$ current =($ row ['Rating'] == 0)? 0:$ row ['RatingTotal']/$ row ['Rating'];'。如果尚未提交投票/评级,即。 '$ row ['Rating'] == 0','$ current'将是'0',但将会是'$ row ['RatingTotal']/$ row ['Rating']'if'$ row ['Rating ']> = 1' – Sean