Click to See Complete Forum and Search --> : php parse error


mohammed_hajat
03-24-2006, 12:11 PM
hi, im an amateur at php.. just having problems with my dissertation.. i have made my database using phpmyadmin, im using php triad, i found this was working for me, neways, im trying to pull the data out of my database, i have a text book im following etc.. but.. having real trouble at this scrip <?php
//connect database
$conn = mysql_connect ("localhost", "", "")
or die(mysql_error());
mysql_select_db("tiles",$conn);

$display_block = "Tiles Categories</h1>
<P>Select a category to see items</P>";

//show categories first
$get_cats = "select id, cat_title, cat_desc from
categories order by cat_title";
$get_cats_res = mysql_query($get_cats) or die(mysql_error());

if (mysql_num_rows($get_cats_res) < 1) {
$display_block = "<P><em> Sorry , no categories to browse. </em></p>";
} else {

While ($cats = mysql_fetch_array($get_cats_res)) {
$cat_id = $cats[id];
$cat_title = strtoupper(stripslashes($cats[cat_title]));
$cat_desc = stripslashes ($cats[cat_desc]);

$display_block .= "<p><strong><a
href=\"$_SERVER[PHP_SELF]?cat_id=$cat_id\">$cat_title</a></strong>
<br>$cat_desc</p>;

if ($_GET[cat_id] == $cat_id) {
//get items
$get_items = "select id, item_title, item_price
from items where cat_id = $cat_id
order by item_title";
$get_items_res = mysql_query($get_items) or die(mysql_error());


if (mysql_num_rows($get_items_res) < 1) {
$display_block = "<P><em>Sorry, no items in
this category.</em></p>";
} else {

$display_block .= "<ul>;

while ($items = mysql_fetch_array($get_items_res)) {
$item_id = $items[id];
$item_title = stripslashes($items[item_title]));
$item_price = $items[item_price];

$display_block .= "<li><a
href="showitem.php?item_id=$item_id\".$item_title</a>
</strong> (\$$item_price)";
}

$display_block .= "</ul>";
}
}
}
}
?>
<HTML>
<HEAD>
<TITLE> Tiles Library</TITLE>
</HEAD>
<BODY>
<?php echo $display_block; ?>
</BODY>
</HTML>



mozilla says its a error on line 30, iv checked everything.. really dont knw what the prblem is.. if anyone could have a quick look it would be appreciated. thanx

chazzy
03-24-2006, 12:14 PM
you never closed your double quote in this area:


$display_block .= "<p><strong><a
href=\"$_SERVER[PHP_SELF]?cat_id=$cat_id\">$cat_title</a></strong>
<br>$cat_desc</p>;

mohammed_hajat
03-24-2006, 12:18 PM
cheers dude.. gone a bit square eyed with all the code..

mohammed_hajat
03-24-2006, 12:24 PM
can you see anything wrong with line 48???

chazzy
03-24-2006, 12:40 PM
you have the same problem on line 41


$display_block .= "<ul>;


and 48-50 should be

$display_block .= "<li><a
href=\"showitem.php?item_id=$item_id\".$item_title</a>
</strong> (\$$item_price)";

mohammed_hajat
03-24-2006, 12:45 PM
legend mate.. thank you soo much.

LiLcRaZyFuZzY
03-24-2006, 12:47 PM
You should use a syntax-highlighting text editor if you don't already

mohammed_hajat
03-25-2006, 05:28 AM
where do i get one of them from???