|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Any Suggestions, new to php.
I have successfully tested the first example about creating a map with php and xml, calling on the markers map. I am trying to create a store locator, and when I test to see if xml is being created, I am getting this error" Invalid query: Table 'invent1bls_markers.locations' doesn't exist" Here is the php file that I am running: <?php $username="invent1bls"; $password=""; $database="invent1bls_markers"; // Get parameters from URL $center_lat = $_GET["lat"]; $center_lng = $_GET["lng"]; $radius = $_GET["radius"]; // Start XML file, create parent node $dom = new DOMDocument("1.0"); $node = $dom->createElement("markers"); $parnode = $dom->appendChild($node); // Opens a connection to a mySQL server $connection=mysql_connect (localhost, $username, $password); if (!$connection) { die("Not connected : " . mysql_error()); } // Set the active mySQL database $db_selected = mysql_select_db($database, $connection); if (!$db_selected) { die ("Can\'t use db : " . mysql_error()); } // Search the rows in the markers table $query = sprintf("SELECT address, name, lat, lng, ( 3959 * acos( cos( radians('%s') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( lat ) ) ) ) AS distance FROM locations HAVING distance < '%s' ORDER BY distance LIMIT 0 , 20", mysql_real_escape_string($center_lat), mysql_real_escape_string($center_lng), mysql_real_escape_string($center_lat), mysql_real_escape_string($radius)); $result = mysql_query($query); if (!$result) { die("Invalid query: " . mysql_error()); } // Iterate through the rows, adding XML nodes for each while ($row = @mysql_fetch_assoc($result)){ $node = $dom->createElement("marker"); $newnode = $parnode->appendChild($node); $newnode->setAttribute("name", $row['name']); $newnode->setAttribute("address", $row['address']); $newnode->setAttribute("lat", $row['lat']); $newnode->setAttribute("lng", $row['lng']); $newnode->setAttribute("distance", $row['distance']); } echo $dom->saveXML(); ?> Can someone please |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
t_kelly546@msn.com schreef:
> Any Suggestions, new to php. > > I have successfully tested the first example about creating a map with > php and xml, calling on the markers map. > > I am trying to create a store locator, and when I test to see if xml > is being created, I am getting this error" > Invalid query: Table 'invent1bls_markers.locations' doesn't exist" > > Here is the php file that I am running: > > <?php > $username="invent1bls"; > $password=""; > $database="invent1bls_markers"; > ..... > $query = sprintf("SELECT address, name, lat, lng, ( 3959 * > acos( cos( radians('%s') ) * cos( radians( lat ) ) * > cos( radians( lng ) - radians('%s') ) + sin( radians('%s') ) * > sin( radians( lat ) ) ) ) AS distance FROM locations HAVING distance < > '%s' ORDER BY distance LIMIT 0 , 20", ..... > > Can someone please Invalid query: Table 'invent1bls_markers.locations' doesn't exist" means that the table with the name 'locations' does not exist in your database with the name 'invent1bls_markers' so, you seem to be missing database contents that go with this example.... -- Luuk |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
t_kelly546@msn.com wrote:
> Any Suggestions, new to php. > > I have successfully tested the first example about creating a map with > php and xml, calling on the markers map. > > I am trying to create a store locator, and when I test to see if xml > is being created, I am getting this error" > Invalid query: Table 'invent1bls_markers.locations' doesn't exist" > > Here is the php file that I am running: > > <?php > $username="invent1bls"; > $password=""; > $database="invent1bls_markers"; > > > // Get parameters from URL > $center_lat = $_GET["lat"]; > $center_lng = $_GET["lng"]; > $radius = $_GET["radius"]; > > // Start XML file, create parent node > $dom = new DOMDocument("1.0"); > $node = $dom->createElement("markers"); > $parnode = $dom->appendChild($node); > > // Opens a connection to a mySQL server > $connection=mysql_connect (localhost, $username, $password); > if (!$connection) { > die("Not connected : " . mysql_error()); > } > > // Set the active mySQL database > $db_selected = mysql_select_db($database, $connection); > if (!$db_selected) { > die ("Can\'t use db : " . mysql_error()); > } > > // Search the rows in the markers table > $query = sprintf("SELECT address, name, lat, lng, ( 3959 * > acos( cos( radians('%s') ) * cos( radians( lat ) ) * > cos( radians( lng ) - radians('%s') ) + sin( radians('%s') ) * > sin( radians( lat ) ) ) ) AS distance FROM locations HAVING distance < > '%s' ORDER BY distance LIMIT 0 , 20", > mysql_real_escape_string($center_lat), > mysql_real_escape_string($center_lng), > mysql_real_escape_string($center_lat), > mysql_real_escape_string($radius)); > $result = mysql_query($query); > > if (!$result) { > die("Invalid query: " . mysql_error()); > } > > > > // Iterate through the rows, adding XML nodes for each > while ($row = @mysql_fetch_assoc($result)){ > $node = $dom->createElement("marker"); > $newnode = $parnode->appendChild($node); > $newnode->setAttribute("name", $row['name']); > $newnode->setAttribute("address", $row['address']); > $newnode->setAttribute("lat", $row['lat']); > $newnode->setAttribute("lng", $row['lng']); > $newnode->setAttribute("distance", $row['distance']); > } > > echo $dom->saveXML(); > ?> > > Can someone please > In addition, I suggest you follow up in comp.databases.mysql. There are probably much better ways to do what you want. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
![]() |
| Outils de la discussion | |
|
|