Jump to content

sepoto

Members
  • Content Count

    254
  • Joined

  • Last visited

Everything posted by sepoto

  1. sepoto

    Use of json_encode

    while($row = mysql_fetch_assoc($table)){ foreach($row as $key => $value) { $arr[$key] = $value; } $main_arr[] = $arr;}$json = json_encode($main_arr); I found this above which is a great example! Is there another way?
  2. sepoto

    Use of json_encode

    <?php$link = mysql_connect('localhost', 'root', '');if (!$link) { die('Connection error: ' . mysql_error());} $result = mysql_query('use `mydatabase`');if(!result) {die('Query error:' . mysql_error());} $result = mysql_query('select * from locations'); mysql_close($link); echo json_encode($result);?> I have a sample I prepared that I am working on to get it functional. I see that in the reference for json_encode that the parameter is not allowed to be of the type resource. This leads to the problem of what to do with $result. I suppose I could use a for loop and populate an array and t
  3. This is what I came up with that works: <!DOCTYPE html><html><head><title>free.wifi.locations</title><style>#wrapper { margin: 0 auto; background-color: black; }#locationselectblock { margin-left: auto; margin-right: auto; border: 1px solid black; background-color: white; width: 90%; }#addressblock { margin-left: auto; margin-right: auto; border: 1px solid black; background-color: white; width: 90%; margin-top: 10px; }#locationblock { margin-left: auto; margin-right: auto; border: 1px solid black; background-color: white; width: 90%; margin-top: 10px; }#g
  4. This is the code I refer to in the above post: // // // // // //geocoder.geocode(geocoderRequest, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { } });// // // // // // It is a callback function and results is set when it runs somehow. It must be some magic of Google.
  5. That actually is all the code. The code in the .php is a one liner. I am contemplating storing the lat and lng in a cookie although I originally wanted to use a global variable I wasn't able to make it work! The .php is just a one liner: <?phpecho $_GET['q'];?> What happens is when the geocoding function runs it sets results which I verified with alert boxes. Once the scope of the geocoding function is ended then results[0] becomes undefined. I need to keep results[0] around a little bit longer! lol...!
  6. It becomes set when the function executes. Adding alerts to that function for results[0] and running the code results in two floating point numbers for both and they are in the right range for the U.S.
  7. Alright I added that to my code but I'm not seeing how that applies to my question about results[0]. Does anyone have something relevant to how to deal with that situation?
  8. <!DOCTYPE html><html><head><title>free.wifi.locations</title><style>#wrapper { margin: 0 auto; background-color: black; }#locationselectblock { margin-left: auto; margin-right: auto; border: 1px solid black; background-color: white; width: 90%; }#addressblock { margin-left: auto; margin-right: auto; border: 1px solid black; background-color: white; width: 90%; margin-top: 10px; }#locationblock { margin-left: auto; margin-right: auto; border: 1px solid black; background-color: white; width: 90%; margin-top: 10px; }#getmapbutton { margin-left: auto; margin-rig
  9. Ohh.. There was a bug in my program that when there are no results returned there is a 404 Error.
  10. For some reason my server does not have the system variable: <?=$_SERVER['PHP_SELF']?> My O.S. is Windows 7 and I am running PHP 5.3 over IIS7. Is my system not supposed to have that variable? In other words I have sample code using PHP_SELF that does not run on my setup for some reason. P.S. My phpinfo(); says that it does exist under system variables: _SERVER["PHP_SELF"]
  11. I found this to be a very informative article on how to use the JavaScript console here: http://getfirebug.com/logging Does anyone have some commentary on if this is the right way to go about things?
  12. Thanks for setting me right. I'll try those things that you all mentioned.
  13. I am trying to figure out how to go global with these variables. This works great: <!DOCTYPE html><html><head><title>My Title</title><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script><script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script><script>$(document).ready(function(){ $('#map').hide(); $("#theyellow").click(function() { $('#map').show();sepysfunction(); }); });//end</script><script type="text/javascript"> function sepysfunction() { //sepysf
  14. sepoto

    PHP with AJAX.

    It is very simple and a very powerfully tool. I like it. Thanks again.
  15. sepoto

    PHP with AJAX.

    I have been studying the example located here: http://www.w3schools...hp_ajax_php.asp In the example the '$response' returned from the PHP script is a single string variable. What if I wanted to return an array of data? How would the array of data then be handled on the JavaScript side? I am posting code below: <?php// Fill up array with names$a[]="Anna";$a[]="Brittany";$a[]="Cinderella";$a[]="Diana";$a[]="Eva";$a[]="Fiona";$a[]="Gunda";$a[]="Hege";$a[]="Inga";$a[]="Johanna";$a[]="Kitty";$a[]="Linda";$a[]="Nina";$a[]="Ophelia";$a[]="Petunia";$a[]="Amanda";$a[]="Raquel";$a[]="Cindy";$a[]="
  16. I'm finding this to be a lot better: <?php?><!DOCTYPE html><html><head><title>My Title</title><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script><script>$(document).ready(function(){$('#enteraddress').hide();$('#entercoords').hide();$('#theyellow').hide();$("#radio01").click(function() {if ($(this).is(':checked')) { $('#enteraddress').show(); $('#theyellow').show(); $('#entercoords').hide(); }});$("#radio02").click(function() {if ($(this).is(':checked')) { $('#entercoords').show(); $('#theyellow').show()
  17. What I am doing is checking for a null. I think I have not really crafted this properly. The form elements do contain a ' value="" ' in some cases. Should I be checking instead for ""? Do I need to convert window.physichaladdress to a string? This is the target line: if(window.physichaladdress != null) Thanks! <?php?><!DOCTYPE html><html><head><title>My Title</title><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script><script>$(document).ready(function(){$('#enteraddress').hide();$('#entercoords').hide();$(
  18. Thank you for the response. That is exactly it.
  19. My program starts with some basic HTML & jQuery: <?php?><!DOCTYPE html><html><head><title>My Title</title><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script><script>$(document).ready(function(){$('#enteraddress').hide();$('#entercoords').hide();$('#theyellow').hide();$("#radio01").click(function() {if ($(this).is(':checked')) { $('#enteraddress').show(); $('#theyellow').show(); $('#entercoords').hide(); }});$("#radio02").click(function() {if ($(this).is(':checked')) { $('#entercoords').show(); $('#th
  20. In this case the $physical_address came from an html form text field initialized to value="". So the correct code turns out to be if("<?php echo $physical_address; ?>" == "") alert("Alert Sepy."); as opposed to what I have in my original posting. It works very well this way.
  21. I am trying to check for null but the code here is not achieving that result yet. I have tried a few variations of the below code but I have not really cracked it yet. Does anyone have suggestions? I just want to check for null as below: <?php header('Content-type: text/javascript'); ?>(function() {//function//window.onload//window.onloadwindow.onload = function() {// Creating a reference to the mapDivvar mapDiv = document.getElementById('map');// Creating a latLng for the center of the mapvar latlng = new google.maps.LatLng(37.09, -95.71);// Creating an object literal containing the p
  22. Yes, that is it. I thank you kindly for your wisdom. Kind Regards,Sepy
  23. I tried this: window.myvar = "<?= $physichal_address ?>"; in my next javascript alert(window.myvar); I get <?= $physichal_address ?> ??????? I tried removing the quotes but that just breaks the script. Is this to do with security?
  24. My form is processed via action.php: <?phprequire_once 'login.php';$db_server = mysql_connect($db_hostname, $db_username, $db_password);if (!$db_server) die("Unable to connect to MySQL: " . mysql_error());$physichal_address = $_GET["physichaladdress"];$thelat = $_GET["thelat"];$thelng = $_GET["thelng"];$link = mysql_connect('localhost', 'root', '************');if (!$link) {die('Could not connect: ' . mysql_error());}mysql_close($link);?><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Fre
  25. sepoto

    SOAP

    Do you know where I can find some decent tutorials on REST? I did some searching on the internet and I am finding references to a RESTfull framework. Is that the same thing as the REST that you are referring to? Also I could write all the programming to parse these url's myself however I'm looking for the easy button right now as far as getting the information into an array.
×
×
  • Create New...