471,316 Members | 1,063 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,316 software developers and data experts.

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

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
4 2724
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
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
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
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.

Similar topics

2 posts views Thread by wrw[three] | last post: by
1 post views Thread by myaashik | last post: by
3 posts views Thread by dslade | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.