我几乎花了一个小时试图弄明白我在这里做错了什么。这是无输出。
连接正常,数组中充满了数据
<?php header('Content-Type: text/html; charset=utf-8');
// Here's the argument from the client.
$domain = $_GET['string'];
$quest=$_GET['quest'];
$event=$_GET['event'];
$con = mysql_connect('localhost', '******', '********');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("vocabulary", $con);
$sql="SELECT * FROM `0` WHERE event_name = '".$event."' AND quest_id = '".$quest."'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$key = array_search($domain, $row);
echo $key;
mysql_close($con);
?>有什么想法吗?谢谢
发布于 2013-05-08 23:34:23
几件事。
要从名为0的表中选择的
,
0的存在,所以我猜你在mysql_fecth_array上有一个错误。如果没有找到任何东西,请尝试将error_reporting(E_ALL);放在script.array_search的开头,返回False。尝试instead.

发布于 2013-05-08 23:39:27
我认为您的问题在于您没有创建关联数组http://php.net/manual/en/function.array-search.php
您的mysql_fetch_array将返回一个有值但没有键的数组,因此没有什么可以存储在$key中。试着这样做:
$row = mysql_fetch_array($result, MYSQL_ASSOC)另外,强制性的“你应该避免完全使用mysql_函数,并转移到mysqli或PDO,因为mysql_已经被弃用了”。
https://stackoverflow.com/questions/16444566
复制相似问题