Jump to content

Parse error: syntax error


rweaver

Recommended Posts

HI at the moment i have a problem with the index php on my website  Parse error: syntax error, unexpected T_STRING, expecting '{' in /home/classads/public_html/index.php on line 8  the line in question-$titleinfo =SITENAME;class ads uk.com -when the classadsuk.com section is removed the web site comes up (a classified ads website)but when i go to a section or page i get this -Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/classads/public_html/classifieds.php on line 40-i think the problem occured when i highlighted the the index to copy so i could practice on a seperate editor ithink the script may have got backed up on itself when highlited i would appreciate any help or ideas. Thanks russ

Link to comment
Share on other sites

<?php

session_start();

include 'includes/configdb.php';

include 'includes/functions.php';

include "language/".LANGUAGE.".php";

 

/* SET BROWSER TITLE INFO */

$titleinfo =SITENAME;class ads uk

   

/* CALL TEMPLATE HEADER */

include 'template/bmheader.php';

 

?>

<!-- START CATEGORY TABLE - DISPLAYS ALL CATEGORIES -->

<table class='category'>

<tr>

<td class='catcolumn'>

 

<?

/* SET ARRAY TO HOLD PARENT CAT TOTALS */

$tcount=array();

 

/* QUERY FOR PARENT CATEGORY TOTALS */

 

mysql_select_db($dbname,$dbc);

$bmquerycnt1 = "SELECT t1.category_id as ID1, t2.category_id as ID2, COUNT(t3.listing_id) as numtotal FROM categories AS t1

LEFT JOIN categories AS t2 ON t1.category_id=t2.parent_id

LEFT JOIN listings AS t3 ON t2.category_id=t3.category_id

WHERE ((t2.parent_id != '0') AND (t3.expiredate >= CURDATE()) AND (t3.complete!='0'))

GROUP BY ID1";

 

$resultcnt1=mysql_query($bmquerycnt1);

 

$parentcounts=array();

 

while ($row = mysql_fetch_assoc($resultcnt1)) {

$parentcounts[$row['ID1']]=$row['numtotal'];

    }

 

/* QUERY TO DISPLAY SUBCATEGORY TOTALS */

 

 

mysql_select_db($dbname,$dbc);

$bmquerytcnt2 = "SELECT t3.category_id as ID3, COUNT(t3.listing_id) as numtotal2 FROM categories as t1

LEFT JOIN categories AS t2 ON t1.category_id=t2.parent_id

LEFT JOIN listings AS t3 ON t2.category_id=t3.category_id

WHERE ((t2.parent_id != '0') AND (t3.expiredate >= CURDATE()) AND (t3.complete!='0'))

GROUP BY ID3";

 

$resulttcnt2=mysql_query($bmquerytcnt2);

 

$catcounts=array();

 

while ($row = mysql_fetch_assoc($resulttcnt2)) {

$catcounts[$row['ID3']]=$row['numtotal2'];

    }

 

 

/* QUERY TO DISPLAY CATEGORIES AND SUBCATEGORIES */

 

mysql_select_db($dbname,$dbc);

$bmquery = "SELECT t1.category_id as ID1, t2.category_id as ID2, t1.categoryname, t2.categoryname AS subcatname, COUNT(t3.listing_id) as numads FROM categories AS t1

LEFT JOIN categories AS t2 ON t1.category_id=t2.parent_id

LEFT JOIN listings AS t3 ON t2.category_id=t3.category_id

WHERE (t2.parent_id != '0')

GROUP BY ID2

ORDER BY t1.weight, categoryname, t2.weight, subcatname";

 

$result=mysql_query($bmquery);

$num_rows = mysql_num_rows($result);

 

 

$last_category='';

$last_rowcolor='subrow1';

$rowcount=0;

$rowmax=(ceil($num_rows/4)-3); // IF ROW BREAKS ARE VERY UNEVEN, ADJUST THE LAST NUMBER

 

while ($row = mysql_fetch_assoc($result)) {

 

$category=$row['categoryname'];

    $parID=$row['ID1'];

    $catID=$row['ID2'];

    $subcat=$row['subcatname'];

    $count=$row['numads'];

   

   

   

    ++$rowcount;

   

/* DISPLAYS ALL CATEGORIES, TOTALS, AND SUBTOTALS */

 

if ($last_category != $category) {

if ($last_category != '') {if($rowcount > $rowmax){$rowcount=1; echo "</table></td><td class='catgutter'></td><td class='catcolumn'><table class='catheader'><tr><td class='catheadl'>".$category."</td><td class='catheadr'>".$parentcounts[$parID]."</td></tr></table><table class='subcats'>"; $last_rowcolor='subrow1';} else {echo "</table><table class='catheader'><tr><td class='catheadl'>".$category."</td><td class='catheadr'>".$parentcounts[$parID]."</td></tr></table><table class='subcats'>"; $last_rowcolor='subrow1';}} else

{echo  "<table class='catheader'><tr><td class='catheadl'>".$category."</td><td class='catheadr'>".$parentcounts[$parID]."</td></tr></table><table class='subcats'>";}

$last_category = $category;

}

else {}

 

$last_category = $category;

 

if ($last_rowcolor == 'subrow1') {

$subrow = 'subrow2';} else {$subrow = 'subrow1';}

$last_rowcolor=$subrow;

 

if($catcounts[$catID]==''){$subtotal='0';} else {$subtotal=$catcounts[$catID];}

 

$linkcat=str_replace('&', '', $category);

$linkcat=str_replace('  ', '-', $linkcat);

$linkcat=str_replace(' ', '-', $linkcat);

$linkcat=strtolower($linkcat);

 

 

$linksub=str_replace('&', '', $subcat);

$linksub=str_replace(',', '', $linksub);

$linksub=str_replace('  ', '-', $linksub);

$linksub=str_replace(' ', '-', $linksub);

$linksub=str_replace('.', '', $linksub);

$linksub=strtolower($linksub).".html";

 

echo "<tr><td class='".$subrow."' align='left'><a class='subcat' href='classifieds/shenandoah/".$catID."/".$linkcat."/".$linksub."'>".$subcat."</td><td class='".$subrow."' align='right'>".$subtotal."</td></tr>";

}

echo '</table>';

 

echo"</td></tr></table><!-- END CATEGORY TABLE -->";

if(SHOW_NEW_ADS=='true'){include 'includes/newads.php'; }

include 'template/bmfooter.php'; ?>

 

Link to comment
Share on other sites

yes as i remove "the class ads uk" the template loads up with no errors but then i go a to a catagory ie-Electronics:classified ads-cameras- i get this at the top-Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/classads/public_html/classifieds.php on line 40- and this in the catorgory section-Error, query failed-iwill post the classified.php seperatly.

Link to comment
Share on other sites

<?php

include 'includes/functions.php';

include 'includes/configdb.php';

include 'language/'.LANGUAGE.'.php';

 

// This sets how many ads to show per page

$rowsPerPage = 15;

 

// Do not change

$pageNum = 1;

 

if($_GET['page']!=''){

 

// if page number is passed in use it as page number

if(isset($_GET['page']))

{

    $pageNum = $_GET['page'];

}

}

// set the page offset

$offset = ($pageNum - 1) * $rowsPerPage;

 

$zone = ''; // Reset zone variable

 

$catID=$_GET['cat'];

 

mysql_select_db($dbname,$dbc);

$bmqueryc = "SELECT t1.categoryname, t2.categoryname as parentcat, t2.category_id as back, t1.category_id as zone FROM categories as t1

LEFT JOIN categories AS t2 ON t2.category_id=t1.parent_id

WHERE t1.category_id=".smart($catID)."";

$result1=mysql_query($bmqueryc);

 

mysql_select_db($dbname,$dbc);

$bmquery = "SELECT t1.title, t1.description, t1.price, t1.listing_id, t1.photo1, date_format(t1.startdate,'%b %D') as listdate, t1.top, t2.city, t2.state FROM listings AS t1

LEFT JOIN users as t2 on t1.owner_id = t2.user_id

WHERE ((t1.category_id = '".smart($catID)."') AND (t1.expiredate >= CURDATE()) AND (complete!='0')) ORDER BY top DESC, listing_id DESC LIMIT ".smart($offset).", ".smart($rowsPerPage)."";

 

$result2=mysql_query($bmquery);

 

while ($row = mysql_fetch_assoc($result1)) {    <this is line 40

$categoryhead=$row['categoryname'];

$parentcat=$row['parentcat'];

$back=$row['back'];

$zone=$row['zone'];

}

$titleinfo = $parentcat.": ".$categoryhead;

include 'template/bmheader.php';

 

echo "<p class='catpagehead'><a href='index.php' class='catpagehead'>".LANG_MENU_HOME."</a> &#187; <a href='subcats.php?cat=".$back."' class='catpagehead'>$parentcat:</a>  $categoryhead</p>

 

<!-- START LISTINGS TABLE - DISPLAYS ALL CATEGORIES -->

 

<table class='listings'>

<tr>

<td class='listings'>

<table class='listheader'><tr><td class='listheader1'></td><td class='listheader2'>".LANG_LIST_ITEM."</td><td class='listheader3'>".LANG_LIST_PRICE."</td><td class='listheader4'>".LANG_LIST_LOCATION."</td><td class='listheader5'>".LANG_LIST_POSTED."</td></tr></table>";

 

 

while ($row = mysql_fetch_assoc($result2)) {

 

$title=$row['title'];

$description=strip_tags($row['description']);

$price=$row['price'];

$city=$row['city'];

$state=$row['state'];

$photo1=$row['photo1'];

$listdate=$row['listdate'];

$listingid=$row['listing_id'];

$top=$row['top'];

   

if($price==''){$price="N/A";}else{$price=curr($price);}

if($top=='1'){$boxclass='listrowt';}else{$boxclass='listrow';}

   

$description = trunc($description, 120);

if($photo1==''){$thumb='nophoto.jpg';}else{$thumb=$photo1;}

 

echo "<tr>

<td>

<table class='".$boxclass."'>

<td class='listthumb' rowspan=2><a href='showad.php?listingid=".$listingid."&cat=".$catID."&page=".$pageNum."' class='item'><img src='../thumbs/".$thumb."' border='0' width='60px' height='45px'></a></td>

<td class='listtitle'><a href='showad.php?listingid=".$listingid."&cat=".$catID."&page=".$pageNum."' class='item'>".$title."</a></td>

<td class='listprice'>".$price."</td>

<td class='listcitystate'>".$city.", ".$state."</td>

<td class='listdate'>".$listdate."</td>

</tr><tr>

<td class='listdescription' colspan=4>".$description."</td>

</tr>

</table>

</td>

</tr>";

}

?>

 

</td>

</tr><tr>

<td class='botnav'>

 

<?php

// determine how many rows in results

mysql_select_db($dbname,$dbc);

$bmqueryx = "SELECT COUNT(listing_id) AS numrows FROM listings

WHERE ((category_id = ".smart($catID).") AND (expiredate >= CURDATE()))";

$resultx  = mysql_query($bmqueryx) or die('Error, query failed');

$row = mysql_fetch_array($resultx, MYSQL_ASSOC);

$numrows = $row['numrows'];

 

// calculate total pages

$maxPage = ceil($numrows/$rowsPerPage);

 

// CREATE NAVIGATION LINKS

// create individual page links

$self = $_SERVER['PHP_SELF'];

$nav  = '';

 

for($page = 1; $page <= $maxPage; $page++)

{

  if ($page == $pageNum)

  {

      $nav .= "<span class='current'>$page </span>"; // current page

  }

  else

  {

      $nav .= "<a href=\"$self?page=$page&cat=$catID\" class='botnav'>$page</a> ";

  }

}

 

// create previous and next links, first and last page links

 

if ($pageNum > 1)

{

  $page  = $pageNum - 1;

  $prev  = "<a href=\"$self?page=$page&cat=$catID\" class='botnav'>&#060; ".LANG_NAV_PREV."</a>    ";

 

  $first = "<a href=\"$self?page=1&cat=$catID\" class='botnav'>&#060;&#060;".LANG_NAV_FIRST."</a>    ";

}

else

{

  $prev  = '&#060; '.LANG_NAV_PREV.'    '; // dead if first page

  $first = '&#060;&#060;'.LANG_NAV_FIRST.'    '; // dead if first page

}

 

if ($pageNum < $maxPage)

{

  $page = $pageNum + 1;

  $next = "   <a class='botnav' href=\"$self?page=$page&cat=$catID\">".LANG_NAV_NEXT." &#062;</a>";

 

  $last = "    <a class='botnav' href=\"$self?page=$maxPage&cat=$catID\">".LANG_NAV_LAST."&#062;&#062;</a>";

}

else

{

  $next = '   '.LANG_NAV_NEXT.' &#062;'; // dead if last page

  $last = '    '.LANG_NAV_LAST.'&#062;&#062;'; // dead if last page

}

 

// print all navigation links

echo $first.$prev.$nav.$next.$last;

 

?>

 

</td></tr>

</table>

<!-- END LISTINGS TABLE -->

 

<?php

include 'template/bmfooter.php';

?>

 

Link to comment
Share on other sites

a few things...

 

POST ALL CODE INSIDE OF php tags. It helps us, a LOT.

 

is there any where else i can maybe  get help with this problem

the reason why no one was helping you is you post 400 freaking lines of code. We don't want to look through all of it. Look the revelant code only. The general area you think the error is.

 

sorry i dont understand this is only the first time ive used a forum of any kind

did you click the link in his footer and actuially look at it. post your code in php tags.... it makes it look like this...

 

(click "quote" on my response, and you'll see how i formatted the php tags to make it colored)

 

<?php
echo "post in the freaking php tags";
?>

as you can see, that helps us.

 

 

Now to the acutal error itself...

mysql_fetch_assoc() only works is there  are rows for it to parse...you would have to do something like this:

 

if(mysql_num_rows($res) == 1){
$row = mysql_fetch_assoc($res); 
}

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.