我试着查了一下,但我并没有得到与我正在做的事情直接相关的答案。我正在尝试从以前提交的数据库中检索值。我想使用这些值来定位服务器上的文件路径并使用填充路径信息来显示文件。为此,我需要分离我在这里拥有的数组。我将如何分离这个数组?
$code = $_POST['codeInput'];
$code = htmlspecialchars($code);
$submitCodes = "SELECT story,video FROM `storycodes` WHERE `code` = $codeInput";
$files = mysql_fetch_array($submitCodes);
mysql_close($con);
print_r(array_values($files));
我很感激任何帮助。理想情况下,我想获得一个变量,如 $story 或 $storyPath 和 $video 或 $videoPath 我需要将视频作为变量,以便我可以使用视频播放器播放它。
编辑:我从 mysql 更改为 mysqli,现在我得到了所有这些错误,我似乎无法修复。我有结果集,它说我没有。
警告:mysqli_fetch_assoc() 期望参数 1 为 mysqli_result,布尔值在 /home/content/98/10339998/html/scripts/stories.php 第 26 行给出
我认为一旦数组被整理好,这个警告应该会自行修复:
警告:extract() 期望参数 1 是数组,在第 28 行的 /home/content/98/10339998/html/scripts/stories.php 中给出了 null
警告:mysqli_free_result() 期望参数 1 为 mysqli_result,布尔值在 /home/content/98/10339998/html/scripts/stories.php 第 30 行给出
$con = mysqli_connect("storycodes.db.10339998.hostedresource.com",$username,$password);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysqli_select_db($con, "storycodes");
$code = $_POST['codeInput'];
$code = htmlspecialchars($code);
$query = "SELECT story,video FROM `storycodes` WHERE `code` = $codeInput";
$result = mysqli_query($con, $query);
$row = mysqli_fetch_assoc($result);
extract($row);
mysqli_free_result($result);
mysqli_close($con);
echo $story . $video;