beating my head over a php/my_sql error

Posted by star_dancer, 01-16-2008, 06:15 PM
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)) { ?>

Posted by Xeentech, 01-16-2008, 06:40 PM
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.

Posted by foobic, 01-16-2008, 06:42 PM
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.

Posted by Harzem, 01-16-2008, 06:51 PM
Put this to line 72: echo mysql_error(); so you can find out what's wrong with the query.

Posted by star_dancer, 01-16-2008, 10:12 PM
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

Posted by star_dancer, 01-16-2008, 10:33 PM
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' ?????

Posted by foobic, 01-16-2008, 11:16 PM
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?

"> 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
Posted by star_dancer, 01-17-2008, 09:16 AM
This is the entire query:
LEVEL
0) {echo date("M j,Y h:i:s a",strtotime($row['lastlogin']));} else { echo "n/a"; }?> 0) { echo ""; } ?>

Posted by Xeentech, 01-17-2008, 09:24 AM
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.

Posted by star_dancer, 01-17-2008, 09:39 AM
would I find that? I'm not a MySql knowledgable person.

Posted by Harzem, 01-17-2008, 10:11 AM
Did "echo mysql_error();" give an error text? Can you write it here?

Posted by Xeentech, 01-17-2008, 10:13 AM
Sorrry, the "Schema" is basicly how you decribe a table. Example: 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'.

Posted by star_dancer, 01-17-2008, 11:56 AM
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');

Posted by bear, 01-17-2008, 01:12 PM
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.

Posted by star_dancer, 01-17-2008, 01:53 PM
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.

Posted by Xeentech, 01-17-2008, 02:34 PM
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.

Posted by star_dancer, 01-17-2008, 02:59 PM
Well that certainly sounds easy enough to do! Thanks, I'd never have thought of that myself! SD

Bu mövzu kifayət qədər köməkçi oldu mu?

 Çap

Digər Başlıqlar

Need Shell script to add prefix to multiple files' name.

Posted by viettechorg, 03-25-2007, 02:09 PMHello, Does anyone know any of the shell script(or...

Sanitize issues i think

Posted by rumrunner439, 09-22-2008, 12:22 AMOk Im over having to rename everything in my computer...

question about IP

Posted by wiredhosting, 07-17-2007, 11:16 AMHello everyone, i have 1 free IP in my dedicated...

SMS sending script

Posted by stjoenetworks, 01-16-2008, 11:35 PMAnyone know a decent/good script for sending SMS...

Redirecting a subdomain to a folder on the main domain?

Posted by Max Renn, 11-12-2012, 02:46 AMHi all I hope someone can help me with this. Do any...