Jump to content

twinytwo

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

twinytwo's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. HI guys, On my site users are enabled to see the location of other users they are trying to find, but i want to add a link to that all users profiles on the window of their marker. Below is the code for the map. The link would be coded something like <a href="userprofile.php?id=<?php echo $row['id'];?>"> im not sure if this is or the correct approach . I would thnk that it would have to be added to the create marker function... but i can get it to work Any help would be appreciated. <script type="text/javascript"> //<![CDATA[ var iconBlue = new GIcon(); iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png'; iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'; iconBlue.iconSize = new GSize(12, 20); iconBlue.shadowSize = new GSize(22, 20); iconBlue.iconAnchor = new GPoint(6, 20); iconBlue.infoWindowAnchor = new GPoint(5, 1); var iconRed = new GIcon(); iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png'; iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'; iconRed.iconSize = new GSize(12, 20); iconRed.shadowSize = new GSize(22, 20); iconRed.iconAnchor = new GPoint(6, 20); iconRed.infoWindowAnchor = new GPoint(5, 1); var customIcons = []; customIcons["restaurant"] = iconBlue; customIcons["bar"] = iconRed; function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(51.89787, -8.47109), 13); GDownloadUrl("geo.php", function(data) { var xml = GXml.parse(data); var markers = xml.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { var name = markers[i].getAttribute("name"); var address = markers[i].getAttribute("address"); var type = markers[i].getAttribute("type"); var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))); var marker = createMarker(point, name, address, type); map.addOverlay(marker); } }); } } function createMarker(point, name, address, type) { var marker = new GMarker(point, customIcons[type]); var html = "<b>" + name + "</b><br/>" + address; GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); }); return marker; } //]]>
  2. Hi guys, this is the geocoding part of the code. I ran this ion my localhost and it runs ok. Then when i uploaded it to my server i got 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. When i take out the php the html code run ok... so its not that. Can anyone help? I have taken out my key and db connection. Im hosted on black knight if thats any help <?php require("config.php"); define("MAPS_HOST", "maps.google.com"); define("KEY", "****"); // Opens a connection to a MySQL server $connection = mysql_connect("localhost", "root", "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()); } // Select all the rows in the markers table $query = "SELECT * FROM users WHERE 1"; $result = mysql_query($query); if (!$result) { die("Invalid query: " . mysql_error()); } // Initialize delay in geocode speed $delay = 0; $base_url = "http://" . MAPS_HOST . "/maps/geo?output=xml" . "&key=" . KEY; // Iterate through the rows, geocoding each address while ($row = @mysql_fetch_assoc($result)) { $geocode_pending = true; while ($geocode_pending) { $address = $row["address1"]; $id = $row["id"]; $request_url = $base_url . "&q=" . urlencode($address); $xml = simplexml_load_file($request_url) or die("url not loading"); $status = $xml->Response->Status->code; if (strcmp($status, "200") == 0) { // Successful geocode $geocode_pending = false; $coordinates = $xml->Response->Placemark->Point->coordinates; $coordinatesSplit = explode(",", $coordinates); // Format: Longitude, Latitude, Al itude $lat = $coordinatesSplit[1]; $lng = $coordinatesSplit[0]; $query = sprintf("UPDATE users " . " SET lat = '%s', lng = '%s' " . " WHERE id = '%s' LIMIT 1;", mysql_real_escape_string($lat), mysql_real_escape_string($lng), mysql_real_escape_string($id)); $update_result = mysql_query($query); if (!$update_result) { die("Invalid query: " . mysql_error()); } } else if (strcmp($status, "620") == 0) { // sent geocodes too fast $delay += 100000; } else { // failure to geocode $geocode_pending = false; echo "Address " . $address . " failed to geocoded. "; echo "Received status " . $status . " \n"; } usleep($delay); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Your Profile Page</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="css/1.css" type="text/css" media="screen,projection" /> </head> <body> <div id="wrapper" class="fixed"> <div id="header"> <h1>Find A Tag Team</strong></h1> <ul id="nav"> <li><a href="home.html">Home</a></li> <li><a href="index.html"></a>Logout</li> <li><a href="Links.php">Links</a></li> <li><a href="Videos.php">Videos</a></li> </ul> </div> <div id="sidebar_left"> <h2>Your Profile Page</h2> <p> </p> <p> From here you can ...<br /> -Edit all your information <br /> -Search for other users <br /> -View any emails you may have recieved</br /> </p> <p> </p> </div> <div id="content"> <h1>Profile</h1> <div class ="message"> The map has been succesfully updated. <br /> <a href = "map.php">View the Map</div> <div id="footer"> </div> </div> </body> </html>
  3. Hi guys Mods please move if this is the wrong place to ask. I have a google maps api added to my web site but i want to be able to position "pins" on the map to show all the the registered clubs in an area... eg the user searches dublin and all teh clubs pop up... My question is.. is there anyway to do this without needing the user to supply the long/lat.. ie can it be gotten automatically?? I really just want it to work off the addrees/area they supplied when they registered. thanks tt
  4. Hey guys... since im new enough to php, i was wondering if someone could talk me through this one. i have three radio buttons.. allowing the user to search by age, area and skill level.. age and area have a text box and skill level has a drop down box. If the user was to select one of the radio buttons and enter/select a value.. how would the if statement work to search the db? I know how to open a connection, but not exactly sure how to structure this one.
  5. Make sure your loading the HTML file through the server as well, that way when your form posts it will post to the server. Is if your form was say insert.html, you load http://localhost/insert.html and you'd set your form's action as action="insert_ac.php". When your working with PHP you have to make sure it is always run through a server. So if you have a separate html file, don't just double-click it to open it in a browser. Open your browser and then go to the URL for that file. Thanks guys.... Kicken you may have just saved my life
  6. See this may be my problem. On the html page i have the text boxes and the "submit" calling the php function that will add the data to the database. But I dont get the error when i click the button, just the display showing the actual script. I only get the error when i go to localhost/###_ac.php or whatever it is. Im thinking when the php script is called it isnt actually "running"
  7. ok.. have done that.... now i get "Notice: Undefined index: name in C:\wamp\www\insert_ac.php on line 14" screenshot below
  8. Ah, good eye. Me thinks that would be the problem. Thanks for that guys.... but where/how would i change that?
  9. im using dreamweaver... i dont think the problem is with the file though.. just getting them to execute.
  10. it displays the second block of code exactly.. ie the PHP stuff.... Could it be something with apache? SO what im getting is this....
  11. it displays the second block of code exactly.. ie the PHP stuff.... Could it be something with apache?
  12. hey guys... below is my code... when i hit the "submit" button the browser displays the php file rather than writing to the db... can anyone see what im doing wrong .. thanks <table width="300" border="0" align="center" cellpadding="0" cellspacing="1"> <tr> <td><form name="form1" method="post" action="insert_ac.php"> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td colspan="3"><strong>Insert Data Into mySQL Database </strong></td> </tr> <tr> <td width="71">Name</td> <td width="6">:</td> <td width="301"><input name="name" type="text" id="name"></td> </tr> <tr> <td>Lastname</td> <td>:</td> <td><input name="lastname" type="text" id="lastname"></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input name="email" type="text" id="email"></td> </tr> <tr> <td colspan="3" align="center"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </form> </td> </tr> </table> <?php $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name="test"; // Database name $tbl_name="test_mysql"; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Get values from form $name=$_POST['name']; $lastname=$_POST['lastname']; $email=$_POST['email']; // Insert data into mysql $sql="INSERT INTO $tbl_name(name, lastname, email)VALUES('$name', '$lastname', '$email')"; $result=mysql_query($sql); // if successfully insert data into database, displays message "Successful". if($result){ echo "Successful"; echo "<BR>"; echo "<a href='insert.php'>Back to main page</a>"; } else { echo "ERROR"; } // close connection mysql_close(); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.