PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Database error
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Database error

Réponse
 
LinkBack Outils de la discussion
Vieux 24/02/2008, 16h31   #1
t_kelly546@msn.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Database error

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
  Réponse avec citation
Vieux 24/02/2008, 18h33   #2
Luuk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Database error

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
  Réponse avec citation
Vieux 24/02/2008, 19h42   #3
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Database error

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
==================

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h47.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,15450 seconds with 11 queries