<?php
//Sessions starten
session_start();
//Include stuff
include('conf.php');
//'Shortcuts' maken
$sname = $site['name'];
$shost = $site['host'];
$shostb = $site['hostb'];
//Verbinding maken met DB
$link = mysql_connect($database['host'], $database['username'], $database['password']) or die (mysql_error());
mysql_select_db($database['db'],$link) or die(mysql_error());
//Gegevens uit db halen
if(isset($_GET['page'])){
$page['title'] = mysql_query("SELECT title FROM pages WHERE page = $_GET[page]");
}
else{
$page['title'] = mysql_query("SELECT title FROM pages WHERE page = 'index.php'");
}
?>
<!doctype html>
<html lang="nl">
<head>
<meta charset="utf-8" />
<title><?php echo $sname;?>•<?php echo $page['title']?></title>
Does somebody know why this doesn’t work? My DB structure is:
page |title
index.php|index
Sorry but I can’t get this clear. The var dump of $page['title'] = resource(5) of type (mysql result). How can I fix this? Thanks for the help.
mysql_queryreturns a resource, you need to usemysql_fetch_array(or similar, e.g.mysql_fetch_assoc) on the resource to get the title value.For example:
Warning: your query is vulnerable to SQL injection.