Warning: mysql_fetch_array(): supplied argument is not a val

Warning: mysql_fetch_array(): supplied argument is not a val

Postby dhedley » Wed Feb 11, 2009 4:26 pm


I had already posted this, but can't see it, so sorry if this is a repeat.

I am trying to connect to my database with the following code:

mysql_connect("localhost","xxxxxx_username","password") or die ("Could not connect");
print 'You are connected';

$get_strategies = "SELECT strategy_id, strategy_title FROM strategies WHERE ind_published = 1 ORDER BY display_order ";
$result = mysql_query($get_strategies);
while ($a = mysql_fetch_array($result))
echo "<a href='strategy.php?strategy_id=".$a[strategy_id]."'class='navLinkBody' > ".$a[strategy_title]."</a><br>";

I get the following error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

I am using the correct username, password and database name. I have tested my SQL statement, which is correct. I seem to be connecting to the database, as I get the message that I have connected.

I have run this code with other providers and it works.

Any ideas?
Posts: 1
Joined: Tue Feb 10, 2009 2:21 pm

Postby randy » Thu Feb 12, 2009 8:18 am


Generally, that warning is caused by one or more of these:

1. Failed to connect to the database server.
2. Failed to select the database.
3. Failed SQL statement.
4. Database user don't have privilege over the database, even though the user can connect to the server.

We could find a ticket regarding this post in our help desk and we have replied to you with the fix, the problem was No. 4. :)

Return to PHP

Who is online

Users browsing this forum: No registered users and 0 guests