I've created two files:
- showtitles.php
- showmessage.php
The first page works ok, but when I want to see the message of a title displayed in showtitles.php i get this error:
undefined variable $id
undefined variable $obj ( 3 times )
I don't know what I'm doing wrong..please help...
thnx in advance
showtitles.php
<?php
session_start();
if (isset ($SESSION['login']) && ($SESSION['login'] == '1')){
?>
<html>
<title></title>
<head></head>
<body>
<table border="0" cellpadding="0" cellspacing="0" bordercolor="#000000" width="480">
<tr>
<td width="100"> Datum:</td>
<td width="380" align="center">Titel:</td>
</tr>
<tr>
<td bgcolor="#DD5001"><hr color="#9B3800" size="1"></td>
<td bgcolor="#DD5001"><hr color="#9B3800" size="1"></td>
</tr>
</table>
</body>
</html>
<?php
include ("style.php");
$db_host = "localhost";
$db_login = "";
$db_password = "";
$db_database = "nieuws";
mysql_connect("$db_host","$db_login","$db_password") or die (mysql_error());
mysql_select_db("$db_database") or die (mysql_error());
$resultaat = mysql_query("SELECT id, titel, bericht, datum FROM nieuws ORDER BY ID DESC LIMIT 0, 5");
while($obj = mysql_fetch_object($resultaat)) {
?>
<html>
<body bgcolor="#DD5001">
<table border="0" cellpadding="0" cellspacing="0" bordercolor="#000000" width="480">
<tr>
<td width="480"> <? echo $obj->datum ?> <b><a href="showmessage.php"><? echo $obj->titel ?></b></a></td>
</tr>
</table>
</body>
</html>
<?php
}}
else {
include ("geen_toegang.php");
}
?>
showmessage.php
<?php
session_start();
if (isset ($SESSION['login']) && ($SESSION['login'] == '1')){
include ("style.php");
$db_host = "localhost";
$db_login = "";
$db_password = "";
$db_database = "nieuws";
mysql_connect("$db_host","$db_login","$db_password") or die (mysql_error());
mysql_select_db("$db_database") or die (mysql_error());
$resultaat = mysql_query("SELECT id, titel, bericht, datum FROM nieuws WHERE id = '$id'");
while($obj = mysql_fetch_object($resultaat)) {
?>
<html>
<body bgcolor="#DD5001">
<table border="0" cellpadding="0" cellspacing="0" bordercolor="#000000" width="480">
<tr>
<td width="480" bgcolor="#DD5001">-> <? echo $obj->datum?> <b><? echo $obj->titel ?></b></td>
</tr>
<tr>
<td width="480" bgcolor="#DD5001"> <? echo $obj->bericht ?></td>
</tr>
</table>
</body>
</html>
<?php
}}
else {
echo"error";
}
?>