Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to separate arrays into variables
    primarykey
    data
    text
    <p>I've tried to look this up, but I'm not quite getting an answer that pertains directly to what I'm doing. I'm trying to retrieve values from a database that were previously submitted. I want to use these values to locate filepaths on the server and use the fillepath information to display the files. To do this, I need to separate the array that i have here. How would I separate this array?</p> <pre><code>$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)); </code></pre> <p>I appreciate any help guys. Ideally I would like to get a variable like $story or $storyPath and $video or $videoPath I need the video as a variable so I can play it with a video player.</p> <p>EDIT: I changed from mysql to mysqli and I'm getting all of these errors now that I can't seem to fix. I have the result set and it says I don't.</p> <p>Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home/content/98/10339998/html/scripts/stories.php on line 26</p> <p>I think this warning should fix itself once the array gets sorted out:</p> <p>Warning: extract() expects parameter 1 to be array, null given in /home/content/98/10339998/html/scripts/stories.php on line 28</p> <p>Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in /home/content/98/10339998/html/scripts/stories.php on line 30</p> <pre><code>$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; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload