Ir para conteúdo
Fórum Script Brasil

tonzinho

Membros
  • Total de itens

    5
  • Registro em

  • Última visita

Sobre tonzinho

tonzinho's Achievements

0

Reputação

  1. Olá pessoal, esse é meu segundo tópico aqui no fórum. Bom estou estudando php agora, estou tentando pegar a localização do usuário , encontrei o seguinte código <!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>Testando</title> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> var geocoder; if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(successFunction, errorFunction); } //Get the latitude and the longitude; function successFunction(position) { var lat = position.coords.latitude; var lng = position.coords.longitude; codeLatLng(lat, lng) } function errorFunction(){ alert("Geocoder failed"); } function initialize() { geocoder = new google.maps.Geocoder(); } function codeLatLng(lat, lng) { var latlng = new google.maps.LatLng(lat, lng); geocoder.geocode({'latLng': latlng}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { console.log(results) if (results[1]) { //formatted address alert(results[0].formatted_address) //find country name for (var i=0; i<results[0].address_components.length; i++) { for (var b=0; b<results[0].address_components[i].types.length;b++) { //there are different types that might hold a city admin_area_lvl_1 usually does in come cases looking for sublocality type will be more appropriate if (results[0].address_components[i].types[b] == "administrative_area_level_1") { //this is the object you are looking for city= results[0].address_components[i]; break; } } } //city data alert(city.short_name + " " + city.long_name) } else { alert("No results found"); } } else { alert("Geocoder failed due to: " + status); } }); } </script> </head> <body onload="initialize()"> </body> </html> Ele pega as informações, e gostaria de passar elas em uma string php, para guarda no BD, se alguém puder, ajudar :)
  2. Olá pessoal, bom estou estudando php pelo manual ,como falei em um tópico anterior , estou aprendendo o básico ainda, estou passando um pequeno script para PDO e estou com o seguinte erro Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-5, 5' at line 1' in C:\xamppp\htdocs\modcp.php:296 Stack trace: #0 C:\xamppp\htdocs\modcp.php(296): PDOStatement->execute() #1 {main} thrown in C:\xamppp\htdocs\modcp.php on line 296 este é meu código $num_items = $noi[0]; //changable $items_per_page= 5; $num_pages = ceil($num_items/$items_per_page); if($page>$num_pages)$page= $num_pages; $limit_start = ($page-1)*$items_per_page; $sql = "SELECT id, name, text, authorid, crdate FROM fun_topics WHERE reported='1' ORDER BY crdate DESC LIMIT $limit_start, $items_per_page"; $items = $tonn->prepare($sql); $items->execute(); Se alguém puder me da uma dica do que pode ser, ficarei grato!
  3. tonzinho

    PHP PDO

    Agora deu certo , obrigado pela ajuda amigo !
  4. tonzinho

    PHP PDO

    Olá pessoal sou novo no forum, e começei a estudar php pelo manual,pois nao tenho condiçoes de pagar um curso. Bom estou passando um script pequeno que tenho aqui,para PDO e estou com problemas Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key Meu código (funcionava perfeitamente com mysql): $res = $tonn->prepare("INSERT INTO fun_online SET userid = :userid, actvtime = :actvtime, place = :place, placedet = :placedet"); $res->bindParam(':userid', $uid, PDO::PARAM_STR); $res->bindParam(':actvtime', $ttime, PDO::PARAM_STR); $res->bindParam(':place', $place, PDO::PARAM_STR); $res->bindParam(':placedet', $plclink, PDO::PARAM_STR); $res->execute(); if(!$res) { $res = $tonn->prepare("UPDATE fun_online SET actvtime = :actvtime, place = :place , placedet = :placedet WHERE userid = :userid"); $res->bindValue(':actvtime', $ttime, PDO::PARAM_STR); $res->bindValue(':place', $place, PDO::PARAM_STR); $res->bindValue(':placedet', $plclink, PDO::PARAM_STR); $res->bindValue(':userid', $uid, PDO::PARAM_STR); $res->execute(); }
×
×
  • Criar Novo...