1

我对 php 和第一个项目非常陌生,但我遇到了这种错误:

注意:未定义的变量:第 16 行 C:\wamp\www\mysite\includes\functions.php 中的 magic_quotes_active

这是我的代码;

function mysqli_prep($value) {
   $magic_quotes_activen = get_magic_quotes_gpc();

   $new_enough_php = function_exists( "mysqli_real_escape_string");

   // i.e PHP >= V4.3.0

   if ($new_enough_php ) {// PHP V4.3.0 or higher

   // undo any magic quote effects so mysqli_real_escape_string can

   // do the work

   if( $magic_quotes_active ) {$value = stripslashes($value);}

   $value = mysqli_real_escape_string($value);

   } else {//before PHP V4.3.0

   // if magic quotes aren't already on then add slashes manually

   if(!$magic_quotes_active) { $value = addslashes($value);}

   // if magic quoes are active, then the slashes already exist
   }
   return $value;
4

2 回答 2

0

您已将变量声明为$magic_quotes_activen但正在引用$magic_quotes_active. 在那个 PHP 错误消息中也很清楚。

于 2015-02-27T21:54:02.703 回答
0

感谢您快速回复 jlindenbaum,

我已经看到了那个错误并清除了它,但现在它仍然显示这个

警告:get_magic_quotes_gpc() 需要 0 个参数,1 个在 C 中给出:

和这个

警告:mysqli_real_escape_string() 需要 2 个参数,1 个在 C 中给出

于 2015-02-28T03:29:59.503 回答