Gustavo Muratalla Gustavo Muratalla -5 years ago 76
MySQL Question

Setting the a WebPages Title with PHP and MySql database

So I have a database the program runs fine connects and all except for one thing I am trying to get the "forum_name" defined under my db and set it as my Title. Pretty much if I click on the link where it takes me to that post or forum page it will get whats under forum_name and print it as the Title.

This is db_connect.php

$db = new mysqli("localhost", "root", "","forum") or die("ERROR: With Connecetion");

And this is the Reset:

//get the page id
if(isset($_GET['id']) &&is_numeric($_GET['id'])){
$id = $_GET['id'];
die("Error! Does not exist!");
//check if Valid Id
$idCheck = $db->query("SELECT * FROM forum_tabl WHERE forum_id = 'id'");
if($idCheck->num_rows !==0){
$row = $idCheck->fetch_object();
$sql = "SELECT post_id, post_title FROM forum_post WHERE forum_id? AND type= 'o'";
if($query = $db->prepare($sql)){
$query->bind_params('s', $id);
$query->bind_result($post_id, $post_title);
<!DOCTYPE html>
<meta charset="utf-8">
<title><?= $row->forum_name?></title>


<div id="container">
<!-- Theres content that will go here -->


Answer Source

I think the Problem is in this line.

$idCheck = $db->query("SELECT * FROM forum_tabl WHERE forum_id = 'id'");

and You have to replace it as follows.

$idCheck = $db->query("SELECT * FROM forum_tabl WHERE forum_id = '$id'");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download