English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am trying to retrieve some data from a my host's database (using MySQL 4.0.24 and PHP 4.4.1), and so far I can already connect and insert data into it and pretty much do the basics, except i keep getting this error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/xxxxxx.com/xxx.php on line 34

I already checked for spelling errors and syntax errors, but here is the clip of code anyway:

$xxx = mysql_query("SELECT * FROM forum");
$row = mysql_fetch_array($xxx);
while ($row) {..*code*...}

The database table is named correctly, and the data is in the database and everything. But for some reason I still get that "mysql_fetch_array()" error.

The code works when I use my own sql server and localhost, but I need it to work on my host's server, and I don't have access to the host server's settings. Again, I already can connect and do most of the stuff on the database; just can't get mysql_fetch_array to work. please help?

2007-04-02 15:50:57 · 4 answers · asked by Eurypt 2 in Computers & Internet Programming & Design

4 answers

[quote]
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/xxxxxx.com/xxx.php on line 34
[/quote]

so your $xxx variable is not a proper resource. which means that there is an error in mysql_query("SQL statement")

do
$xxx = mysql_query("SELECT * FROM forum") or die(mysql_error());
in your script.

this will force the script to fail if there is an issue with the mysql statement and produce the error generated by mysql.

2007-04-02 20:59:52 · answer #1 · answered by my_screen_name 2 · 0 0

I ordinarily use the while prior to the mysql_fetch_array statement. I dont know if that is the issue but here is the mysql page on its use.

http://us2.php.net/mysql_fetch_array

2007-04-02 23:12:23 · answer #2 · answered by Tracy L 7 · 0 0

It should be

$xxx = mysql_query("SELECT * FROM forum");
while ($row = mysql_fetch_array($xxx)) {..*code*...}

I believe that will fix it.

2007-04-03 15:46:26 · answer #3 · answered by phparrow 1 · 0 0

Why don't you use this:

$row = mysql_fetch_row($xxx);

instead of:

$row = mysql_fetch_array($xxx);

Since you are fething each row until the end of rows.

2007-04-02 23:35:23 · answer #4 · answered by Anonymous · 0 0

fedest.com, questions and answers