duanmao9918 2016-11-18 20:22
浏览 39

php.5.6变量对代码不可见

I have simple msql based glossary - which stop working after upgrade from php5.4 to php 5.6.28

In form i send a variable to address like page.php?word=xxx

in page.php it should get $word from table.word with table.definition

Connection with database is working.

Error log looks

array(1) { ["word"]=string(5) "xxx" } bool(true) 

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, string given

my code is

ini_set('display_errors', 'On');
error_reporting(E_ALL);

$configfile = "config.php";
require $configfile;
$db = mysqli_connect("$host", "$username", "$password") or die ("could not connect to mysql"); 
mysqli_select_db($db, "$databasename") or die ("no database"); 
mysqli_query($db, "SET NAMES 'utf8' COLLATE 'utf8_polish_ci'");

function mysqli_result($db,$row=0,$col=0){ 
    $numrows = mysqli_num_rows($db); 
    if ($numrows && $row <= ($numrows-1) && $row >=0){
        mysqli_data_seek($db,$row);
        $resrow = (is_numeric($col)) ? mysqli_fetch_row($db) : mysqli_fetch_assoc($db);
        if (isset($resrow[$col])){
            return $resrow[$col];
        }
    }
    return false;
}

$word = "";

var_dump($_GET);    
var_dump(isset($word));

if($word)
    {       
        $getWord=mysqli_query($db, "SELECT word,definition FROM mdglossary WHERE word LIKE '$word' ORDER BY word");
    }
    else {....}

if($getWordArray=mysqli_fetch_array($getWord, MYSQLI_BOTH))
    {
    do
        {
        echo "....";
        }
    while($getWordArray=mysqli_fetch_array($getWord));
    }
else {....}

I try to find solution "hundret" times by Internet and this page, but I just can't understand what happened and why it doesn't work at all.

  • 写回答

1条回答 默认 最新

  • doubo9799 2016-11-18 20:53
    关注

    You have set word to equal nothing.

    $word = "";
    

    then your sql will look like this

    SELECT word,definition FROM mdglossary WHERE word LIKE '' ORDER BY word
    

    So your looking for a word column with nothing in it. Is that your intention?

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。