So, I'm trying to get the name of a forum title through a function by using the category_id in the url.
It's not returning the title. Yes, I am including the functions.php.
The link is:
http://www.dxbridge.com/view_category.php?cid=1
functions.php:
function getForumsCategoriesName($cid) {
$query = "SELECT * FROM categories WHERE id='" . $cid . "'";
try {
global $db;
// Execute the query against the database
$stmt = $db->prepare($query);
$stmt->execute();
$result = $stmt->fetchAll();
foreach($result as $forums) {
$forumsID = $forums['id'];
$forumsTitle = $forums['category_title'];
$forumsTopicAmount = $forums['topic_amount'];
$forumsCategoriesName = "<h1>" . $forumsTitle . "</h1>";
echo $forumsCategories3;
}
}
catch(PDOException $ex) {
// Note: On a production website, you should not output $ex->getMessage().
// It may provide an attacker with helpful information about your code.
die("Error loading names");
}
}
trying to grab the name from function
$cid = $_GET['cid'];
getForumsCategoriesName($cid);
Also, I know the variable is being set, it's jsut not going through the function.
echo $forumsCategories3;doesn't have a value. You have several other variables populated there, but not that one.$forumsCategories3. At the top of you script:error_reporting(E_ALL); ini_set('display_errors', 1);$cidright into your SQL string. Now is the time to learn to useprepare()/execute()properly with bound parameters.