Hello all! Thanks for taking a look at this...
I've set up a PDO connection string in PHP, which works fine. I'm using the code below to run a simple query that should return a single line from the database. The query appears to be working fine, but when I do a var_dump on the results, I get an array inside of an array. It's like it's adding an extra "layer" of array. Instead of just an array with the elements, it creates and array with one element that contains another array with the expected elements. Please see the results below:
I'm hoping that you can help save the little hair I have left - it's coming out in clumps!
Here's the code, and the var-dump results are below it...
<?php // Get existing values of case id if present in DB
$my_id = trim(strip_tags($_SESSION['my_id']));
try {
$case_res = $pdo->query("SELECT m_city, m_state, m_country FROM user_info where my_id = '" . $my_id . "'");
}catch (Exception $e){
echo "Not Successfull: Unable to read Case ID";
}
echo "<pre>";
//var_dump($case_res->fetchAll());
var_dump($case_res->fetchAll(PDO::FETCH_ASSOC));
?>
Here are the results:
array(1) {
[0]=>
array(3) {
["m_city"]=>
string(9) "hollywood"
["m_state"]=>
string(2) "CA"
["m_country"]=>
string(4) "Togo"
}
}