Jump to content

php error, almost done with this fix!


verano

Recommended Posts

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)) 

 

Link to comment
Share on other sites

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.

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.