By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,928 Members | 1,810 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,928 IT Pros & Developers. It's quick & easy.

mysql_fetch_array(): supplied argument is not a valid mysql result resource

P: n/a
i recieve this error from this part of the code:

mysql_fetch_array(): supplied argument is not a valid mysql result resource
it's returning a long text from the database which is about 200 characters long.
Thanks for any help that is given.
<?php
if ($_SESSION['is_town'] = 1){
$query = "SELECT usemap FROM town WHERE town_id = " . $_SESSION['townID'][0];
$db_result = mysql_query($query);
$db_usemap = mysql_fetch_array($db_result);
echo $db_usemap;}
?>
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
In article <90**************************@posting.google.com >,
sk*******@yahoo.com (josh dismukes) wrote:
i recieve this error from this part of the code:

mysql_fetch_array(): supplied argument is not a valid mysql result resource
<?php
if ($_SESSION['is_town'] = 1){
$query = "SELECT usemap FROM town WHERE town_id = " .
$_SESSION['townID'][0];
$db_result = mysql_query($query);
$db_usemap = mysql_fetch_array($db_result);
echo $db_usemap;}
?> if ($_SESSION['is_town'] = 1)
(should be == 1 instead of = 1, I guess)
$db_result = mysql_query($query);


Try:

$db_result = mysql_query($query) or die (mysql_error() . ": $query");

and see if that helps anything.

JP

--
Sorry, <de*****@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.
Jul 17 '05 #2

P: n/a
On Tue, 06 Apr 2004 20:15:59 +0200, Jan Pieter Kunst
<de*****@cauce.org> wrote:
$db_result = mysql_query($query) or die (mysql_error() . ": $query");

when i used that i recieved "You have an error in your sql syntax. at
line 1 SELECT usemap FROM town WHERE town_id =

Jul 17 '05 #3

P: n/a
In article <lj********************************@4ax.com>,
Josh Dismukes <sk*******@yahoo.com> wrote:
On Tue, 06 Apr 2004 20:15:59 +0200, Jan Pieter Kunst
<de*****@cauce.org> wrote:
$db_result = mysql_query($query) or die (mysql_error() . ": $query");

when i used that i recieved "You have an error in your sql syntax. at
line 1 SELECT usemap FROM town WHERE town_id =


Which means that the variable that is supposed to contain the 'town_id'
is either not set or empty.

JP

--
Sorry, <de*****@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.
Jul 17 '05 #4

P: n/a
Josh Dismukes wrote:
On Tue, 06 Apr 2004 20:15:59 +0200, Jan Pieter Kunst
<de*****@cauce.org> wrote:
$db_result = mysql_query($query) or die (mysql_error() . ": $query");

when i used that i recieved "You have an error in your sql syntax. at
line 1 SELECT usemap FROM town WHERE town_id =


So, look at the query displayed by your browser and identify the syntax
error :)

If you can't identify the error just by looking at the query
copy and paste it into the MySQL client and execute it there
to get a better (more informative) error message.
--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.