Hello all

im new member and newbe abiut programming.
i'd like to ask about this program.

when i run the script it show like this : 
Warning:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/rekor/public_html/admin/top.php on line 6
You are not an administrator

here the script "top.php":

<?php
require '../dconn.php';
require '../require.inc.php';

$query = mysql_query("SELECT * FROM $user_table WHERE userid=$id");
$row = mysql_fetch_array($query);

if ($row["type"] != "admin") {
 die ("You are not an administrator");
}
?>

<html>
<head>
<title>SuperSurf Administration: <? echo $title; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">
<table width="95%" border="0" cellspacing="0" height="245">
  <tr> 
    <td rowspan="2" background="../images/1.jpg" width="17%" valign=top> 
      <p>&nbsp;</p>
      <table width="100%" border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
        <tr align="right" bordercolor="#666666"> 
          <td colspan="2"><img src="down.gif" width="17" height="18"></td>
        </tr>
        <tr bordercolor="#000000" valign="top"> 
          <td colspan="2" height="158" valign=top> 
            <table width="98%" border="0" cellspacing="0" cellpadding="4" align="center">
              <tr> 
                <td><font face="Ms Sans Serif" size="2">Users<br>
                  - <a href='list_users.php'>List</a><br>
                  - <a href='givegold.php'>Give Gold</a><br>
                  - <a href='emailUser.php'>Email One</a><br>
                  - <a href='sendmail.php'>Email All</a><br>
                  <a href='findcheats.php'>Find cheats</a><br>
                  <a href='list_websites.php'>Websites</a><br>
                  <a href='list_faqs.php'>FAQs</a><br>
                  <a href='list_ads.php'>Advertisements</a><br></font></td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
    <td width="83%" height="61" background="../images/1.jpg"> 
      <blockquote><br>
        <h2><? echo $title; ?> Administration Panel</h2>
      </blockquote>
    </td>
  </tr>
  <tr> 
    <td width="83%" height="124">

Thx for your help

:lol:

If you tried to debug it:

$query = mysql_query("SELECT * FROM $user_table WHERE userid=$id") or die(mysql_error());

You'd probably get the error in sql query syntax. Most likely becaues $id is not defined unless it is in one of the above includes, which I doubt.

You're probably trying to access the id in the session, in that case try:

<?php
require '../dconn.php';
require '../require.inc.php';

$id=(int)$_SESSION['id'];

$query = mysql_query("SELECT * FROM $user_table WHERE userid=$id") or die(mysql_error());

//...

I'm assuming that the $id is numeric value, otherwise:

$id=mysql_real_escape_string($_SESSION['id']);

$query = mysql_query("SELECT * FROM $user_table WHERE userid='$id'") or die(mysql_error());

hi,
for this error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/rekor/public_html/admin/top.php on line 6
You are not an administrator
in my view the variable u assinged in the query and in the database field name will be differnt i think r otherwise put an request for that varialble and echo it by that u can solve this error

This article has been dead for over six months. Start a new discussion instead.