localhost Posted June 27, 2006 Share Posted June 27, 2006 heres my code, big but the main area is near $num_rows1.it works, it displays NEVER if there is less than 1 row in content where type==3. but gives this error:Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/dotomega/public_html/forums/index.php on line 130[code]<?php/*======================================================================*\|| #################################################################### |||| # .Omega Community System 2006 version 0.6 # |||| # ---------------------------------------------------------------- # |||| # Copyright ©2006 dotOmega # |||| # This file may not be redistributed in whole or significant part. # |||| # ---------------- DOTOMEGA IS NOT FREE SOFTWARE ----------------- # |||| # http://dotomega.com | http://licence.dotomega.com # |||| #################################################################### ||\*======================================================================*/ob_start();// ************************* INCLUDE BACK-END ************************* //include('includes/config.php');include('includes/connect.php');include('includes/tree.php');include('includes/nest.php');include('includes/var.php');// ************************ START DRAWING PAGE ************************ //include('global/global_header.php');print "<head><title>$PAGE_TITLE - Powered by .Omega</title></head><body>";/* ****** PRINT HERE WHAT YOU WANT NOT TO BE REPEATED ****** */print "<td class='groupHeaderRight'> </td></tr></table></div><div id='forumGroupDiv_1'><table id='forumGroupBox_1' cellspacing='0px' class='groupBox'><tr><td class='groupBoxSpacer'> </td><td class='groupBoxArea'><table id='fg_1' cellspacing='0px'><thead><tr><td id='ffco_1' class='forumForumsCol'><a href='#' title='Sort Column by Forum Title'>Forums</a></td><td id='flco_1' class='forumLastPostCol'><a href='#' title='Sort Column by Last Post'>Last Post</a></td><td id='ftco_1' class='forumThreadsCol'><a href='#' title='Sort Column by Number of Threads'>Threads</a></td><td id='fpco_1' class='forumPostsCol'><a href='#' title='Sort Column by Number of Posts'>Posts</a></td></tr></thead>";/* ****** END PRINT FOR NON REPEATING STYLE ****** */$flag="off";$view = @$_GET['view'];if ($view==""){$view=0;}$query = "SELECT * FROM content WHERE id = '$view'";$result = mysql_query($query) or die('Query failed: ' . mysql_error() . '<hr>There has been an error in the application, please contact the administrator<hr><b>Error: E001</b>');while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){$sectiontext = $row['text'];$sectionstatus = $row['status'];$sectionauth = $row['auth'];$sectiontype = $row['type'];}if ($LOGIN_METHOD == "COOKIE"){$user_name = @$_COOKIE["DotOmega1"];$auth = @$_COOKIE["DotOmega2"];$uid = @$_COOKIE["DotOmega3"];if (($user_name=="")||($auth=="")||($uid=="")){$user_name = "Guest";$auth = "100";$uid = "0";}}if ($LOGIN_METHOD == "SESSION"){session_start(); if ((isset($_SESSION['user_name']))&&(isset($_SESSION['auth']))&&(isset($_SESSION['uid']))){$user_name = $_SESSION['user_name'];$auth = $_SESSION['auth'];$uid = $_SESSION['uid'];} else {$user_name = "Guest";$auth = "100";$uid = "0";}}/* ****** CHECK IF THE INSTALL DIRECTORY STILL EXISTS ****** */$filename = "install/";if (file_exists($filename)) {print "<Center><b><BR><BR>Forums will not be displayed until the /install/ directory is deleted or renamed for security purposes.";} else {/* ****** DISPLAY WELCOME MESSAGE BASED ON WETHER THE USER IS LOGGED IN OR NOT ****** */ if ($user_name = "Guest") { print "<p align=left><div id=\"login_id\">\n\r\tWelcome, Guest.<BR>";} else { print " Welcome, $user_name. <BR> <A href=logout.php>Logout?<BR></a> </div> <div id=\"navbar\"> </p> "; }/* ****** END OF WELCOME MESSAGE TO FORUM USER ****** *//* ****** QUERY TO CHECK LATEST THREAD IN CERTAIN FORUM ****** */$queryl = "SELECT * FROM content WHERE type='3'"; // Selects all from content where type is equal to 3, 3 is the title of the thread$resultl = mysql_query($queryl) or die('Could not select the title of thread');$num_rows1 = mysql_num_rows($result1);while ($row = mysql_fetch_array($resultl, MYSQL_ASSOC)){$thread_id = $row['id'];$thread_title = $row['text'];$thread_starter = $row['starter'];}/* ****** END OF CHECKING LATEST THREADS IN CERTAIN FORUM ****** */$forumpath = tree($view, "");if($user_name=="Guest") {include('global/global_login.php');} else { }print "</div>";$header=0;$query = "select * from content where parentID = '$view' order by `order` asc";$result = mysql_query($query) or die('Query failed: ' . mysql_error() . '<hr>SQL error 1<hr>');while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){$id = $row['id'];$parentid = $row['parentid'];$order = $row['order'];$text = $row['text'];$date = $row['date'];$alttext = $row['alttext'];$icon = $row['icon'];$type = $row['type'];$status = $row['status'];$sectionauth = $row['auth'];$poster = $row['poster'];$mod = $row['mod'];$count1 = $row['count1'];$count2 = $row['count2']; switch ($type) { case "0": //0 - Page furniture if ($header==0) { $header=1;print "<div id=\"forum\"><div id=\"titles\"><div id=\"head1\">$sectiontext</div><div id=\"head2\">Topics</div><div id=\"head3\">Posts</div><div id=\"head4\">Last Post</div></div><div id=\"thread_holder\">";} // print "<span class=\"cat_tit\">\r\n // \r\n"; // include ("$text"); // print "\r\n\r\n</span> // \r\n"; // nest($id); break;case "1": //1 - Divider if ($header==0) { $header=1; print " <div id=\"forum\"> <div id=\"titles\"> <div id=\"head1\"> $sectiontext </div> <div id=\"head2\"> Topics </div> <div id=\"head3\"> Posts </div> <div id=\"head4\"> Last Post </div> </div> <div id=\"thread_holder\"> "; } // print "<tr class=\"cat_tit\"> // <td colspan=\"5\"><h1><a href=\"?view=$id\" alt=\"$alttext\">$text</a></h1></td>\r\n // </tr>\r\n"; //nest($id); break;case "2": //2 - Forum if ($header==0) { $header=1;/* FOR BELOWhead4 - Last Posthead3 - postshead2 - topicshead1 - $sectiontext*/ print " <div id=\"forum\"> <div id=\"titles\"> <div id=\"head1\"> </div> <div id=\"head2\"> </div> <div id=\"head3\"> </div> <div id=\"head4\"> </div> </div> <div id=\"thread_holder\"> "; }/* ****** PRINT WHAT YOU WANT FOR EACH FORUM ****** */ print "<? xml version='1.0' encoding='UTF-8' ?><!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'><html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'> <head> <base href='http://www.dotomega.com/forums' /> <!-- Start Stylesheets --> <link rel='stylesheet' href='/themes/omega06/ocean/global.css' media='screen' title='ocean' /> <link rel='stylesheet' href='/themes/omega06/ocean/home.css' media='screen' title='ocean' /> <!-- End Stylesheets --> </head> <body> <!-- Start JavaScript --> <script type='text/javascript' src='/jscript/omega.js'></script> <script type='text/javascript' src='/jscript/omegaDrag.js'></script> <script type='text/javascript' src='/jscript/omegaPage.js'></script> <script type='text/javascript'> omega.changeStyle('ocean'); </script> <!-- End JavaScript --> <tbody> <tr id='ftr_1' class='forumRow'> <td id='ffce_1' class='alt1'> <div id='ffdiv_1' sort='announcements'> <table class='forumTitleTable' cellspacing='5px'><tr> <td id='fiarea_1' class='fiarea' rowspan='3'> <span id='fiareai_1' class='forumNew'></span> </td> <td id='ffarea_1' class='ffarea'> <span class='forumTitle'><a href='?view=$id' title='View $text'>$text</a></span> </td> <td id='frarea_1' class='frarea' rowspan='3'> <img alt='View RSS Feed of Announcements' src='/themes/omega06/ocean/icons/rss.gif' style='height:12px;width:12px;'/> </td> </tr><tr> <td id='fdarea_1' class='fdarea'> <span class='forumDescription'>$alttext</span> </td> </tr></table> </div> </td> <td id='flce_1' class='alt2'> <div id='fldiv_1' sort='20060501'> <table class='forumLastPostTable' cellspacing='5px'><tr> "; if($numrows<1) { echo "NEVER"; } else { print "<td id='fnarea_1' class='fnarea' colspan='2'> <img alt='Post Icon' src='/themes/omega06/ocean/posticons/whatever.gif' style='height:12px;width:12px;'/> <a href='$siteurl/?view=$thread_id' title='View $thread_title'>$thread_title</a> </td> </tr><tr> <td id='fbarea_1' class='fbarea'> by <a href='$siteurl/profile.php?u=$thread_starter' title='View $thread_starter's profile'>$thread_starter</a> </td> <td id='fdaarea_1' class='fdaarea'> <span>Today</span> <span class='greyed'>00:13am</span> <img alt='View Last Post in Thread' src='/themes/omega06/ocean/icons/lastpost.gif' style='height:12px;width:12px;'/> </td> </tr></table> </div> </td> <td id='ftce_1' class='alt1'> $count2 </td> <td id='fpce_1' class='alt2'> Not yet implemented </td> </tr><Br> </body></html>";}/* ****** END INDIVIDUAL FRONT PAGE FORUM DISPLAY ****** */ break; case "3": //thread if ($header==0) { $header=1; } print "<div id=\"f_n_t\" class=\"fnt_class\" onmouseover=\"this.className='fnt_class_hover';\" onmouseout=\"this.className='fnt_class';\"> <div id=\"icon\"> Thread Icon </div> <div id=\"title_text\"> <div id=\"main_title\"> <a href=\"?view=$id\">$text</a> </div> <div id=\"alt_text\"> </div> </div> <div id=\"count1\"> $count1 </div> <div id=\"count2\"> $count2 </div> <div id=\"last_post\"> last post yet to be implemented </div> </div> "; break; case "4": //post $querys = "select * from users where uid = '$poster';"; $results = mysql_query($querys) or die('Query failed: ' . mysql_error() . '<hr>SQL error 1<hr>'); while ($rows = mysql_fetch_array($results, MYSQL_ASSOC)) { $select_user_name = $rows['username']; $postcount = $rows['postcount']; $users_avatar = $rows['avatar']; $users_tag = $rows['tag']; $users_icq = $rows['icq']; $users_msn = $rows['msn']; $users_yim = $rows['yim']; } print "<div id=\"post_holder\"> <div id=\"poster_details\"> <div id=\"post_ID\"> $id </div> <div id=\"post_username\"> <A href='profile.php?u=$select_user_name'>$select_user_name</a> </div> <div id=\"post_avatar\">"; if ($users_avatar!=NULL) { print "<img src=\"$users_avatar\">"; } print " </div> <div id=\"post_tag\"> $users_tag </div> <div id=\"post_postcount\"> Post count: $postcount </div> </div> <div id=\"post_relevant\"> <div id=\"post_title\"> $alttext</div> <div id=\"post_body\"> $text </div> </div> <div id=\"post_buttons\"> "; if (($user_name!="Guest")&&($uid==$poster)) { print "<form action=\"edit.php\" method=\"post\"> <input type=\"hidden\" name=\"p\" value=\"$id\" /> <input type=\"hidden\" name=\"v\" value=\"$view\" /> <input type=\"hidden\" name=\"u\" value=\"$user_name\" /> <input type=\"submit\" value=\"EDIT POST\" />"; if ($users_icq!=NULL) { print " User has ICQ "; } if ($users_msn!=NULL) { print " User has MSN "; } if ($users_yim!=NULL) { print " User has YIM "; } print "</form>"; } print "</div> </div>"; break;/*0 - Page furniture1 - Divider2 - Forum3 - thread4 - Post*/ }}if ($flag!="on"){ print "</div><div id=\"ftbuttons\"> "; // changed for development, guessts cannot start threads. // if (($sectiontype!=3)&&($sectiontype!=4)&&($auth<=$sectionpermisson)) if (($sectiontype!=3)&&($sectiontype!=4)) { if (($view==0)&&($ALLOW_MAIN_PAGE_THREADS == "NO")) { echo ""; } else { print "<a href=$siteurl/new.php?view=$view&type=3>New thread</a>"; } } if ($sectiontype==3) { print "<a href=\"new.php?view=$view&type=4\">Post reply</a>"; } print " </div> ";}print "</div><div id=\"users_online\">";if ($view=="0"){ // include("members.php"); commented out for theme to work right now...}if ($uid==0){ // comment}print "</div></body></html>";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12976-num-rows-not-working/ Share on other sites More sharing options...
AndyB Posted June 27, 2006 Share Posted June 27, 2006 Two comments.#1 - this is obviously a third party script so I'm moving it to the right forum#2 - if you want help, please point out where in all that stuff you think the error arises. I don't have time to wade through it and probably nobody else will. Quote Link to comment https://forums.phpfreaks.com/topic/12976-num-rows-not-working/#findComment-49904 Share on other sites More sharing options...
localhost Posted June 27, 2006 Author Share Posted June 27, 2006 as i said, the error occurs near $num_rows1, do a search, it occurs 3 times all near each other. Quote Link to comment https://forums.phpfreaks.com/topic/12976-num-rows-not-working/#findComment-49957 Share on other sites More sharing options...
localhost Posted June 27, 2006 Author Share Posted June 27, 2006 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/12976-num-rows-not-working/#findComment-50082 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.