Parse Error Help
Posted: Wed Apr 21, 2004 8:11 pm
I am writing my first PHP script with mysql. I am new to PHP and am wondering if you can help me out. I wrote a little form that added information to my database in a table I created. I want to write a script just to view each entry and I get a parse error when I try to run it and can't figure out what the problem is. It says it is on line 78, which is right after {$row['longdescription']}<br /></p>"; This is a modified script from the book PHP for the World Wide Web by Larry Ullman. Thanks.
<?php
if ($dbc=mysql_connect ("localhost", "truthd_logan", "MYPASSWORD")) {
if (!@mysql_select_db ('truthd_123christian'))
{
die ('<p>Could not select the database because: <b>'. mysql_error() . '</b></p>');
}
} else {
die ('<p>Could not connect to MYSQL because: <b>' . mysql_error() . '</b></p>');
}
$query = 'SELECT * FROM 123_listings ORDER BY id DESC';
if ($r = mysql_query ($query))
while ($row = mysql_fetch_array ($r)) {
print "<p><h3>{$row['businessname']}</h3>
{$row['id']}<br />
{$row['webaddress']}<br />
{$row['firstname']}<br />
{$row['lastname']}<br />
{$row['category']}<br />
{$row['shortdescription']}<br />
{$row['longdescription']}<br /></p>";
}
} else {
die ('<p>Could not retrieve the date because: <b>' . mysql_error() . "</b>. The query was $query.</p>");
}
mysql_close();
?>