数组中的值未编入索引

时间:2013-05-13 11:55:11

标签: php mysql

此脚本应从数据库中选择StaffID,然后将其放入一个数组中,然后从那里我可以将其放入一个变量中,以便在下一个查询中使用。

$query  = "SELECT StaffID FROM staff WHERE First_Name = '$db_staff_member_first_name' AND Last_Name = '$db_staff_member_last_name'";
    $result = mysql_query($query)
    or die(mysql_error());
    echo $result;
    echo $query + "<br>";
    while($row = mysql_fetch_array($result, MYSQL_ASSOC))
    {
$db_staffid = $row['staffID'];
}

脚本运行后我得到了

'Resource id #4SELECT CustomerID FROM customer WHERE Customer_First_Name = 'Christopher' AND Customer_Last_Name = 'Bennett'Resource id #50'

然后是以下通知:

  

注意:未定义的索引:staffID in   第112行的E:\ EasyPHP-12.1 \ www \ Placing_Orders.php

为什么会这样?

1 个答案:

答案 0 :(得分:3)

http://php.net/manual/en/function.mysql-fetch-array.php

Note: Field names returned by this function are case-sensitive.