Hi Gentlemen
Please help the following code shoots error, my purpose is to view the table value for checking purpose, but it fires error,
<?php
include ('main_config.php');
//get all web settings
$web_settings = array();
try {
$db = new PDO($mysql_host_db, $mysql_user, $mysql_pass);
$query = "SELECT * FROM t_lfs_web_settings";
//$result = $db->query($query);
$result = $db->prepare($query);
$result->execute();
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$web_settings[] = $row;
}
foreach($web_settings as $key=>$val) {
echo $val["gname"];
echo $val;
}
return(0);
}
catch(PDOException $e)
{
//echo $e->getMessage();
echo "Error while retrieving web settings.";
}
$result->closeCursor();
$db = null;
Error messages as follows
Notice: Undefined index: gname in F:\xampp\htdocs\lfs2\site_globalfn.php on line 16
Notice: Array to string conversion in F:\xampp\htdocs\lfs2\site_globalfn.php on line 17
table fields
gld int
gname varchar(200)
gvalue text