i am reading the book
"BUILDING YOUR OWN DATABASE DRIVEN WEBSITE USING PHP & MYSQL" and im stuck. i tried the example with the joke database but it doesnt seem to work. ive successfull created the table but when i write the code to display the data nothing comes up.
here is my code
PHP Code:
<html>
<head>
<title>our list of jokes</title>
<head>
<body>
<?php
$dbcnx = @mysql_connect('localhost', 'root', 'mypasswd');
if (!$dbcnx) {
exit('<p>Unable to connect to the ' .
'database server at this time.</p>');
}
if (!@mysql_select_db('ijdb')) {
exit('<p>Unable to locate the joke ' .
'database at this time.</p>');
}
?>
<p>here are all the jokes in our database:</p>
<blockquote>
<?php
$result = @mysql_query('SELECT joketext FROM joke');
if (!$result) {
exit('<p>Error performing query: ' .mysql_error() . '</p>');
}
while ($row = mysql_fetch_array($result)) {
echo '<p>' . $row['joketext'] . '</p>';
}
?>
</blockquote>
</body>
</html>
Bookmarks