mysql_fetch_array() expects parameter 1 to be a resource

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AdrenalineSeed
Forum Newbie
Posts: 24
Joined: Sat Oct 09, 2010 5:54 pm

mysql_fetch_array() expects parameter 1 to be a resource

Post by AdrenalineSeed »

Code: Select all

$result = mysqli_query($link, 'SELECT Count(name) FROM signup WHERE tourny = "' . $tournyinfo['name'] . '"'); 
include 'bin/verifysql.php';

$row = mysql_fetch_array($result);
I get this error when I run this code. But I have run this code many times before, its only when I do a count. But the output looks like this:

+-------------+
| count(name) |
+-------------+
| 3 |
+-------------+
1 row in set (0.00 sec)

so $result should be a valid resource.

I have a line right under it that works:

Code: Select all

$result = mysqli_query($link, 'SELECT * FROM signup where tourny = "' . $tournyinfo['name'] . '"');  
include 'bin/verifysql.php';
 
while ($row = mysqli_fetch_array($result))  
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: mysql_fetch_array() expects parameter 1 to be a resource

Post by califdon »

In your first example, you executed a mysqli_query, but you then tried to execute a mysql_fetch_array() function. Try adding i to that.
AdrenalineSeed
Forum Newbie
Posts: 24
Joined: Sat Oct 09, 2010 5:54 pm

Re: mysql_fetch_array() expects parameter 1 to be a resource

Post by AdrenalineSeed »

awsome thanks! Amazing find
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: mysql_fetch_array() expects parameter 1 to be a resource

Post by califdon »

AdrenalineSeed wrote:awsome thanks! Amazing find
If you find that amazing, you're missing a vital part of programming technique: when something isn't working, look at each and every element of the syntax to find simple typos like that. Good luck.
Post Reply