...

View Full Version : mysql_fetch_array(): supplied argument....



bzzrd2
03-25-2007, 03:08 PM
I can't seem to rid myself of this error: mysql_fetch_array(): supplied argument is not a valid MySQL

I have the site running perfectly on a local test environment. I uploaded it to my old web space and they both work fine. I then got my new server (ISP) uploaded the files and imported the database. I get many errors that lead to the code above. Here is a sample:

All errors lead to this line in the PHP code: (different files of course)

$config=mysql_fetch_array(mysql_query("select * from XXXXX_config "));

I have run a MySql connection test and all is OK there. I'm at my wits end! Anyone? Thank You.

rafiki
03-25-2007, 03:18 PM
I can't seem to rid myself of this error: mysql_fetch_array(): supplied argument is not a valid MySQL

I have the site running perfectly on a local test environment. I uploaded it to my old web space and they both work fine. I then got my new server (ISP) uploaded the files and imported the database. I get many errors that lead to the code above. Here is a sample:

All errors lead to this line in the PHP code: (different files of course)

$config=mysql_fetch_array(mysql_query("select * from XXXXX_config "));

I have run a MySql connection test and all is OK there. I'm at my wits end! Anyone? Thank You.

try adding

$config=mysql_fetch_array(mysql_query("select * from XXXXX_config ")) or die(mysql_error());

Inigoesdr
03-25-2007, 06:11 PM
Your query is failing. Separate the lines so you can see the error:


$result = mysql_query("select * from XXXXX_config ") or die(mysql_error());
$config=mysql_fetch_array($result) or die(mysql_error());

bzzrd2
03-25-2007, 08:06 PM
Here is one of the results I got for one query:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xxxxxx/public_html/friends/myconnect.php on line 32

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xxxxxx/public_html/friends/styles.php on line 17
Table 'xxxxxx_friends.friends_config' doesn't exist

One thing I am curious about and that is why this is great on two servers and not my new one. I'm somewhat of a newb but learning!

CFMaBiSmAd
03-25-2007, 08:25 PM
Does this part of the error output say anything to you about where the problem is? -

Table 'xxxxxx_friends.friends_config' doesn't exist

iLLin
03-25-2007, 08:26 PM
apparently the table xxxxxx_friends.friends_config doesnt exist..

bzzrd2
03-25-2007, 11:58 PM
Here are the errors:

Parse error: syntax error, unexpected T_LOGICAL_OR in /home/oldatel5/public_html/friends/myconnect.php on line 32


Line 32 Code:
$online=mysql_fetch_array(mysql_query("select * from friends_online where sb_ip='$ip'"));

iLLin
03-26-2007, 12:23 AM
Doesn't mean there is a problem with that line, just means thats when the error occurred. You could have an open " or ' somewhere above that line.

I suggest splitting out your query and array as suggested by Inigoesdr.

CFMaBiSmAd
03-26-2007, 01:57 AM
The parse error is a PHP error. The code did not even get to the point of running. As iLLin suggested, you would need to post at least 5-10 lines prior to the line with the error in order to get any help with that error.

bzzrd2
03-28-2007, 03:10 AM
Your query is failing. Separate the lines so you can see the error:


$result = mysql_query("select * from XXXXX_config ") or die(mysql_error());
$config=mysql_fetch_array($result) or die(mysql_error());

Here is the response I got following Inigoesdr's direction. Is it possible it's a MySql version problem? Like I said, it works ok on my environment and another host.

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /mounted-storage/home48c/sub004/sc33782-ACCQ/www/fXXXX/myconnect.php on line 33

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /mounted-storage/home48c/sub004/sc33782-ACCQ/www/XXXX/styles.php on line 17

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /mounted-storage/home48c/sub004/sc33782-ACCQ/www/XXXX/styles.php on line 44

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

This is my table structure. The host I'm using now has MySql version 5.
CREATE TABLE `friends_admin` (
`id` bigint(20) NOT NULL auto_increment,
`admin_name` varchar(255) collate latin1_general_ci default NULL,
`pwd` varchar(255) collate latin1_general_ci default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=2 ;

Inigoesdr
03-28-2007, 03:50 AM
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
This is the relevant error, you need to figure out why your query is failing. Run it in phpMyAdmin, and/or post the actual query you're running.

bzzrd2
03-28-2007, 03:57 AM
This is the query that give me the errors. Ther are many of these as well as others producing errors:

$config=mysql_fetch_array(mysql_query("select * from friends_config "));

Inigoesdr
03-28-2007, 04:05 AM
First guess would be the table name is wrong.. since the one you posted earlier and the one in the query are different.

iLLin
03-28-2007, 04:10 AM
Hmm paste up 10lines up and your query, with error.

bzzrd2
03-28-2007, 05:23 AM
Here's the error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /mounted-storage/home48c/sub004/sc33782-ACCQ/www/friends/date_time_format.php on line 5

After I input the extra code:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /mounted-storage/home48c/sub004/sc33782-ACCQ/www/friends/myconnect.php on line 32

Parse error: syntax error, unexpected ';' in /mounted-storage/home48c/sub004/sc33782-ACCQ/www/friends/date_time_format.php on line 5

A few lines of code.
<?php
//include_once "myconnect.php";
function sb_date($unx_stamp,$cal_elapsed)
{
$config=mysql_fetch_array(mysql_query("select * from friends_config") or die(mysql_error());
$config=mysql_fetch_array($result) or die(mysql_error());

$date_str="";
$time_str="";
if($cal_elapsed==1)
{
if($config["elapsed_date"]=="no")
{$cal_elapsed=0;}
}
if($cal_elapsed==0)
{

Inigoesdr
03-28-2007, 05:37 AM
$result = mysql_query("select * from friends_config") or die(mysql_error());
$config = mysql_fetch_array($result) or die(mysql_error());

doozer
03-28-2007, 08:53 PM
$config=mysql_fetch_array(mysql_query("select * from friends_config") or die(mysql_error());
$config=mysql_fetch_array($result) or die(mysql_error());


One obvious error here is that $result has not been declared as the result of the search. You have declared $config as the result of the search which is presumably why mysql_fetch_array can do nothing meaningful with the undeclared $result.

bcarl314
03-28-2007, 09:13 PM
Error suppression can be your friend...



$config=@mysql_fetch_array(@mysql_query("select * from XXXXX_config "));

bzzrd2
03-28-2007, 10:35 PM
Error suppression can be your friend...



$config=@mysql_fetch_array(@mysql_query("select * from XXXXX_config "));



I actually did it this way, just showed the code I used as per Inigoesdr to diplay the error info.

bcarl314
03-28-2007, 11:01 PM
Hmm

Interesting. Well, usually I do something like this....



$sql = "SELECT something FROM table WHERE x=y";
$rs = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($rs)==1) {
$results = mysql_fetch_assoc($rs);
}
if(mysql_num_rows($rs)>1) {
while($r = mysql_fetch_assoc($rs)) {
$results[] = $r;
}
}

bzzrd2
03-29-2007, 02:48 PM
Well, I THINK I got to the botom of this. I think the reason the app. only runs omn my old host and my localhost is that it is somehow encrypted. That way it only works for the domian that it was licensed for. Contacted the writer and he said if it works on my original host it is fine! That Sucks. It's kind of like buying furniture but you can't take it with you when you move!

bzzrd2
03-30-2007, 03:34 PM
That was indeed the problem. I have moved my original site to my new server along with my new site. Is there a way that my visitors can navigate through the links fairly seamlesly, be able to bookmark etc. without knowing they are on my old URL? I have not heard good things about URL keepers. I only have one HTML page and a couple of PHP/Myql.

(Maybe a Mod should put me back to "New Coder")



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum