View previous topic :: View next topic |
Author |
Message |
olly86 -
Joined: 25 Apr 2003 Posts: 993 Location: Wiltshire, UK
|
Posted: Wed Sep 15, 2004 5:56 pm Post subject: mysql_fetch_array(): supplied argument is not a valid MySQL |
|
|
when I run the following code, I receive this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\Abyss Web Server\htdocs\hp\login.php on line 7
Code: | $sql = 'SELECT * FROM `author` WHERE 1 AND `author _name` = '.$_POST['username'];
// Run the query, identifying the connection
$queryResource = mysql_query($sql, $connection);
// Fetch rows from MySQL one at a time
while ($row = mysql_fetch_array($queryResource, MYSQL_ASSOC)) {
echo($row['author_id']);
} |
I've used similar code before, but cannot see why this code is bombing out on line 7 (while ($row = mysql_fetch_array($queryResource, MYSQL_ASSOC)) {). any help will be greatly appreciated, thanks.
note their is more code to the script, but i've only shown the bits that I feel are relevant _________________ Olly |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
|
Back to top |
|
 |
hernanx -
Joined: 15 Sep 2004 Posts: 1
|
Posted: Wed Sep 15, 2004 11:33 pm Post subject: |
|
|
Hi
mysql_fetch_array return FALSE if the query has problems, so I think that the problems is in the query line, the resource that make reference mysql_fetch_array come from the previous query. |
|
Back to top |
|
 |
olly86 -
Joined: 25 Apr 2003 Posts: 993 Location: Wiltshire, UK
|
Posted: Wed Sep 15, 2004 11:45 pm Post subject: Re: mysql_fetch_array(): supplied argument is not a valid My |
|
|
Code: | $sql = "SELECT * FROM `author` WHERE 1 AND `author_name`='".$_POST['username']."'"; |
I had a felling it would be something simple :( I'd missed the ' around the search criteria. Mind you when one is dyslexic these are frequent problems. :( _________________ Olly |
|
Back to top |
|
 |
|