Jump to content

deefer

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

deefer's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. It will be a single location. Just so I understand this right, are you saying that I should use PHP to pull the data from the database as strings, and then insert the strings into the javascript code? Thanks again.
  2. Hi, Thanks for the reply. Which way would be best? I will have my javascript.js as a seperate file, and I will need to have 3-4 variables where the info is called from a database. Can you recommend any tutorials for absolute beginners on how to do this?
  3. Hi, I am a total novice to all things here, so please bear that in mind when answering. Thanks. I am tring to include google maps on a site I have. But I want to pull the address from a MySQL database. Currently I have var gpsLatlng; var map; var directionDisplay; var directionsService;function initialize() { var myLatlng = new google.maps.LatLng(51.9605055, 1.3508106); var myOptions = { zoom: 14, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); var WPFPMarkerMessage = "3 wolsey court felixstowe suffolk"; var MarkerIconUrl = "http://chart.apis.google.com/chart?chst=d_map_pin_icon_withshadow&chld=home|FFFF00"; var initialMarkerImage = new google.maps.MarkerImage(MarkerIconUrl); var initialmarker = new google.maps.Marker( { position: myLatlng, draggable: false, icon: initialMarkerImage, title: WPFPMarkerMessage , map: map }); directionsService = new google.maps.DirectionsService(); directionsDisplay = new google.maps.DirectionsRenderer(); directionsDisplay.setMap(map); directionsDisplay.setPanel(document.getElementById("map_directions_panel"));} function getDirections() { var FromLocation = document.getElementById("EZMBFromLocation").value; var ToLocation = "ADDRESS GOES HERE"; var request = { origin:FromLocation, destination:ToLocation, travelMode: google.maps.DirectionsTravelMode.DRIVING }; directionsService.route(request, function(result, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(result); } }); return false;} function getGpsDirections() { get_geolocation();return false;} function get_geolocation(){ if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(onSuccess, onError);}} function onError(error) {alert("GPS location not available");} var onSuccess = function(position) {gpsLatlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); var ToLocation = "ADDRESS GOES HERE"; var request = { origin:gpsLatlng, destination:ToLocation, travelMode: google.maps.DirectionsTravelMode.DRIVING }; directionsService.route(request, function(result, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(result); } }); return false;}; function loadScript() { var script = document.createElement("script"); script.type = "text/javascript"; script.src = "http://maps.googleapis.com/maps/api/js?sensor=false&callback=initialize"; document.body.appendChild(script); } window.onload = loadScript; How would I go about replacing "ADDRESS GOES HERE" with an actual address stored in a MySQL dataabase? Thanks
  4. As I said numerous times, changing your function to: function check_email_address($email) { return (bool)filter_var($email, FILTER_VALIDATE_EMAIL); } would have sufficed. Hi, I tried this, but just couldn't get it to work. I am a total novice to PHP, so was probably not putting it in the right place, or not removing the old code correctly, or just something else daft.
  5. Got it fixed now, thanks for your help.
  6. OK, I have had a nights sleep I reuploaded the original file, and went back to step one again. I then changed the first instance of ereg to preg_match and added / deliminators and now the error moves on to the next case or ereg But now, if I use (!preg_match(" I get error Warning: preg_match() [function.preg-match]: Unknown modifier '_' Code starts line 123 function contact(){ $settings = $this->defaultSettings; $rows = MyActiveRecord::FindAll("settings"); foreach ($rows as $r){ $settings[$r->name] = $r->value; } $error = array(); //$error[] = "<div class='error'>Please fill the <strong>Name</strong> field</div>"; if (strlen($_POST['submit'])){ if (strlen(trim(strip_tags($_POST['name']))) < 1){ $error[] = "<div class='error'>Please fill the <strong>Name</strong> field</div>"; } if (strlen(trim(strip_tags($_POST['email']))) < 1 || !check_email_address(trim(strip_tags($_POST['email'])))){ $error[] = "<div class='error'><strong>Email</strong> field empty or not valid</div>"; } if (strlen(trim(strip_tags($_POST['msg']))) < 1 ){ $error[] = "<div class='error'>Please fill the <strong>Message</strong> field</div>"; } if (sizeof($error) < 1){ $mail = new PHPMailer(); $mail->IsHTML(true); $mail->SetLanguage("en", 'language/'); $mail->From = trim(strip_tags($_POST['email'])); $mail->FromName = 'Mobile site'; $mail->AddAddress($settings["contact_email"]); $mail->Subject = "Msg from mobile site"; $body = trim(strip_tags($_POST['msg'])); $AltBody = trim(strip_tags($_POST['msg'])); $mail->Body = $body; $mail->$AltBody = $AltBody; $mail->Send(); $error[] = "<div class='ok'>Message sent</div>"; $_POST = array(); } } include_once("pages/header.php"); include_once("pages/contact.php"); include_once("pages/footer.php"); } /////////////////////////////////////////////////////////////////////////////////// }//end class c_ajax function check_email_address($email) { // First, we check that there's one @ symbol, // and that the lengths are right. if (!preg_match("/^[^@]{1,64}@[^@]{1,255}$/", $email)) { // Email invalid because wrong number of characters // in one section or wrong number of @ symbols. return false; } // Split it into sections to make life easier $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!preg_match("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%& ↪'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } // Check if domain is IP. If not, // it should be valid domain name if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; // Not enough parts to domain } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])| ↪([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } ?>
  7. I am definately interested in learning, it's now been 5 hours and I don't seem to be getting anywhere. Serious frustration is setting in as I have to be at work in 8 hours and still need to sleep. Would really like to get this fixed first though. I really appreciate your help, and welcome more advice, I am just not understanding most of it as I am a novice
  8. ok, I must be missing something really simple here, because whatever I try just isn't working :'( My form is still retuning an invalid mail address and everything I do results in more errors, right now I think it would be better to pay someone to fix it and then I can see what is done. (it's either that or I might end up breaking my laptop )
  9. Sorry, I am just not getting this, do you mean it should be $email_array = explode("\@", $email); ? My brain is scrambled after trying to get this fixed for the past 4 hours
  10. That is way above my level of understanding at the moment Now I have if (!preg_match("/^[^@]{1,64}@[^@]{1,255}$\", $email)) { // Email invalid because wrong number of characters // in one section or wrong number of @ symbols. return false; } // Split it into sections to make life easier $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!preg_match("/^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%& ↪'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$\", $local_array[$i])) { return false; } } And I get error "Parse error: syntax error, unexpected '@'" in line 7 of the code posted above
  11. one at a time, if I change the firest ereg to (!preg_match("/^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%& ↪'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$/", $local_array[$i])) { return false; The form returns "Email field empty or not valid"
  12. Hi, I am getting 5 errors of "Deprecated: Function ereg() is deprecated" in the following code I have tried replacing with "preg_match//" but it is throwing up different errors. Please can someone have a look and point me in the right direction. if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { // Email invalid because wrong number of characters // in one section or wrong number of @ symbols. return false; } // Split it into sections to make life easier $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%& ↪'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } // Check if domain is IP. If not, // it should be valid domain name if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; // Not enough parts to domain } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])| ↪([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } Thanks
×
×
  • 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.