Link to home
Start Free TrialLog in
Avatar of Daniish
DaniishFlag for United Kingdom of Great Britain and Northern Ireland

asked on

What's wrong with my SQL syntax?

Hello,

I have written the following SQL query to find the local region:
$lreg = mysql_query("SELECT lat,lng,maxzl,icon FROM regions WHERE locations['reg_id']");

and i'm using the following to process the results:
// this displays the local Regional marker
while ($row=mysql_fetch_object($lreg)){
      echo '<reg_local lat="'.$row['lat'].'" lng="'.$row['lng'].'" maxzl="'.$row['maxzl'].'" icon="arrow"/>';
}

Can't for the life of me see what's wrong but Firebug reports the following regarding the line beginning 'While':
:  mysql_fetch_object(): supplied argument is not a valid MySQL result resource

You can see this here (line 66):
http://www.globexposure.net/includes/read.php

Any tips appreciated
Avatar of Ali Kayahan
Ali Kayahan
Flag of Türkiye image

  Your WHERE clause is typed in a wrong way , you are not making any kind of comparisions on there it should be something like ;

   WHERE locations['reg_id'] = "Some number" ;
Avatar of hielo
your where clause is missing "fieldName=".  Do you have a field named "reg_id"? If so, try:
$lreg = mysql_query("SELECT lat,lng,maxzl,icon FROM regions WHERE reg_id = {locations['reg_id']}");
SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
use mysql_fetch_array instead and try
Avatar of Daniish

ASKER

Sorry for the delay in getting back to you...

I have changed the WHERE clause to:
$lreg = mysql_query("SELECT lat,lng,maxzl,icon FROM regions WHERE {locations['reg_id']} = id");

and i have tried using:
mysql_fetch_array
mysql_fetch_assoc
mysql_fetch_object

None of these have worked.

 What do you suppose i try next?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Daniish

ASKER

When this MySQL query is included in my read file it causes Firebug to report this problem:

handleErrors is not defined
http://www.globexposure.net/index_dubious.php
Line 291

I have created a development version of the site & read file, where you can see this:

www.globexposure.net/index_dubious.php

Obviously not sure why this is happening
I opened the page without any errors?!
Avatar of Daniish

ASKER

Not sure what occurred with regards to the error i was getting but your support was very helpful.