<?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();
?>
Parse Error Help
Moderator: General Moderators
-
drumminlogan
- Forum Newbie
- Posts: 3
- Joined: Wed Apr 21, 2004 8:11 pm
Parse Error Help
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.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
<?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 "<h3>$row['businessname']</h3> <br />
$row['id']<br />
$row['webaddress']<br />
$row['firstname']<br />
$row['lastname']<br />
$row['category']<br />
$row['shortdescription']<br />
$row['longdescription']<br />"; } else {
die ('<p>Could not retrieve the date because: <b>' . mysql_error() . "</b>. The query was $query.</p>");
}
}
mysql_close();
?>i cleaned up ur code a lil too
Last edited by John Cartwright on Wed Apr 21, 2004 8:24 pm, edited 2 times in total.
-
drumminlogan
- Forum Newbie
- Posts: 3
- Joined: Wed Apr 21, 2004 8:11 pm
Code: Select all
if ($r = mysql_query ($query))Code: Select all
if ($r = mysql_query ($query))
{-
drumminlogan
- Forum Newbie
- Posts: 3
- Joined: Wed Apr 21, 2004 8:11 pm