verano Posted November 21, 2010 Share Posted November 21, 2010 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resourc The line that this is referring to is.... while($r=mysql_fetch_array($result)) Quote Link to comment Share on other sites More sharing options...
shlumph Posted November 21, 2010 Share Posted November 21, 2010 $result is not a valid MySQL result resource. And we have no idea how $result was created Quote Link to comment Share on other sites More sharing options...
revraz Posted November 21, 2010 Share Posted November 21, 2010 Means your query is failing. Quote Link to comment Share on other sites More sharing options...
verano Posted November 21, 2010 Author Share Posted November 21, 2010 exactly... what more information can i provide to research further. Quote Link to comment Share on other sites More sharing options...
revraz Posted November 21, 2010 Share Posted November 21, 2010 Fix your query.. use mysql_error after it and/or echo your query to make sure its ok Quote Link to comment Share on other sites More sharing options...
verano Posted November 21, 2010 Author Share Posted November 21, 2010 i know, i found this.. $definamge = $r["defimage"]; and updated it to.. $defimage = $r["defimage"]; error still exists Quote Link to comment Share on other sites More sharing options...
revraz Posted November 21, 2010 Share Posted November 21, 2010 That isn't your query. Quote Link to comment Share on other sites More sharing options...
verano Posted November 21, 2010 Author Share Posted November 21, 2010 I guess thats the part I dont understand. I tried.. $result = mysql_query($sql) or die(mysql_error()); but response was query is empty Quote Link to comment Share on other sites More sharing options...
verano Posted November 21, 2010 Author Share Posted November 21, 2010 How do I view my query? Quote Link to comment Share on other sites More sharing options...
revraz Posted November 21, 2010 Share Posted November 21, 2010 Post your code. To view your query, echo $sql Quote Link to comment Share on other sites More sharing options...
verano Posted November 21, 2010 Author Share Posted November 21, 2010 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource on line 47 for header.php... <? include "header2.php"; include "config.php"; $db = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db ($db_name) or die ("Cannot connect to database"); //Get the data $query = "SELECT sitename, forumname, sitetitle, menulink, normallink, defimage, defsig, backcolor, msitecolor, siteurl, headimage, hiwidth, hiheight FROM prefs"; $result = mysql_query($query); /* Here we fetch the result as an array */ while($r=mysql_fetch_array($result)) { /* This bit sets our data from each row as variables, to make it easier to display */ $sitename = $r["sitename"]; $forumname = $r["forumname"]; $sitetitle = $r["sitetitle"]; $menulink = $r["menulink"]; $normallink = $r["normallink"]; $defimage = $r["defimage"]; $defsig = $r["defsig"]; $backcolor = $r["backcolor"]; $msitecolor = $r["msitecolor"]; $siteurl = $r["siteurl"]; $headimage = $r["headimage"]; $hiwidth = $r["hiwidth"]; $hiheight = $r["hiheight"]; ?> <table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td bgcolor="<?=$msitecolor;?>"> <? if ($_SESSION['Username'] == "" AND $_SESSION['Logged_In'] != "True" OR $_SESSION['Logged_In'] == "True-Admin") { $log_button = "<a href=\"login.php\" class=\"menu\">Login</a>"; } else { $log_button = "<a href=\"login.php?mode=logout\" class=\"menu\">Logout</a>"; } ?><a href="index.php" class="menu"><b>The <?=$sitename;?> Forum</b></a></td><td bgcolor="<?=$msitecolor;?>" align="right"> <a href="post.php?c=<?=$_GET['c'];?>" class="menu">New Thread</a> <a href="search.php" class="menu">Search</a> <a href="stat.php" class="menu">Statistics</a> <a href="accounts.php" class="menu">Account Settings</a> <?=$log_button;?> </td></tr><tr><td bgcolor="<?=$msitecolor;?>" colspan="2" align="center"> <? } mysql_close($db); //connection to database include "config.php"; $db = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db ($db_name) or die ("Cannot connect to database"); $query = "SELECT category FROM fcat ORDER BY id LIMIT 0,2"; $result = mysql_query($query); while($r=mysql_fetch_array($result)) { $cname=$r["category"]; echo "<b><a href=\"list.php?c=$cname\" class=\"menu\">$cname</a> </b>"; } mysql_close($db); ?> <b><a href="listcat.php" class="menu">List All</a></b> </td></tr></table> This is line 47... $defimage = $r["defimage"]; Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource on line 20 for index.php... <? session_start(); // This forum was developed by Adam M. B. from aWeb Labs // Visit us at http://www.labs.aweb.com.au // for forum problems, bugs, or ideas email yougotmail@gmail.com // thanks for trying out or using this forum // aWebBB version 1.2 released under the GNU GPL include "header.php"; ?> <div align="center"> <div class="side-headline"><b>Forum Index:</b></div><br> <table cellpadding="0" cellspacing="0" border="0"><tr><td valign="top"> <? include "config.php"; $db = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db ($db_name) or die ("Cannot connect to database"); $query1 = "SELECT category, description FROM fcat ORDER BY category DESC"; $result1 = mysql_query($query1); while($r=mysql_fetch_array($result1)) { $category = $r["category"]; $description = $r["description"]; ?> <div class="bluein-box"> <table cellpadding="0" cellspacing="0" border="0" width="350"><tr><td width="4"></td><td width="130" valign="top"> <b><a href="list.php?c=<?=$category;?>"><?=$category;?>:</a></b></td><td width="60" valign="top"><b>Topics:</b><br> <? $query3="SELECT * FROM flist WHERE categories = '$category'"; $result3 = mysql_query($query3); $num_rows3 = mysql_num_rows($result3); echo "$num_rows3"; ?> </td><td width="60" valign="top"><b>Posts:</b><br> <? $query2="SELECT * FROM forum WHERE categories = '$category'"; $result2 = mysql_query($query2); $num_rows2 = mysql_num_rows($result2); echo "$num_rows2"; ?> </td><td width="100" valign="top"><b>Last Post:</b><br> <? $query5 = "SELECT time, date FROM forum WHERE categories = '$category' ORDER BY date DESC LIMIT 0,1"; $result5 = mysql_query($query5); /* Here we fetch the result as an array */ while($r1=mysql_fetch_array($result5)) { $time=$r1["time"]; $date=$r1["date"]; ?> <?=$date;?> @ <?=$time;?> <? } ?> </td></tr></table> </div> <? } mysql_close($db); ?> </td><td valign="top"> <div class="greyin-box"> <table cellpadding="0" cellspacing="0" border="0" width="300"><tr><td width="300" valign="top"><b>Recent Posts:</b><br><br> <? include "config.php"; $db = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db ($db_name) or die ("Cannot connect to database"); //Get the data $query = "SELECT id, tid, categories, tname, poster, fpost, sig, avatar, time, date FROM forum ORDER BY date DESC LIMIT 0,7"; $result = mysql_query($query); /* Here we fetch the result as an array */ while($r=mysql_fetch_array($result)) { $id=$r["id"]; $tid=$r["tid"]; $categories=$r["categories"]; $tname=$r["tname"]; $poster=$r["poster"]; $fpost=$r["fpost"]; $sig=$r["sig"]; $avatar=$r["avatar"]; $time=$r["time"]; $date=$r["date"]; echo "<a href=\"ndis.php?c=$categories&tid=$tid&t=$tname\"><b>$tname</b> by $poster<br></a>"; } ?> </td></tr></table></div> </td></tr></table> <? echo "</div>"; include "footer.php"; ?> this is line 20.. while($r=mysql_fetch_array($result1)) Quote Link to comment Share on other sites More sharing options...
shlumph Posted November 21, 2010 Share Posted November 21, 2010 In the first code snippit replace $result = mysql_query($query); with $result = mysql_query($query) or trigger_error(mysql_error()); In the second code snippit replace $result1 = mysql_query($query1); with $result1 = mysql_query($query1) or trigger_error(mysql_error()); And let us know what the error is, it might even give you big enough clue to fix it yourself. 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.