rweaver Posted May 9, 2009 Share Posted May 9, 2009 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 Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted May 9, 2009 Share Posted May 9, 2009 post the code or we can't really help... but i can pretty much guarantee that you're missing a " ; " Quote Link to comment Share on other sites More sharing options...
rweaver Posted May 9, 2009 Author Share Posted May 9, 2009 <?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'; ?> Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 9, 2009 Share Posted May 9, 2009 Read #4 of Forum DOs. Click that link in my sig. $titleinfo =SITENAME;class ads uk ^ there's the error. See anything wrong? Quote Link to comment Share on other sites More sharing options...
rweaver Posted May 10, 2009 Author Share Posted May 10, 2009 $titleinfo =SITENAME;class ads uk ^ there's the error. See anything wrong? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 ... What? Quote Link to comment Share on other sites More sharing options...
rweaver Posted May 10, 2009 Author Share Posted May 10, 2009 i know where the problem is if i knew the answer or could see any thing wrong i would have it fixed by now,can any one see if i have missed ; out anywhere as suggested in the first reply Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 Can you remove the 'class ads uk' part? Quote Link to comment Share on other sites More sharing options...
rweaver Posted May 10, 2009 Author Share Posted May 10, 2009 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. Quote Link to comment Share on other sites More sharing options...
rweaver Posted May 10, 2009 Author Share Posted May 10, 2009 <?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> » <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'>< ".LANG_NAV_PREV."</a> "; $first = "<a href=\"$self?page=1&cat=$catID\" class='botnav'><<".LANG_NAV_FIRST."</a> "; } else { $prev = '< '.LANG_NAV_PREV.' '; // dead if first page $first = '<<'.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." ></a>"; $last = " <a class='botnav' href=\"$self?page=$maxPage&cat=$catID\">".LANG_NAV_LAST.">></a>"; } else { $next = ' '.LANG_NAV_NEXT.' >'; // dead if last page $last = ' '.LANG_NAV_LAST.'>>'; // 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'; ?> Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 Read #4 of Forum DOs. Click that link in my sig. Please! Quote Link to comment Share on other sites More sharing options...
rweaver Posted May 10, 2009 Author Share Posted May 10, 2009 sorry i dont understand this is only the first time ive used a forum of any kind Quote Link to comment Share on other sites More sharing options...
rweaver Posted May 10, 2009 Author Share Posted May 10, 2009 is there any where else i can maybe get help with this problem Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted May 10, 2009 Share Posted May 10, 2009 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); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.