其中$ variable = $ variable

时间:2014-06-16 17:20:13

标签: php mysql variables

有一个问题,我有一个下拉我的HTML和文本条目,然后我试图在mysql查询中使用这些 当我回显它们时,条件和查询类型都返回值,它只是返回没有值的选择查询

<?php
$con = mysqli_connect("***********************");
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$querytype = mysqli_real_escape_string($con, $_POST['querytype']);
$criteria = mysqli_real_escape_string($con, $_POST['criteria']);

$query= mysqli_query($con,"SELECT trackingnumber FROM 'OrderDB' WHERE '$querytype' = '$criteria'");
$result = mysqli_fetch_array ($query);
header('Location: http://trackyourpackage.uk/track.php?oid=' . $result);
?>

1 个答案:

答案 0 :(得分:0)

$result = mysqli_fetch_array ($query);
header('Location: http://trackyourpackage.uk/track.php?oid=' . $result);

mysql_fetch_array()返回一个数组。将数组转换为字符串会生成文字字符串"Array"。您需要使用数组索引:

header('Location: http://trackyourpackage.uk/track.php?oid=' . $result[0]);