Jump to content

sepoto

Members
  • Posts

    254
  • Joined

  • Last visited

Everything posted by sepoto

  1. This code is quite functional. I really like it. Thank you thescientist for pointing this out to me. <!DOCTYPE html><html><head><link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script><script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <script>$(document).ready(function() {$("input#autocomplete").autocomplete({source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]});});</script> </head><body style="font-size:62.5%;"> <input id="autocomplete" /> <script>$( "input#autocomplete" ).autocomplete({ select: function(event, ui) { alert("Alert!"); }});</script></body></html>
  2. <!doctype html><html lang="en"><head> <meta charset="utf-8" /> <title>jQuery UI Autocomplete - Default functionality</title> <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" /> <script src="http://code.jquery.com/jquery-1.8.3.js"></script> <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css" /> <script> $(function() { var availableTags = [ "ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme" ]; $( "#tags" ).autocomplete({ source: availableTags }); }); </script></head><body> <div class="ui-widget"> <label for="tags">Tags: </label> <input id="tags" /></div> <script>$("#tags").change(function() {alert('Handler for .change() called.');});</script></body></html> It isn't working yet. This is what I have. I think if I work with it some more it could potentially be the answer nut it just isn't yet...
  3. I verified this again be writing the script again and copy pasting this much easier query. I get rows out of MySQL workbench no problem however MySQLi return nothing into $result. I am really perplexed here... <?phprequire_once('include.securelogin.php');$mysqli = new mysqli($ad_host, $ad_user, $ad_password, "mysql");if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit();} $tUserName = "root";$tPassword = "**********"; $tSQL = 'select * from `mysql`.`user` where user = "' . $tUserName . '" and password = PASSWORD("' . $tPassword .'")';echo $tSQL; if ( $result = $mysqli->query($tSQL) ) {echo $result->num_rows(); $result->close();} ?>
  4. <?phprequire_once('include.securelogin.php'); $tValue = $_POST['username']; $mysqli = new mysqli($ad_host, $ad_user, $ad_password, "mysql"); if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit();} $tSQL = "select * from `mysql`.`user` where user = \"" . $tValue . "\""; if ($result = $mysqli->query($tSQL) && $result->num_rows > 0) { $result->close(); echo("username#matched");}else { } ?> If I pull $tSQL out of my Netbeans debugger, remove the opening quote and closing quote and run the query I get some results from the table `mysql`.`user`. For some reason nothing is ever returned into the variable $result though. Could this be some kind of permissions problem on the back end of MySQL somewhere? I thought I had a good idea to create some database users with some permissions and query them from `mysql`.`user` with mysqli but it has really not been working out so far. Any suggestions on how to get things working? Thanks!!!
  5. Does anyone know what event is fired when a Dropdown entry is selected for an input of type Textbox? I am using the AutoComplete Widget of the jQuery UI and I am attempting to perform some functions on the style of the Textbox when a user selects one of the entries. P.S. I'm also wondering is there a way a can track which events are being triggered as I use controls on the page perhaps maybe Google Chrome Developer Tools or FireFox Develpor Tools have this functionality?
  6. I have read the documentation on php.net about installing the module php-pdo with MySQL support and it seems that it says to use the option--with-pdo-mysql however it does not show me any context on how or where to use it. I have been installing php-pdo on my server with yum -y install php-pdo however that only installs the module with SQLite support. I need to know how to install the module on CentOS 6 with support for MySQL. It seems there are drivers for this. I found know documentation that could explain this to me. Does anyone know how to do this?
  7. implicit_flush is set to off on both systems 5.2 @ HostGator and 5.4 @ localhost.
  8. I can assure you that as I view my files in Notepad++ on Windows 8 right now that there is no line break before the opening tags in any of my files however I can tell you that the version of PHP provided by my hosting provider is quite old and if I remember correctly is some release of PHP 5.2. Also I can tell you that on my development machine running PHP 5.4 xammpp configuration with display errors on in the php.ini the warning does not appear. PHP 5.4 is winning.
  9. I've read the sticky and I've made an attempt at solving the problem using output buffering however it still is coming at me with the warning: <?phpob_start();session_start(); $productname2 = $_POST['productname2']; if (isset($_POST['countone'])){ if(empty($productname2)){echo "No product name was entered. Use the back button to go back to the form and try again.";}else if($productname2 != $_SESSION['productname']){echo "The product name does not match. The counter was not incremented. Please use the back button and try again.";}else{$sepysCounter = $_SESSION['sepysCounter'];$sepysCounter++;$_SESSION['sepysCounter'] = $sepysCounter;header("Location: http://localhost/Form2.php");}} if (isset($_POST['resetbutton'])){$_SESSION['sepysCounter'] = 0;header("Location: http://localhost/Form2.php");} ob_end_flush();?>
  10. <?phpsession_start(); $productname = trim($_GET['productname']);$productquantity = trim($_GET['productquantity']); if( (!empty($productname) && !empty($productquantity)) && (is_numeric($productquantity)) ) { $_SESSION['productname'] = $productname;$_SESSION['productquantity'] = $productquantity;$_SESSION['sepysCounter'] = 0;header("Location: http://localhost/Form2.php");}else if(empty($productname) || empty($productquantity)){ echo "A value must be entered for both the Product Name and the Quantity text boxes. Please use the back button to go back to the form"; }else if(!is_numeric($productquantity)){echo "The quantity field must be a numeric value";} ?> It's funny I have tried every way I can think of to get rid of the warning but it won't go away unless I completely turn off the display errors property in the configuration. Although the application works perfectly from what I can see. I think it may be this line causing the problem? header("Location: http://bcthub.com/Form2.php"); I see no other way though of writing the code. Could I get some commentary on this? Thank You! Form1.zip
  11. sepoto

    htmlentities

    I am currently reading the title "Essential PHP Security". I see one of the topics is concerning the use of "htmlentities()". I have looked up the functions man page on php.net and I do understand what it is doing however I don't yet fully understand how the use of "htmlentities()" is supposed to make my application more secure. Could someone explain this a bit? Thanks!
  12. sepoto

    Twitter.

    Thank you very much for the great input...
  13. sepoto

    Twitter.

    So I suppose then that just doing this is not quite enough to declare the global: <script type="text/javascript" src="jquery/jquery-1.8.0.js"></script><script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script><script type="text/javascript">var window.barLocations;</script><script type="text/javascript" src="js/jquery.tweet.js"></script><script type="text/javascript" src="js/barsmap.js"></script> I put that into my header. It is still coming up undefined when I try to access it through onclick. I had also changed this line here: window.barLocations = $.parseJSON(output); Does the variable actually have to be defined with some data first in order for it to be global? It still is not behaving globally for me... Thanks so much for taking an interest in this.
  14. sepoto

    Twitter.

    // Catching the forms submit eventbutton.onclick = function() { button.disabled = true; // Getting the address from the text inputvar address = document.getElementById('addressBox').value;var radius = document.getElementById('radialDistance').value; // Making the Geocoder callgetCoordinates(address, radius); // Preventing the form from doing a page submit//return false;$('#hdivBarLocations').show(); alert(barLocations[0].twitter); //<<<<-----------------------------} So I reproduced the code where the undefined variable was taking place. alert(barLocations[0].twitter); inside of the onclick. I am still perplexed and I tried using window.barLocations and global.barLocations but I think there is a problem with those becasue I was trying to use them inside the protected "namespace" that this code is inside of. In either case the script behaved like there was a syntax error.
  15. sepoto

    Twitter.

    I like this code but I am finding I have to modify it: http://tweet.seaofclouds.com/ So then this will be my first jQuery plug-in.
  16. sepoto

    Twitter.

    I have this code that does some AJAX to go back into my database and extract an array of bars. I have developed the code to change one of my div's to display all the data for each bar. In addition to displaying the data I also need to modify the contents of #latestFromDSGbuffer to contain a twitter feed of 5 tweets each per bar that was queried. I have tried a number of samples but for some reason I am able to get the twitter samples working in a sandbox but when I try to integrate that code things don't seem to be working out. I don't know if maybe that is because I was trying to call $.ajax(); inside of the callback function from another $.ajax(). Maybe the design needs to be modified? Maybe I should use some DOM storage to store barLocations? I'm wondering what to do with it. All of the data is located in "barLocations". Although I have attempted to make "barLocations" "global" I am not able to access it from within button.onclick where it is showing as "undefined". $.ajax({ url: 'ajax.php', data: { lat: results[0].geometry.location.lat(), lng: results[0].geometry.location.lng(), radius: radius }, type: 'post', success: function(output) { barLocations = $.parseJSON(output); //alert(obj[0].lat); /* So now that we have the JSON encoded array it has to be displayed into one of the div's probably below the map someplace */ var newInnerHTML = ""; for(var i = 0; i < barLocations.length; i++) { newInnerHTML = newInnerHTML + "<strong>" + barLocations[i].company + "</strong></br>"; newInnerHTML = newInnerHTML + barLocations[i].first_name + " " + barLocations[i].last_name + "</br>"; newInnerHTML = newInnerHTML + barLocations[i].street_address1 + "</br>" + barLocations[i].street_address2 + "</br>" + barLocations[i].city + "</br>"; newInnerHTML = newInnerHTML + "Phone: " + barLocations[i].phone_number + "</br>"; newInnerHTML = newInnerHTML + "Email: " + barLocations[i].email + "</br>"; newInnerHTML = newInnerHTML + "Website: " + barLocations[i].website + "</br>"; newInnerHTML = newInnerHTML + "<a href=\"standardprofile.php\" target=\"_blank\">Profile page >>>></a>"; newInnerHTML = newInnerHTML + "</br></br>"; } for (i = 0; i < barLocations.length; i++) { var markerImage = 'image/baricon.png'; marker = new google.maps.Marker({ position: new google.maps.LatLng(barLocations[i].lat,barLocations[i].lng), map: map, icon: markerImage, title: barLocations[i].company }); } if(barLocations.length > 0) { document.getElementById('divBarLocations').innerHTML = newInnerHTML; } } }); Thanks in advance for any help comments or commentary. Your input is most welcome... The whole code looks more like this: (function() { var map, geocoder, marker, infowindow, barLocations; window.onload = function() { $('#hdivBarLocations').hide(); // Creating a reference to the mapDiv var mapDiv = document.getElementById('map'); // Creating a latLng for the center of the map var latlng = new google.maps.LatLng(37.09, -95.71); // Creating an object literal containing the properties // we want to pass to the map var options = { center: latlng, zoom: 4, mapTypeId: google.maps.MapTypeId.ROADMAP }; // Creating the map map = new google.maps.Map(mapDiv, options); // Getting a reference to the HTML form var button = document.getElementById('addressButton'); // Catching the forms submit event button.onclick = function() { button.disabled = true; // Getting the address from the text input var address = document.getElementById('addressBox').value; var radius = document.getElementById('radialDistance').value; // Making the Geocoder call getCoordinates(address, radius); // Preventing the form from doing a page submit //return false; $('#hdivBarLocations').show(); } } // Create a function the will return the coordinates for the address function getCoordinates(address, radius) { // Check to see if we already have a geocoded object. If not we create one if(!geocoder) { geocoder = new google.maps.Geocoder(); } // Creating a GeocoderRequest object var geocoderRequest = { address: address } // Making the Geocode request geocoder.geocode(geocoderRequest, function(results, status) { // Check if status is OK before proceeding if (status == google.maps.GeocoderStatus.OK) { //Go back in for some data. document.getElementById('divBarLocations').innerHTML = "No bars found in your area..."; $.ajax({ url: 'ajax.php', data: { lat: results[0].geometry.location.lat(), lng: results[0].geometry.location.lng(), radius: radius }, type: 'post', success: function(output) { barLocations = $.parseJSON(output); //alert(obj[0].lat); /* So now that we have the JSON encoded array it has to be displayed into one of the div's probably below the map someplace */ var newInnerHTML = ""; for(var i = 0; i < barLocations.length; i++) { newInnerHTML = newInnerHTML + "<strong>" + barLocations[i].company + "</strong></br>"; newInnerHTML = newInnerHTML + barLocations[i].first_name + " " + barLocations[i].last_name + "</br>"; newInnerHTML = newInnerHTML + barLocations[i].street_address1 + "</br>" + barLocations[i].street_address2 + "</br>" + barLocations[i].city + "</br>"; newInnerHTML = newInnerHTML + "Phone: " + barLocations[i].phone_number + "</br>"; newInnerHTML = newInnerHTML + "Email: " + barLocations[i].email + "</br>"; newInnerHTML = newInnerHTML + "Website: " + barLocations[i].website + "</br>"; newInnerHTML = newInnerHTML + "<a href=\"standardprofile.php\" target=\"_blank\">Profile page >>>></a>"; newInnerHTML = newInnerHTML + "</br></br>"; } for (i = 0; i < barLocations.length; i++) { var markerImage = 'image/baricon.png'; marker = new google.maps.Marker({ position: new google.maps.LatLng(barLocations[i].lat,barLocations[i].lng), map: map, icon: markerImage, title: barLocations[i].company }); } if(barLocations.length > 0) { document.getElementById('divBarLocations').innerHTML = newInnerHTML; } } }); circ = null; var circ = new google.maps.Circle({ map: map, radius: radius * 1609.344 }); circ.setCenter(results[0].geometry.location); // Center the map on the returned location map.setCenter(results[0].geometry.location); map.fitBounds(circ.getBounds()); google.maps.event.trigger(map,'dragend'); var markerImage = 'image/home.png'; // Check to see if we've already got a Marker object if (!marker) { // Creating a new marker and adding it to the map marker = new google.maps.Marker({ map: map, icon: markerImage }); } // Setting the position of the marker to the returned location marker.setPosition(results[0].geometry.location); // Check to see if we've already got an InfoWindow object if (!infowindow) { // Creating a new InfoWindow infowindow = new google.maps.InfoWindow(); } // Creating the content of the InfoWindow to the address // and the returned position var content = '<span style="color: black;">Your location.</span>'; // Adding the content to the InfoWindow infowindow.setContent(content); // Opening the InfoWindow infowindow.open(map, marker); } }); }})();
  17. So as I change the code to this I am left with an array to string conversion? Hmmm... I'm confused here: <?php function getHours($time, $day, $close){ if(!$close){$hours = <<<htmltext <option value="1" { if(isset($time[$day]['hours1'])) echo $time[$day]['hours1'];} >1</option><option value="2" { if(isset($time[$day]['hours2'])) echo $time[$day]['hours2']; } >2</option><option value="3" { if(isset($time[$day]['hours3'])) echo $time[$day]['hours3']; }>3</option><option value="4" { if(isset($time[$day]['hours4'])) echo $time[$day]['hours4']; } >4</option><option value="5" { if(isset($time[$day]['hours5'])) echo $time[$day]['hours5']; } >5</option><option value="6" { if(isset($time[$day]['hours6'])) echo $time[$day]['hours6']; } >6</option><option value="7" { if(isset($time[$day]['hours7'])) echo $time[$day]['hours7']; } >7</option><option value="8" { if(isset($time[$day]['hours8'])) echo $time[$day]['hours8']; } >8</option><option value="9" { if(isset($time[$day]['hours9'])) echo $time[$day]['hours9']; } >9</option><option value="10" { if(isset($time[$day]['hours10'])) echo $time[$day]['hours10']; } >10</option><option value="11" { if(isset($time[$day]['hours11'])) echo $time[$day]['hours11']; } >11</option><option value="12" { if(isset($time[$day]['hours12'])) echo $time[$day]['hours12']; } >12</option> htmltext;} }?> Notice: Array to string conversion in C:\xampp\htdocs\dailysportsguide\functions\f_hours.php on line 9
  18. I have this code from another programmer: function getHours($time, $day, $close){ if(!$close){ $hours = <<<htmltext <option value="1" {$time[$day]['hours1']} >1</option> <option value="2" {$time[$day]['hours2']} >2</option> <option value="3" {$time[$day]['hours3']} >3</option> <option value="4" {$time[$day]['hours4']} >4</option> <option value="5" {$time[$day]['hours5']} >5</option> <option value="6" {$time[$day]['hours6']} >6</option> <option value="7" {$time[$day]['hours7']} >7</option> <option value="8" {$time[$day]['hours8']} >8</option> <option value="9" {$time[$day]['hours9']} >9</option> <option value="10" {$time[$day]['hours10']} >10</option> <option value="11" {$time[$day]['hours11']} ">11</option> <option value="12" {$time[$day]['hours12']} ">12</option>htmltext;} It's good code but I need there to be an isset() happening somehow. I am currently working on the problem but I am not fully sure yet on the significance of the { }'s here and if I can just add an: { if(isset($time[$day]['hours1'])) echo $time[$day]['hours1']; } I'm not sure if that direct change would work but I'm about to find out. I am trying to change the code as little as possible and I would prefer not to change my php.ini settings. I actually like being warned if my variables are not set (call me crazy!). Love this forum by the way! Thanks....
  19. I believe at this point that the answer to the [ ]'s is in the PHP json_encode doc's under JSON_FORCE_OBJECT. I'm still toying with it. I'm not sure how I came all unraveled... Darn... No.... using JSON_FORCE_OBJECT breaks the $.each.... I'm lost at this point still and I know it all hinges on the [ ]'s which need to come out on the PHP side. Alright.... This took me a while but this is how it should be.... The JSON has to be parsed and then it becomes much easier... $.ajax({ url: 'ajax.php', data: { lat: results[0].geometry.location.lat(), lng: results[0].geometry.location.lng(), radius: radius }, type: 'post', success: function(output) { var obj = $.parseJSON(output); alert(obj[0].lat); /* So now that we have the JSON encoded array it has to be displayed into one of the div's probably below the map someplace */ } });
  20. I figured it out. My first entry comes out like this: lat 34.1721 from: $.each( {"lat":"34.1721","lng":"-118.947","company":"The Bar Cave","street_address1":"315 Eagle Ridge St.","city":"Newbury Park","state":"CA","postal_code":"91320","phone_number":"8054028072","email":"eric.sepich@hotmail.com","website":"","id":"10","twitter":""}, function(k, v){ alert(k + " " + v ); }); It is a bit tricky the way the examples are but it works way well. Sorry... It must be the midnight oil I am burning... So it looks to me like the [ ]'s need to be stripped off in order for the function to work properly. If someone could enlighten me on why the [ ]'s I would really love that and this question would have been usefull to ask then. Thanks guys...
  21. [{"lat":"34.1721","lng":"-118.947","company":"The Bar Cave","street_address1":"XXX Eagle Ridge St.","city":"My City","state":"CA","postal_code":"90007","phone_number":"8055551212","email":"eric.sepich@hotmail.com","website":"","id":"10","twitter":""}] The first thing that strikes me about how this JSON was returned from PHP is the opening and closing '[' and ']'. So I am trying to figure out how to iterate through this array which actually represents one row of data from my database. I am wondering do I need to first call $.parseJson();? Do the '[' and ']' remain in there? A lot of examples I see don't have those in the JSON. My JavaScript is pretty simple when it comes back it looks like this: $.ajax({ url: 'ajax.php', data: { lat: results[0].geometry.location.lat(), lng: results[0].geometry.location.lng(), radius: radius }, type: 'post', success: function(output) { alert(output); /* So now that we have the JSON encoded array it has to be displayed into one of the div's probably below the map someplace */ } }); Essentially I am trying to determine the bounds of the JSON array and iterate through each item. So I know for this one that it is one row and I see the elements but it will of course be different each time. What is the accepted way to do this? So I am also familiar with $.each but it does not seem to be processing correctly the array which comes out broken up into bits. Thanks so much....
  22. I really like this one also. The jQuery library needs to be added: $.ajax({ url: 'ajax.php',data: { lat: results[0].geometry.location.lat(), lng: results[0].geometry.location.lng(), radius: radius },type: 'post',success: function(output) { alert(output); }});
  23. OK. I see what it is. I have to turn off the inside blue border. It appears that everything hinges upon some expert positioning. I still need to study it more. Thank you dsonesuk, you are helping me take things to the next level by showing me this. I greatly appreciate your efforts.
  24. So I have been studying this code and I have read a bit about the callback function: xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState == 4) { HandleResponse(xmlHttp.responseText); } } is asynchronous although I'm not fully sure exactly what that means to me at this point. Essentially I am starting with a page bars.php: <!DOCTYPE html><html><head><title>Daily Sports Guide Bars</title><link type="text/css" rel="stylesheet" href="style/style.css"><link type="text/css" rel="stylesheet" href="style/suckerfish.css"><style>#map { width: 80%; height: 500px; border: 1px solid #000; margin-left: 10%; }</style><script type="text/javascript" src="js/ajax.js"></script><script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script><script>(function() { window.onload = function() { var responseText = MakeRequest(); alert(responseText); // Creating a reference to the mapDiv var mapDiv = document.getElementById('map'); // Creating a latLng for the center of the map var latlng = new google.maps.LatLng(37.09, -95.71); // Creating an object literal containing the properties // we want to pass to the map var options = { center: latlng, zoom: 4, mapTypeId: google.maps.MapTypeId.ROADMAP }; // Creating the map var map = new google.maps.Map(mapDiv, options); }})();</script></head><body><div id="wrapper"><?php require('includes/i_header.php'); ?><div style='margin: 0px; padding: 0px; text-align: center;'><img height="100" width="413" src="image/underconstruction.gif"></div><div id="map"></div><?php require('includes/i_footer.php'); ?></div></body></html> So I guess the first thing would be to also list the contents of my ajax.js: function getXMLHttp(){ var xmlHttp try { //Firefox, Opera 8.0+, Safari xmlHttp = new XMLHttpRequest(); } catch(e) { //Internet Explorer try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert("Your browser does not support AJAX!") return false; } } } return xmlHttp;} function MakeRequest(){ var xmlHttp = getXMLHttp(); xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState == 4) { HandleResponse(xmlHttp.responseText); } } xmlHttp.open("GET", "ajax.php", true); xmlHttp.send(null); return xmlHttp.responseText;} function HandleResponse(response){ alert(response);} I am not sure at all of my design here but my intent would be (in bars.php that is): var responseText = MakeRequest();alert(responseText); in this case to get MakeRequest to return into 'responseText' the value in ajax.php which is: <?phpecho "This is a php response to your request!!!!!!";?> So maybe it just is not the right design or maybe I just can't make this work because I don't really understand the internals of it all yet. I do get the first alert from HandleResponse however what I can't figure out is how to get that data back into my mapping area. How should this be done? Thanks so much. As always any help from the forums is most welcome.
  25. It's going to take me a bit of time to tinker with what you have done. I see I can learn quite a bit from running your code through jsFiddle. Thanks again it looks like an awesome alternate method.
×
×
  • Create New...