【问题标题】:Mapping a static value to a static value将静态值映射到静态值
【发布时间】:2013-03-27 08:57:31
【问题描述】:

我正在尝试将数组中的一些值与用户输入的值进行映射。 这里 $actual 来自用户,$target 来自表

if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
else

{
    $actual; 
    $comment; $con;
    foreach($_POST['value']  as $country => $value1 ){
        foreach($value1  as $goal => $value2){
                    //value => ["matrix"]
                    foreach($value2 as   $matrix => $value3){
                            //value => string 
                             $country ." ". $goal." " .$matrix. " " . $value3."<br/>";  
                            if($matrix == "actual"){
                                $actual = $value3;  
                            }else if($matrix=="comment"){
                                $comment=$value3;

                            }

                    }
              $sql="SELECT target FROM target where ini_id = '$ini' and country_id='$country' and metric_id='$goal'"; 
              $result=mysql_query($sql);
              $target = mysqli_fetch_array($result);


                insert($actual,$target['target'],$country.$ini.$goal ,$comment,$con);

警告:mysqli_fetch_array() 期望参数 1 为 mysqli_result,布尔值在 C:\xampp\htdocs\xampp\Testing\sq1.php 第 107 行给出

【问题讨论】:

  • 你的查询失败,添加一些调试看看原因
  • 当我做 print_r($target);?> 我没有看到任何值
  • 返回的都是假的

标签: php mysqli


【解决方案1】:

我看到的问题是您使用的是mysql_query 而不是mysqli_query

(因此 mysqli_fetch_array 并不真正知道如何解释该参数)

【讨论】:

  • 想通了,只是语法问题
猜你喜欢
  • 2020-04-10
  • 1970-01-01
  • 2013-09-20
  • 1970-01-01
  • 2014-02-03
  • 2021-10-28
  • 2014-04-13
  • 2016-12-24
  • 1970-01-01
相关资源
最近更新 更多