Looking to do your daily good deed? Take a look at my problem and see if you can help.
I have a table called WEBSITES. Within this table are the fields -- NAME, WEBSITE, and CATEGORY. (There are five identifiers within category - food, friends, fans, venues, and industry -- these are entered into the database via a drop down menu)
What I want to do is querie the database multiple times and call back only those records that have a specific identifier, i.e. food.
When I do the following, everything is super, borderline super duper.
$query = "SELECT id, name, website, category FROM websites WHERE category = 'food'";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
However when I try to multiply this querie a second time, in hopes of doing it five in total, I get the following error.
Parse error: parse error, unexpected $ on line 112
Weird thing is that my code ends with line 111.
Any help is greatly appreciated. I have no idea where this phantom $ is coming from. And I would like find out so I can send it back as soon as possible.
<table width="350" cellpadding="5" cellspacing="0" border="0">
<?
// includes
include("conf.php");
include("functions.php");
// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
?>
<tr align="left" valign="top">
<?
// generate and execute query
$query = "SELECT id, name, website, category FROM websites WHERE category = 'food'";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
// if records present
if (mysql_num_rows($result) > 0)
{
// iterate through resultset
// print title with links to edit and delete scripts
while($row = mysql_fetch_object($result))
{
?>
<td width="50" align="left"><a href="edit_contact.php?id=<? echo $row->id; ?>">EDIT</a></td>
<td width="250"><? echo $row->name; ?>
</td>
<td width="250">
<? if ($row->website != "" )
{
echo "<a href=http://";
echo $row->website;
echo "\n target=_new >";
}
?>
<? echo $row->website;
?>
<? if ($row->website != "" )
{
echo "</a>";
}
mysql_free_result ($result);
?>
</td>
<td width="50"> <a href="delete_contact.php?id=<? echo $row->id; ?>">DELETE</a>
</td>
</tr>
<tr align="left" valign="top">
<?
// generate and execute query
$query = "SELECT id, name, website, category FROM websites WHERE category = 'fans'";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
// if records present
if (mysql_num_rows($result) > 0)
{
// iterate through resultset
// print title with links to edit and delete scripts
while($row = mysql_fetch_object($result))
{
?>
<td width="50" align="left"><a href="edit_contact.php?id=<? echo $row->id; ?>">EDIT</a></td>
<td width="250"><? echo $row->name; ?>
</td>
<td width="250">
<? if ($row->website != "" )
{
echo "<a href=http://";
echo $row->website;
echo "\n target=_new >";
}
?>
<? echo $row->website;
?>
<? if ($row->website != "" )
{
echo "</a>";
}
?>
</td>
<td width="50"> <a href="delete_contact.php?id=<? echo $row->id; ?>">DELETE</a>
</td>
</tr>
<?
}
// close connection
mysql_close($connection);
?>
</table>