Results 1 to 17 of 17
  1. #1
    Join Date
    Jan 2008
    Location
    Little Switzerland, NC
    Posts
    9

    beating my head over a php/my_sql error

    I'm getting an error and I can't figure it out. I know I have just been looking too long but I can't see the problem... Can anyone help?

    Error is:
    mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/****/public_html/admin/adminmanagement.php on line 73

    line 73 of that file reads:
    while ($row=mysql_fetch_array($getadmins)) { ?>

  2. #2
    Join Date
    Aug 2005
    Location
    UK
    Posts
    654
    Just means you're trying to pull results from an object with mysql_fetch_array() when the object is not a set of results..

    Either the query failed (you should check that before you try to iterate over the results) or you typoed the variable name.

  3. #3
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    5,842
    It means your mysql_query failed, so there was no result. Try printing out the sql you're feeding into the query and if you can't see what's wrong with it, run the same query in PhpMyAdmin.
    Chris

    "Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter

  4. #4
    Join Date
    Feb 2006
    Location
    Kusadasi, Turkey
    Posts
    3,273
    Put this to line 72:

    echo mysql_error();

    so you can find out what's wrong with the query.
    Fraud Record - Stop Fraud Clients, Report Abusive Customers.
    █ Combine your efforts to fight misbehaving clients.

    HarzemDesign - Highest quality, well designed and carefully coded hosting designs. Not cheap though.
    █ Large and awesome portfolio, just visit and see!

  5. #5
    Join Date
    Jan 2008
    Location
    Little Switzerland, NC
    Posts
    9

    Thanks guys

    I'll give that a try on line 72.

    Thing is the program has been running for over 2 years without ever getting this error now all of a sudden I start getting it. Don't know what could have changed and I'm not that good with My_sql

    but you gave me something to start with and for that I'm grateful.
    SD

  6. #6
    Join Date
    Jan 2008
    Location
    Little Switzerland, NC
    Posts
    9
    ok guys I think I'm lost now more than ever... when I did the echo this is what I got


    Unknown column 'level' in 'order clause'


    ?????

  7. #7
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    5,842
    Well, mysql error messages tend to be a bit cryptic, that's why it's usually a good idea to print out the sql for the query you're trying to run.

    What this one probably means is you're trying to sort results by the value of "level", but there's no column called level in the table you're querying. Did you recently change the database structure / upgrade the software?
    Chris

    "Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter

  8. #8
    Join Date
    Jan 2008
    Location
    Little Switzerland, NC
    Posts
    9
    Quote Originally Posted by foobic View Post
    Well, mysql error messages tend to be a bit cryptic, that's why it's usually a good idea to print out the sql for the query you're trying to run.

    What this one probably means is you're trying to sort results by the value of "level", but there's no column called level in the table you're querying. Did you recently change the database structure / upgrade the software?
    This is the entire query:
    <tr class="c4">
    <td width="100"><?=$a_lang[USERNAME];?></td>
    <td align="center"><?=$a_lang[CREATED];?></td>
    <td align="center"><?=$a_lang[LASTLOGIN];?></td>
    <td align="center">LEVEL</td>
    <td width="60" align="center"><?=$a_lang[DELETE];?></td>
    </tr><?
    $mbcnt=0;
    $getadmins=mysql_query("SELECT * FROM probid_admins ORDER BY level"); echo mysql_error();
    while ($row=mysql_fetch_array($getadmins)) { ?>
    <tr class="<? echo (($count++)%2==0)?"c1":"c2";?>">
    <td> <a href="adminedit.php?id=<?=$row['id'];?>">
    <?=$row['username'];?>
    </a> </td>
    <td align="center"><? echo date("M j,Y",strtotime($row['created']));?></td>
    <td align="center"><? if ($row['lastlogin']>0) {echo date("M j,Y h:i:s a",strtotime($row['lastlogin']));} else { echo "n/a"; }?></td>
    <td align="center"><? echo $row['level']; ?></td>
    <td align="center"> <? if ($mbcnt>0) { echo "<input type=checkbox name=delete[] value=".$row['id'].">"; } ?> </td>
    </tr>

    I haven't changed anything, been running fine for about 2 years then all of a sudden this. Now my server upgraded and moved me to a new machine, could this have caused this error? Might the DB have gotten corrupted? If so, how can I go about fixing it?
    Last edited by star_dancer; 01-17-2008 at 09:22 AM. Reason: to get rid of smiley that showed up in center

  9. #9
    Join Date
    Aug 2005
    Location
    UK
    Posts
    654
    Quote Originally Posted by star_dancer View Post
    $getadmins=mysql_query("SELECT * FROM probid_admins ORDER BY level");
    The comlum `level` doesn't exist in the table `probid_admins`, or at least, MySQLs DBMS can't find it.

    Post the table's schema, might help.

  10. #10
    Join Date
    Jan 2008
    Location
    Little Switzerland, NC
    Posts
    9

    where

    Quote Originally Posted by Xeentech View Post
    The comlum `level` doesn't exist in the table `probid_admins`, or at least, MySQLs DBMS can't find it.

    Post the table's schema, might help.
    would I find that? I'm not a MySql knowledgable person.

  11. #11
    Join Date
    Feb 2006
    Location
    Kusadasi, Turkey
    Posts
    3,273
    Did "echo mysql_error();" give an error text? Can you write it here?
    Fraud Record - Stop Fraud Clients, Report Abusive Customers.
    █ Combine your efforts to fight misbehaving clients.

    HarzemDesign - Highest quality, well designed and carefully coded hosting designs. Not cheap though.
    █ Large and awesome portfolio, just visit and see!

  12. #12
    Join Date
    Aug 2005
    Location
    UK
    Posts
    654
    Sorrry, the "Schema" is basicly how you decribe a table.

    Example:
    Code:
    CREATE TABLE auth (
      `userid` int(5) NOT NULL auto_increment,
      `state` enum('active','disabled') NOT NULL,
      `username` varchar(16) NOT NULL,
      PRIMARY KEY  (userid)
    ) ENGINE=MyISAM;
    If oyu have access to PHPMyAdmin, you can select the table then click the Export tab on the top. Pick the option to Export the 'Structure'.

  13. #13
    Join Date
    Jan 2008
    Location
    Little Switzerland, NC
    Posts
    9
    Quote Originally Posted by Xeentech View Post
    Sorrry, the "Schema" is basicly how you decribe a table.

    Example:
    Code:
    CREATE TABLE auth (
      `userid` int(5) NOT NULL auto_increment,
      `state` enum('active','disabled') NOT NULL,
      `username` varchar(16) NOT NULL,
      PRIMARY KEY  (userid)
    ) ENGINE=MyISAM;

    If oyu have access to PHPMyAdmin, you can select the table then click the Export tab on the top. Pick the option to Export the 'Structure'.

    This is what I got:

    Table structure for table `probid_admins`
    --

    CREATE TABLE `probid_admins` (
    `id` int(11) NOT NULL auto_increment,
    `username` varchar(100) NOT NULL default '',
    `password` varchar(100) NOT NULL default '',
    `created` date NOT NULL default '0000-00-00',
    `lastlogin` datetime NOT NULL default '0000-00-00 00:00:00',
    PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Table with admin info' AUTO_INCREMENT=6 ;

    --
    -- Dumping data for table `probid_admins`
    --

    INSERT INTO `probid_admins` VALUES(5, 'stardancer', 'c4af3ad59dea51fed5e36f05c196cc80', '2006-02-05', '2008-01-16 20:16:10');

  14. #14
    Join Date
    Oct 2002
    Location
    State of Disbelief
    Posts
    22,951
    Quote Originally Posted by Harzem View Post
    Did "echo mysql_error();" give an error text? Can you write it here?
    He gave it above.
    Quote Originally Posted by star_dancer View Post
    This is what I got:
    CREATE TABLE `probid_admins` (
    `id` int(11) NOT NULL auto_increment,
    `username` varchar(100) NOT NULL default '',
    `password` varchar(100) NOT NULL default '',
    `created` date NOT NULL default '0000-00-00',
    `lastlogin` datetime NOT NULL default '0000-00-00 00:00:00',
    PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Table with admin info' AUTO_INCREMENT=6 ;
    No column "level" in there. Each one with a `name` is a column, and you have none with that name. Did you recently upgrade the script and not upgrade the database to include that new column, perhaps?

    "ORDER BY level" means it's trying to use the missing column to sort the results it gets from the query.
    Having problems, or maybe questions about WHT? Head over to the help desk!

  15. #15
    Join Date
    Jan 2008
    Location
    Little Switzerland, NC
    Posts
    9
    Quote Originally Posted by bear View Post
    He gave it above.

    No column "level" in there. Each one with a `name` is a column, and you have none with that name. Did you recently upgrade the script and not upgrade the database to include that new column, perhaps?

    "ORDER BY level" means it's trying to use the missing column to sort the results it gets from the query.
    No I haven't touched the script in any manner at all. I do have an update but have been afraid to install it because that is my admin section and I don't know what problem it will cause and me being a dummie when it comes to this stuff, it scares the heck outta me.

    The only thing even remotely new was my host moving me to a better server machine.

  16. #16
    Join Date
    Aug 2005
    Location
    UK
    Posts
    654
    If you don't have a `level` column now, and don't even know what is was, I'd just delete the "ORDER BY level" from the SQL Query and be done with it.

    The results will just come out in their natural order.

  17. #17
    Join Date
    Jan 2008
    Location
    Little Switzerland, NC
    Posts
    9
    Quote Originally Posted by Xeentech View Post
    If you don't have a `level` column now, and don't even know what is was, I'd just delete the "ORDER BY level" from the SQL Query and be done with it.

    The results will just come out in their natural order.

    Well that certainly sounds easy enough to do! Thanks, I'd never have thought of that myself!

    SD

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •