Hi there,
I am relatively new to PHP and MySQL coding and I am currently using the Joomla CMS.
What I am trying to do is get a game name based on a custom field value from my DB like so;
// fetch the value of field called Game
$gname = $custom[0]->value; //returns something like Trine 2
//connect to database
$database =& JFactory::getDBO();
$query = "SELECT name, id, avatar FROM jos_games WHERE name = '$gname'";
$result = mysql_query($query);
// return database as arrays
while($row = mysql_fetch_array($result)){
echo $row["name"]; //this too should return the name Trine 2 if it exists
}
}
it is far from perfect and I am not sure (as I am still learning) but I think it has something to do with $custom[0]->value; because if I change
$gname = $custom[0]->value;
to
$gname = 'Trine 2'; //changed to string
then the code works fine, please help me out :)