アレイを再割り当てしないでください。次のように使用$result= query->fetch_assoc()
して取得するだけです。
$upload = $result['uploadr'];
echo $upload;
攻撃に対して確実なクエリを作成するには、準備されたステートメントを使用する必要があります。
$query = "SELECT * FROM files WHERE hash = ?"
if (!$stmt = $db->prepare($query))
{
echo "Prepared Failed: (" . $db->errno . ") " . $db->error;
}
if (!$stmt->bind_param("s", $file))
{
echo "Bind Failed: (" . $db->errno . ") " . $db->error;
}
if (!$stmt->execute())
{
echo "Execution Failed: (" . $db->errno . ") " . $db->error;
}
if (!$results = $stmt->get_results())
{
echo "No Results where found: (" . $db->errno . ") " . $db->error;
}
while($row = $results->fetch_assoc())
{
$upload = $row['uploadr'];
$name = $row['name'];
echo $upload."<br>";
echo $name;
}
$stmt -> close();
$db -> close();