Hello, we need help with our homepage, which is currently out of commission! We used an online admin to simply change some of the body text, but now there appears to be a problem with the coding (which we hadn't changed). The error 'occurred on line 18', and I've gone through to make sure all the brackets and " marks matched up. Any ideas? <? include('includes/application_top.php'); $dontShow = "|104|107|103|89|94|113|109|"; $query_string = ""; $block_ids = explode("|", $dontShow); for($i=0;$i<sizeof($block_ids);$i++){ if (!empty($block_ids[$i])) { $query_string .= " and p.products_id != '$block_ids[$i]'"; } } $query_string = " and (".substr($query_string, 5).")"; if (eregi("[a-zA-Z]", $category_id)) { $getCategory = mysql_query("select category_top_id, category_top_name, copy from category_top where category_top_name='".eregi_replace("\-"," ",$category_id)."'"); if (mysql_num_rows($getCategory)>0) { $categoryImage = $category_id; $category = mysql_fetch_array($getCategory); $category_id = $category[category_top_id]; $category_copy = $category['copy']; } } # gets the html files from the directory supplied and spits out the url (must be .html files). function randlink($dizin) { $filelist=array(); $handle=opendir("$dizin"); while ($filename = readdir($handle)) { if ($file != "." && $file != "..") { $ext=substr($filename,-5); if ($ext == ".html") { $file=substr($filename,0,-5); array_push($filelist, "$file.html"); } } } srand ((double) microtime() * 10000000); $rk = array_rand($filelist); # return a random link return "$dizin/$filelist[$rk]"; } $pageTitle = "Generic title substituted."; if ($category[category_top_id]){ $pageTitle = $category[category_top_name]. ", generic description substituted."; } $pageKeywords = "generic keyword substituted."; $pageDescription = "generic description substituted."; $include_file = DIR_INCLUDES . 'header.php'; include(DIR_INCLUDES . 'include_once.php'); if (!$category_id) {?> <p style="margin-top:25px; "><img src="/images/template/item.jpg" alt=" item name" title="item name - text removed style="float:right; margin-left:20px; margin-bottom:10px;">generic description substituted.</p> <p>body copy taken out</p> <p>body copy taken out</p> <p>Call <strong>800-000-0000</strong> for your nearest representative.</p> <? # include(randlink("/www/data/domain/includes/splash/")) ?> <!--img src="/images/trends_report3.jpg" border="0" alt="Welcome to <?print STORE_NAME;?>" width="550" height="334" /--> <br> <div align="center"> <br> <br> <!--<p>body copy taken out or see our <a href="about.php">about us</a> page.</p>--> <? } else { $query = " (SELECT p.products_name, p.products_image, p.products_price, p.products_url, p.products_id, p.colour, p.variation, s.subcategories_name FROM products p, subcategories s, products_to_subcategories ps, subcategories_to_category sc WHERE sc.category_top_id='$category_id' and sc.subcategories_id=ps.subcategories_id and ps.products_id=p.products_id and p.products_quantity > 0 and ps.subcategories_id=s.subcategories_id and p.variation != '' $query_string GROUP BY p.products_id, p.variation) UNION (SELECT p.products_name, p.products_image, p.products_price, p.products_url, p.products_id, p.colour, p.variation, s.subcategories_name FROM products p, subcategories s, products_to_subcategories ps, subcategories_to_category sc WHERE sc.category_top_id='$category_id' and sc.subcategories_id=ps.subcategories_id and ps.products_id=p.products_id and p.products_quantity > 0 and ps.subcategories_id=s.subcategories_id and p.variation = '' $query_string ) ORDER BY s.subcategories_name, p.products_name"; $getProducts = mysql_query($query); // GROUP BY p.orderable_item $curBedGroup = ""; $curSubGroup = ""; $getProductList = ""; $curSubcategoriesName = ""; while ($products = mysql_fetch_array($getProducts)){ $checkProduct = mysql_query("select * from product_parent where product_id='$products[products_id]'"); if (mysql_num_rows($checkProduct)<1){ $getProductList .= ":".$products[products_id].":"; } } mysql_data_seek ($getProducts, 0);?> <img src="/images/headers/<?if ($category_id) print $categoryImage;?>.gif" alt="<?if ($category_id) print $category[category_top_name];?>"> <br> <?print $category_copy;?> </div> <table cellpadding=6 cellspacing=0 border=0 width="565"> <? $curCategory = ""; $requiredRows = mysql_num_rows($getProducts) / PRODUCTS_PER_ROW; $productCount = 0; $rowCt=0; while ($products = mysql_fetch_array($getProducts)){ $useName = ""; $usePrice = ""; $useImage = ""; print "<!--select * from products where products_name='".addslashes($products[products_name])."'-->"; $getSimilarProducts = mysql_query("select * from products where products_name='".addslashes($products[products_name])."'"); if (mysql_num_rows($getProducts) > 1){ while ($similarProducts = mysql_fetch_array($getSimilarProducts)){ if (eregi("set", $similarProducts[colour])){ $useID = $similarProducts[products_id]; $useName = $similarProducts[products_name]; $usePrice = $similarProducts[products_price]; $useImage = $similarProducts[products_image]; } } } $rowCt++; $id = $products[products_id]; if (eregi("".$id."",$getProductList) && !eregi("\|".$id."\|", $dontShow)){ if (file_exists($products[products_image])) { $image = $products[products_image]; } else { $image = "images/pic_unavailable.gif"; } if($useImage){ $image = $useImage; } $productCount++; if ($productCount % PRODUCTS_PER_ROW == 1) {?> <tr> <? } if ($products[subcategories_name] != $curCategory){ $curCategory ="$products[subcategories_name]"; $productCount=1;?> </tr> <tr> <? } if ($useName){?> <td valign=top align="center" class="clear"> <a href="http://www.domain.com/product/<?print $useID;?>/"><img src="/<?print $image;?>" alt="<?print $useName;?>" border='0' vspace='3'></a><br> <a href="http://www.domain.com/product/<?print $useID;?>/"><?print $useName;?></a><br> <font color="#ff0000">$<?print number_format($usePrice,2);?></font><br> </td> <? } else {?> <td valign=top align="center" class="clear"> <a href="http://www.domain.com/product/<?print $products[products_id]?>/"><img src="/<?print $image;?>" alt="<?print $products[products_name];?>" border='0' vspace='3'></a><br> <a href="http://www.domain.com/product/<?print $products[products_id];?>/"><?print $products[products_name];?></a><br> <?= $products[products_price]>0?'<font color="#ff0000">$'.number_format($products[products_price],2).'</font>':'';?></font><br> </td> <? } if ($productCount % PRODUCTS_PER_ROW == 0 || mysql_num_rows($getProducts) == $rowCt) {?> </tr> <? } } }?> </table> <? }?> <map name="Map_splashMap"> <area shape="rect" coords="-1,122,61,146" href="#"> <area shape="rect" coords="64,168,154,196" href="#"> <area shape="rect" coords="191,142,280,175" href="#"> <area shape="rect" coords="227,83,310,111" href="#"> <area shape="rect" coords="179,18,250,46" href="#"> <area shape="rect" coords="54,31,124,55" href="#"> <area shape="rect" coords="79,71,217,136" href="#"> </map> <map name="Map_splash"> <area shape="rect" coords="-2,123,60,147" href="#"> <area shape="rect" coords="95,172,185,200" href="#"> <area shape="rect" coords="219,145,308,178" href="#"> <area shape="rect" coords="247,84,330,112" href="#"> <area shape="rect" coords="208,17,279,45" href="#"> <area shape="rect" coords="44,31,114,55" href="#"> <area shape="rect" coords="72,66,240,141" href="#"> </map> <? $include_file = DIR_INCLUDES . 'footer.php'; include(DIR_INCLUDES . 'include_once.php'); $include_file = DIR_INCLUDES . 'application_bottom.php'; include(DIR_INCLUDES . 'include_once.php'); ?>
Can you post the exact error message? And make sure in error message it is not talking about any included file.
Here's the entire error message that I get. Parse error: syntax error, unexpected '<' in /home/domain/public_html/default.php on line 18
Change all your short tags to long tags. <? to <?PHP Also on this line a space may be needed <?print $category_copy;?> between the ? and print. These are just quick guesses since I can not see all the code.
I tried changing to long tags and that didn't do it. Any other ideas. This is really driving me crazy.
your error is in Line 18, so i think it is "if (mysql_num_rows($getCategory)>0) {" what is you try if(mysql_num_rows($getCategory) > "0") or even try to put an space between.. maybe it will work. =)
Hello, I have run your code as above on my linux machine: [jayshah@node dp]$ php -v PHP 5.2.5 (cli) (built: Mar 3 2008 17:29:40) Code (markup): But no errors were detected: [jayshah@node dp]$ php -l syntax.php No syntax errors detected in syntax.php Code (markup): Are you sure the problem still exists? Jay
After yesterday's problems with our email. It's looking like it might be the server causing the error codes. I'm now getting the same code on a few other pages. I'm going to look at the server today.
I'm still getting the error code so I thought i'd post this quick <? include('includes/application_top.php'); $dontShow = "|104|107|103|89|94|113|109|"; $query_string = ""; $block_ids = explode("|", $dontShow); for($i=0;$i<sizeof($block_ids);$i++){ if (!empty($block_ids[$i])) { $query_string .= " and p.products_id != '$block_ids[$i]'"; } } $query_string = " and (".substr($query_string, 5).")"; if (eregi("[a-zA-Z]", $category_id)) { $getCategory = mysql_query("select category_top_id, category_top_name, copy from category_top where category_top_name='".eregi_replace("\-"," ",$category_id)."'"); if (mysql_num_rows($getCategory)>0) { $categoryImage = $category_id; $category = mysql_fetch_array($getCategory); $category_id = $category[category_top_id]; $category_copy = $category['copy']; } } # gets the html files from the directory supplied and spits out the url (must be .html files). function randlink($dizin) { $filelist=array(); $handle=opendir("$dizin"); while ($filename = readdir($handle)) { if ($file != "." && $file != "..") { $ext=substr($filename,-5); if ($ext == ".html") { $file=substr($filename,0,-5); array_push($filelist, "$file.html"); } } } srand ((double) microtime() * 10000000); $rk = array_rand($filelist); # return a random link return "$dizin/$filelist[$rk]"; } $pageTitle = "generic text."; if ($category[category_top_id]){ $pageTitle = $category[category_top_name]. ", generic text."; } $pageKeywords = "generic text."; $pageDescription = "generic text."; $include_file = DIR_INCLUDES . 'header.php'; include(DIR_INCLUDES . 'include_once.php'); if (!$category_id) {?> <P style="MARGIN-TOP: 25px"><IMG title="generic text" style="FLOAT: right; MARGIN-BOTTOM: 10px; MARGIN-LEFT: 20px" alt="text" src="/images/template/picture.jpg">generic text.</P> <P>generic text.</P> <P>generic text<SMALL><SUP>TM</SUP></SMALL>, generic text.</P> <P>Call <STRONG>phone number</STRONG> for your nearest representative.</P><? # include(randlink("/home/users/web/b2635/webdomain/public_html/includes/splash/")) ?><!--img src="/images/trends_report3.jpg" border="0" alt="Welcome to <?print STORE_NAME;?>" width="550" height="334" /--><BR> <DIV align=center><BR><BR><!--<p>generic text <a href="about.php">about us</a> page.</p>--><? } else { $query = " (SELECT p.products_name, p.products_image, p.products_price, p.products_url, p.products_id, p.colour, p.variation, s.subcategories_name FROM products p, subcategories s, products_to_subcategories ps, subcategories_to_category sc WHERE sc.category_top_id='$category_id' and sc.subcategories_id=ps.subcategories_id and ps.products_id=p.products_id and p.products_quantity > 0 and ps.subcategories_id=s.subcategories_id and p.variation != '' $query_string GROUP BY p.products_id, p.variation) The blue line is the problem one. thanks
Replace if (!$category_id) {?> Code (markup): ... with if (!$category_id) {?> Code (markup): That should fix it. P.S.: You should use "<?php" instead of "<?". That's a bad habit.