PHP - Problem With Clientlogin And Google Trends
Similar TutorialsHi Hopefully someone can help me. My knowledge of PHP doesnt go any further than looking at identifying areas of code and copy and paste - as basic as you get! Basically i have a php script installed that produces an RSS feed for me to use with google base. There is a little problem were it does not pull the sale price(known as special) into googlebase and it will instead show the original price. I have identified what needs to be changed but i dont know the correct syntax. I somehow need to get something similar to the following IF ELSE into the code below (this is taken from the same php script that shows the special price on the actual rss feed) foreach ($product_data as $result) { $special = $model_catalog_product->getProductSpecial($result['product_id']); if ($special) { $price = $special; } else { $price = $result['price']; } if ($useTax) { $price = $currency->format($tax->calculate($price, $result['tax_class_id'], $config->get('config_tax')), $currency->getCode()); } else { $price = $currency->format($price, $currency->getCode()); } The code below is were i need the If Else inserted. <?php foreach ($products as $product) { ?> <item> <title><?php echo htmlspecialchars($product['name'], ENT_QUOTES, 'utf-8'); ?></title> <g:brand><?php echo htmlspecialchars($product['brand'], ENT_QUOTES, 'utf-8'); ?></g:brand> <g:condition>new</g:condition> <g:product_type><?php echo $taxonomy; ?></g:product_type> <description><?php echo htmlspecialchars($product['desc'], ENT_QUOTES, 'utf-8'); ?></description> <link><?php echo str_replace('&', '&', $product['href']); ?></link> <pubDate><?php echo $product['add_date']; ?></pubDate> <!--guid isPermaLink="true"><?php echo $product['href']; ?></guid--> <g:id><?php echo (int)$product['id']; ?></g:id> <!--g:upc><?php echo sprintf("%012s", $product['id']); ?></g:upc--> <g:image_link><?php echo $product['thumb']; ?></g:image_link> <!--g:expiration_date>2010-01-01</g:expiration_date--> <g:price><?php echo $product['price']; ?></g:price> <g:mpn><?php echo htmlspecialchars($product['model'], ENT_QUOTES, 'utf-8'); ?></g:mpn> <g:weight><?php echo $product['weight']; ?></g:weight> <g:currency><?php echo $config->get('config_currency'); ?></g:currency> </item> <?php } ?> The <g:price> is what googlebase reads to get the price of the product. The problem seems to be that there is no if else statement here to output the special price if there is one. Any help would be greatly appreciated, i tired emailing the developer but i have been ignored and as you can see i'm pretty clueless I have been running Google ReCaptcha v2 on 4 different sites for a very long time without any problem. They were all working fine. Not sure when as I was just recently made aware it, but none of them work anymore ??? Did google change something or is it because I updated php?? The problem is in the response - no matter what I try, I cannot verify that I am human. This is the response code:
[\code] For some reason I am no longer getting a successful response. Any help would be greatly appreciated Thanx
I had bought a script from he php google maps and have been using the attached php script. It was working and than apparently stopped working with this error "602: Unable to Geocode this address" Can anyone tell me if there is another solution? Or if I can use another method besides $gmap->showLocation($cross,$town,$county$state); Thanks! Code: [Select] <?php require_once('gmap.php'); $gmap = new GMap(); $cross = $result['cross_streets']; $county = $result['county']; $town = $result['town']; $state = 'New York'; $gmap->showLocation($cross,$town,$county$state); ?> Hi, Ihave the below array output from a DB query. I need to convert into the bottom array for Google CHarts. Any ideas? $myarray = array( 0 => array( 'year' => 2009, 'month' => "January", 'month_sales' => 524, 'year_totalsales' => 3610 ), 1 => array ( 'year' => 2009, 'month' => 'February', 'month_sales' => 521, 'year_totalsales' => 3610 ), 2 => array ( 'year' => 2009, 'month' => 'March', 'month_sales' => 501, 'year_totalsales' => 3610 ), 3 => array ( 'year' => 2009, 'month' => 'April', 'month_sales' => 601, 'year_totalsales' => 3610 ), 4 => array ( 'year' => 2009, 'month' => 'May', 'month_sales' => 710, 'year_totalsales' => 3610 ), 5 => array ( 'year' => 2009, 'month' => 'June', 'month_sales' => 801, 'year_totalsales' => 3610 ), 6 => array ( 'year' => 2009, 'month' => 'July', 'month_sales' => 991, 'year_totalsales' => 3610 ), 7 => array ( 'year' => 2009, 'month' => 'August', 'month_sales' => 301, 'year_totalsales' => 3610 ), 8 => array ( 'year' => 2009, 'month' => 'September', 'month_sales' => 250, 'year_totalsales' => 3610 ), 9 => array ( 'year' => 2009, 'month' => 'October', 'month_sales' => 322, 'year_totalsales' => 3610 ), 10 => array ( 'year' => 2009, 'month' => 'November', 'month_sales' => 621, 'year_totalsales' => 3610 ), 11 => array ( 'year' => 2009, 'month' => 'December', 'month_sales' => 691, 'year_totalsales' => 3610 ), 12 => array ( 'year' => 2010, 'month' => "January", 'month_sales' => 789, 'year_totalsales' => 1610 ), 13 => array ( 'year' => 2010, 'month' => "February", 'month_sales' => 1409, 'year_totalsales' => 1610 ), 14 => array ( 'year' => 2010, 'month' => "March", 'month_sales' => 550, 'year_totalsales' => 1610 ) ); raw_data=[['January',524,0],['February',521,0],['March',501,0],['April',601,0],['May',710,0],['June',801,0], ['July',991,0],['August',301,0],['September',250,0],['October',322,0],['November',621,0],['December',691,0],['January',789,0],['February',1409,0],['March',550,0],]; raw_data= [ [ month1 , year1 sales figure(zero if no figure), year2 sales figure(zero if no figure).....], [ month1 , year1 sales figure(zero if no figure), year2 sales figure(zero if no figure).....]......]; Thanks all Hey Guys.
I want to implement google cloud vision api for recognise the image. Everything installed fine, I'm getting the error Google\Cloud\Core\Exception\ServiceException { "error": { "code": 403, "message": "The request is missing a valid API key.", "status": "PERMISSION_DENIED" } } 1. in C:\xampp\htdocs\vofms\vendor\google\cloud-core\src\RequestWrapper.php at line 336 327328329330331332333334335336337338339340341342343344345 case 504: $exception = Exception\DeadlineExceededException::class; break; default: $exception = Exception\ServiceException::class; break; } return new $exception($this->getExceptionMessage($ex), $ex->getCode(), $ex); } /** * Gets the exception message. * * @param \Exception $ex * @return string */ private function getExceptionMessage(\Exception $ex) 2. in C:\xampp\htdocs\vofms\vendor\google\cloud-core\src\RequestWrapper.php at line 189 – Google\Cloud\Core\RequestWrapper::convertToGoogleException(GuzzleHttp\Exception\ClientException) 183184185186187188189190191192193194195 try { return $backoff->execute($this->httpHandler, [ $this->applyHeaders($request), $this->getRequestOptions($options) ]); } catch (\Exception $ex) { throw $this->convertToGoogleException($ex); } } /** * Deliver the request asynchronously. * 3. in C:\xampp\htdocs\vofms\vendor\google\cloud-core\src\RestTrait.php at line 96 – Google\Cloud\Core\RequestWrapper::send(GuzzleHttp\Psr7\Request, []) 90919293949596979899100101102 try { return json_decode( $this->requestWrapper->send( $this->requestBuilder->build($resource, $method, $options), $requestOptions )->getBody(), true ); } catch (NotFoundException $e) { if ($whitelisted) { throw $this->modifyWhitelistedError($e); } 4. in C:\xampp\htdocs\vofms\vendor\google\cloud-vision\src\Connection\Rest.php at line 59 – Google\Cloud\Vision\Connection\Rest::send('images', 'annotate', ['requests' => [['image' => ['content' => '/9j/4AAQSkZJRgABAQEBLAEsAAD/2wBD...'], 'features' => [['type' => 'FACE_DETECTION']]]]]) 535455565758596061 /** * @param array $args */ public function annotate(array $args) { return $this->send('images', 'annotate', $args); } } 5. in C:\xampp\htdocs\vofms\vendor\google\cloud-vision\src\VisionClient.php at line 272 – Google\Cloud\Vision\Connection\Rest::annotate(['requests' => [['image' => ['content' => '/9j/4AAQSkZJRgABAQEBLAEsAAD/2wBD...'], 'features' => [['type' => 'FACE_DETECTION']]]]]) 266267268269270271272273274275276277278 foreach ($images as $image) { $requests[] = $image->requestObject(); } $res = $this->connection->annotate([ 'requests' => $requests ] + $options); $annotations = []; if (isset($res['responses'])) { foreach ($res['responses'] as $response) { $annotations[] = new Annotation($response); } 6. in C:\xampp\htdocs\vofms\vendor\google\cloud-vision\src\VisionClient.php at line 229 – Google\Cloud\Vision\VisionClient::annotateBatch([Google\Cloud\Vision\Image], []) 223224225226227228229230231232233234235 * @param Image $image The image to annotate * @param array $options Configuration options * @return Annotation */ public function annotate(Image $image, array $options = []) { $res = $this->annotateBatch([$image], $options); return $res[0]; } /** * Annotate a set of images. * 7. in C:\xampp\htdocs\vofms\frontend\themes\admin_lte\site\index.php at line 22 – Google\Cloud\Vision\VisionClient::annotate(Google\Cloud\Vision\Image) 16171819202122232425262728 $image = $vision->image( fopen('C:\xampp\htdocs\vofms\frontend\themes\admin_lte\images\1.jpg', 'r'), ['faces'] ); $annotation = $vision->annotate($image); // Determine if the detected faces have headwear. foreach ($annotation->faces() as $key => $face) { if ($face->hasHeadwear()) { echo "Face $key has headwear.\n"; } 8. in C:\xampp\htdocs\vofms\vendor\yiisoft\yii2\base\View.php at line 348 – require('C:\xampp\htdocs\vofms\frontend\t...') 9. in C:\xampp\htdocs\vofms\vendor\yiisoft\yii2\base\View.php at line 257 – yii\base\View::renderPhpFile('C:\xampp\htdocs\vofms\frontend\t...', ['dataProvider' => yii\data\ActiveDataProvider]) 10. in C:\xampp\htdocs\vofms\vendor\yiisoft\yii2\base\View.php at line 156 – yii\base\View::renderFile('C:\xampp\htdocs\vofms\frontend\v...', ['dataProvider' => yii\data\ActiveDataProvider], frontend\controllers\SiteController) 11. in C:\xampp\htdocs\vofms\vendor\yiisoft\yii2\base\Controller.php at line 384 – yii\base\View::render('index', ['dataProvider' => yii\data\ActiveDataProvider], frontend\controllers\SiteController) 12. in C:\xampp\htdocs\vofms\frontend\controllers\SiteController.php at line 89 – yii\base\Controller::render('index', ['dataProvider' => yii\data\ActiveDataProvider]) 83848586878889909192939495 $dataProvider = new ActiveDataProvider([ 'query' => Offenses::find(), ]); return $this->render('index', [ 'dataProvider' => $dataProvider, ]); } /** * Displays a single Offenses model. * @param integer $id * @return mixed 13. frontend\controllers\SiteController::actionIndex() 14. in C:\xampp\htdocs\vofms\vendor\yiisoft\yii2\base\InlineAction.php at line 57 – call_user_func_array([frontend\controllers\SiteController, 'actionIndex'], []) 15. in C:\xampp\htdocs\vofms\vendor\yiisoft\yii2\base\Controller.php at line 157 – yii\base\InlineAction::runWithParams(['r' => 'site/index']) 16. in C:\xampp\htdocs\vofms\vendor\yiisoft\yii2\base\Module.php at line 528 – yii\base\Controller::runAction('index', ['r' => 'site/index']) 17. in C:\xampp\htdocs\vofms\vendor\yiisoft\yii2\web\Application.php at line 103 – yii\base\Module::runAction('site/index', ['r' => 'site/index']) 18. in C:\xampp\htdocs\vofms\vendor\yiisoft\yii2\base\Application.php at line 386 – yii\web\Application::handleRequest(yii\web\Request) 19. in C:\xampp\htdocs\vofms\frontend\web\index.php at line 17 – yii\base\Application::run() 11121314151617 require _DIR_ . '/../../common/config/main.php', require _DIR_ . '/../../common/config/main-local.php', require _DIR_ . '/../config/main.php', require _DIR_ . '/../config/main-local.php' ); (new yii\web\Application($config))->run()Quote
Where I can set GOOGLE_APPLICATION_CREDENTIALS environment variable in Yii2 framework.
Edited February 9, 2019 by PHPLazy Hi all!
I'm new here, apologies that my 1st post will be a cry for help. I'm tearing my hair out with this one.
I've got this page that generates PDF's via TCPDF plugin http://www.kinho.com/lightbox/ whenever I view it in chrome it zooms in at 100% to the top left corner. The problem is I need the images to be large and suitable to print (7"x5" or thereabouts) and so the PDF isn't built to be viewed at 100%, it just looks too zoomed in. Every other browser respects the fit to width setting. My images are 1600px on their long side, pages are landscape. here's the create.php:https://dl.dropboxusercontent.com/u/14123055/PHP/create.php
Can anybody advise a workaround for chrome? many thanks!
badger
I'm having trouble loading this kind of KML with PHP http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_protocol.html#RetrievingFeatures example <atom:entry xmlns='http://www.opengis.net/kml/2.2' xmlns:atom='http://www.w3.org/2005/Atom' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:gd='http://schemas.google.com/g/2005'> <atom:id> http://maps.google.com/maps/feeds/features/userID/mapID/full/featureID</atom:id> <atom:published>2008-08-14T17:46:06.462Z</atom:published> <atom:updated>2008-08-14T18:12:31.589Z</atom:updated> <atom:category scheme='http://schemas.google.com/g/2005#kind' ..... it seems like the column in atom:entry, etc is causing this. $response = simplexml_load_string($response); print_r($response); the above just gives an empty SimpleXMLElement Object() Any ideas Hey guys, I have stored a google map link into a database. When I try to display it from database using the command below <?php echo $google_map; ?> I get this output, but I can't display a map. Code: [Select] <iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&source=s_q&hl=hr&geocode=&q=smi%C4%8Diklasova+3,+karlovac,+croatia&sll=37.0625,-95.677068&sspn=50.910968,135.263672&ie=UTF8&hq=&hnear=Tadije+Smi%C4%8Diklasa,+Karlovac,+Republika+Hrvatska&t=h&ll=45.487155,15.55089&spn=0.028883,0.054932&z=14&iwloc=A&output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&source=embed&hl=hr&geocode=&q=smi%C4%8Diklasova+3,+karlovac,+croatia&sll=37.0625,-95.677068&sspn=50.910968,135.263672&ie=UTF8&hq=&hnear=Tadije+Smi%C4%8Diklasa,+Karlovac,+Republika+Hrvatska&t=h&ll=45.487155,15.55089&spn=0.028883,0.054932&z=14&iwloc=A" style="color:#0000FF;text-align:left">Prikaz veće karte</a></small> Can you tell me why?? When try to copy that directly to HTML it works perfectly!!! I'm confused! Is there a Chrome tag like this IE one <!--[if IE]> <![endif]--> <!--[if !IE]><!--> <!--<![endif]--> I have use the above tag in my wordpress site, and the only browser it doesn't work in is Google Chrome. Hi I'm using a the following google Pie Cart from here http://code.google.com/apis/ajax/playground/#pie_chart I would like to use php to COUNT printers listed in a column called machine and return result so I can echo it into google code Example of Column below would return a count of one for each except for the TurboJet which would return two. I would then like to echo the results to the google Javascript for printer 1 to 6. _______ machine ________ FB7500-1 TurboJet XL1500-1 Roland Canon TurboJet Can anyone help? Cheers Chris Code: [Select] <?php mysql_connect("localhost","chris","Cr2baxKUHWGxr6nn"); @mysql_select_db("schedule") or die( "Unable to select database"); date_default_timezone_set('Europe/London'); $query = "SELECT machine, COUNT(machine) FROM maindata GROUP BY machine"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo "There are is ". $row['COUNT(machine)'] ." ". $row['machine'] ." items."; echo "<br />"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title> Google Visualization API Sample </title> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript"> google.load('visualization', '1', {packages: ['corechart']}); </script> <script type="text/javascript"> function drawVisualization() { // Create and populate the data table. var data = new google.visualization.DataTable(); data.addColumn('string', 'Task'); data.addColumn('number', 'Hours per Day'); data.addRows(5); data.setValue(0, 0, 'Printer 1'); data.setValue(0, 1, 11); data.setValue(1, 0, 'Printer 2'); data.setValue(1, 1, 2); data.setValue(2, 0, 'Printer 4'); data.setValue(2, 1, 2); data.setValue(3, 0, 'Printer 5'); data.setValue(3, 1, 2); data.setValue(4, 0, 'Printer 6'); data.setValue(4, 1, 7); // Create and draw the visualization. new google.visualization.PieChart(document.getElementById('visualization')). draw(data, {title:"Current Work in Progress"}); } google.setOnLoadCallback(drawVisualization); </script> </head> <body style="font-family: Arial;border: 0 none;"> <div id="visualization" style="width: 600px; height: 400px;"></div> </body> </html> Hey all
I'm working on a script which needs to connect to the Google Calendar API, but when I run the code I get
Fatal error: Uncaught exception 'Google_Auth_Exception' with message 'Error refreshing the OAuth2 token, message: '{ "error" : "invalid_grant" }'' in /home/public_html/cal_test/google-api-php/src/Google/Auth/OAuth2.php:341 Stack trace: #0 /home/public_html/cal_test/google-api-php/src/Google/Auth/OAuth2.php(300): Google_Auth_OAuth2->refreshTokenRequest(Array) #1 /home/public_html/cal_test/google-api-php/src/Google/Auth/OAuth2.php(230): Google_Auth_OAuth2->refreshTokenWithAssertion() #2 /home/public_html/cal_test/google-api-php/src/Google/Service/Resource.php(171): Google_Auth_OAuth2->sign(Object(Google_Http_Request)) #3 /home/public_html/cal_test/google-api-php/src/Google/Service/Calendar.php(1133): Google_Service_Resource->call('list', Array, 'Google_Service_...') #4 /home/public_html/cal_test/index.php(34): Google_Service_Calendar_CalendarList_Resource->listCalendarList() #5 {main} thrown in /home/public_html/cal_test/google-api-php/src/Google/Auth/OAuth2.php on line 341The code i'm using is <?php error_reporting(-1); ini_set('display_errors', 'On'); require_once "google-api-php/src/Google/Client.php"; require_once "google-api-php/src/Google/Service/Calendar.php"; // Service Account info $client_id = 'CLIENT_ID'; $service_account_name = 'EMAIL'; $key_file_location = 'FILE_LOC'; // Calendar id $calName = 'CAL_ID'; $client = new Google_Client(); $client->setApplicationName("Calendar test"); $service = new Google_Service_Calendar($client); $key = file_get_contents($key_file_location); $cred = new Google_Auth_AssertionCredentials( $service_account_name, array('https://www.googleapis.com/auth/calendar.readonly'), $key ); $client->setAssertionCredentials($cred); $cals = $service->calendarList->listCalendarList(); //print_r($cals); //exit; $events = $service->events->listEvents($calName); foreach ($events->getItems() as $event) { echo $event->getSummary(); } ?>i've spent serveral hours trying to locate a fix on Google, but so far i'm stuggling Can anyone help me? Thanks Edited by dweb, 09 October 2014 - 06:58 AM. Hello to all. Please I need your help.
I have a web site (php, mysql, dreamweaver) with some seller info in a db table. They want to show a google map with their location of address, that have in the db. Let's say:
Field: Data:
tbAddress 22 Kastelliou street
tbPO 11141
tbLocal Athens
tbCountry Greece
I am try with these iframes that google has on site but this embed is ONLY for what i will find through the address bar. The dynamic web page I have, has the info of the seller (who, where, what) and I want this map dynamically change location, according to the address of the seller from the fields I provided.
Thank you
Hi all
The issue is, I want to show a map on google map site with marker on the location, when someone click on the link on my site. The problem is map is showing correctly, but no marker is there. Here is the link I am using
<a href="https://www.google.c...803171">Map</a>
Any help ?
My wife is a Type 1 diabetic and I am trying to put a site together where she can record her blood/glucose readings and analyse the readings.
I am trying to use Google Charts to create a line graph so that she can see if their is a trend during the day when her blood sugar levels peak and trough. But my coding isn't providing any results.
Can anyone see what I am doing wrong?
<?php $level=DB::getInstance()->query("SELECT * FROM tabbyhealth WHERE reading!=0"); foreach ($level->results() as $levelresults) $glucose = $levelresults->reading; $timestamp = date('d M Y h.i A',strtotime($levelresults->timestamp) +18000); ?> <head> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load('visualization', '1.0', {'packages':['corechart']}); google.setOnLoadCallback(drawChart); function drawChart() { var data = new google.visualization.DataTable(); data.addColumn('string', 'Time of Reading'); data.addColumn('number', 'Blood Glucose Reading'); data.addRows([ ['<?php echo $timestamp; ?>', '<?php echo $glucose; ?>'] ]); var options = { title:'Blood Glucose Monitoring', curveType: 'function', legend: { position: 'bottom' } width:600, height:300 hAxis: { title: 'Date/Time' }, vAxis: { title: 'Reading' } }; var chart = new google.visualization.LineChart(document.getElementById('chart_div')); chart.draw(data, options); } </script> </head> <body> <div id="chart_div"></div> </body>I have even tried replacing data.addRows([ ['<?php echo $timestamp; ?>', '<?php echo $glucose; ?>'] ]);with data.addRows([ [0, 0, 0], [1, 10, 5], [2, 23, 15], [3, 17, 9], [4, 18, 10], [5, 9, 5], [6, 11, 3], [7, 27, 19], [8, 33, 25] ]);to see if it is just a problem with reading from my database, but I am still getting nothing - by nothing I mean that no chart is appearing. Hi I have been working on this code for almost two weeks and can't get over the last hurdle. If someone can put a fresh set of eys on it I would appreciate it. I have 3 files - a geocoder php script which I can't get to work, but it is exactly like the example given on Google except that I have my addresses broken down by street, city, state and zip. - marker.php which is echoing the data correctly, and my map - location.html which pulls up a map but no markers. my geocoder script is below: Code: [Select] <?php define("MAPS_HOST", "maps.google.com"); define("KEY", "mykey"); // Opens a connection to a MySQL server $connection = mysql_connect("server", "user","pwd"); if (!$connection) { die("Not connected : " . mysql_error()); } // Set the active MySQL database $db_selected = mysql_select_db("Db", $connection); if (!$db_selected) { die("Can\'t use db : " . mysql_error()); } // Select all the rows in the markers table $query = "SELECT * FROM table 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) { $street = $row["street"]; $city = $row["city"]; $state = $row["state"]; $zip_code = $row["zip_code"]; $id = $row["id"]; $request_url = $base_url . "&q=" . urlencode($street + $city + $state + $zip_code); $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 = split(",", $coordinates); // Format: Longitude, Latitude, Altitude $lat = $coordinatesSplit[1]; $lng = $coordinatesSplit[0]; $query = sprintf("UPDATE table " . " 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 " . $street . " failed to geocoded. "; echo "Received status " . $status . " \n"; } usleep($delay); } } ?> my html file looks like the following: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>location</title> <script src="http://maps.google.com/maps?file=api&v=2&key=mykey" type="text/javascript"></script> <script type="text/javascript"> var iconFlag = new GIcon(); iconFlag.image = 'images/redflag.png'; iconFlag.iconSize = new GSize(12, 20); iconFlag.iconAnchor = new GPoint(6, 20); iconFlag.infoWindowAnchor = new GPoint(5, 1); var iconBlue = new GIcon(); iconBlue.image = 'images/glossy-ball.png'; iconBlue.iconSize = new GSize(12, 20); iconBlue.iconAnchor = new GPoint(6, 20); iconBlue.infoWindowAnchor = new GPoint(5, 1); var iconRed = new GIcon(); iconRed.image = 'images/redbutton.png'; iconRed.iconSize = new GSize(12, 20); iconRed.iconAnchor = new GPoint(6, 20); iconRed.infoWindowAnchor = new GPoint(5, 1); var customIcons = []; customIcons["Db1"] = iconFlag; customIcons["Db2"] = iconBlue; customIcons["Db3"] = iconRed; function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(39.0000, 72.0000), 11); // Change this depending on the name of your PHP file GDownloadUrl("marker.php", function(data) { var xml = GXml.parse(data); var markers = xml.documentElement.getElementsByTagName("markers"); for (var i = 0; i < markers.length; i++) { var informant = markers[i].getAttribute("id"); var firstname = markers[i].getAttribute("firstname"); var lastname = markers[i].getAttribute("lastname"); var phone = markers[i].getAttribute("phone"); var zip_code = markers[i].getAttribute("zip_code"); var type = markers[i].getAttribute("type"); var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))); var marker = createMarker(point, id, firstname, lastname, street, city, state, zip_code, type); map.addOverlay(marker); } }); } } function createMarker(point, id, firstname, lastname, street, city, state, zip_code, type) { var marker = new GMarker(point, customIcons[type]); var html = "<b>" + id + "</b> <br/>" + firstname + "<br/>" + lastname + "<br/>" + phone + "<br/>" + street + "<br/>" + city + "<br/>" + state + "<br/>" + zip_code +"<br/>" + type; GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); }); return marker; } //]]> </script> </head> <body background="images/bg2.jpg"> <body onload="load()" onunload="GUnload()"> <center><div id="map" style="width: 800px; height: 600px"></div></center> </body> </html> Thanks for any help Hi Guys!! I am in need of creating a categories' listing similar to that of Google Directory, http://www.google.com/dirhp All the categories along with their respective sub categories, subcategories of the subcategories, and the subsub categories of the subsub categories ( as deep down as the category system goes ) should be displayed which is exactly similar to that of the Google Directory. Could anyone suggest me how to do it as am pretty much new to PHP. The categories list is stored in a database and should be displayed using PHP and MySQL. This is exactly what i require. I have gone through some articles related to this, (both in this forum and elsewhere) but in all those tutorials, the depth of the categories is known (say, up to 4 or 5 levels). But, what i require is dynamic creation of these categories whose depth is unknown and also provide a way that any user can add a category from the front-end and also the admin can add a category from the back-end. Am in urgent need of this. Can anyone guide me in this regard, pls? And an example of the same would be of great help. Thanks in advance!! For every search, I get ZERO RESULTS, and I don't understand what I'm doing wrong. Code: [Select] <?php require('places_class.php'); $types = $_POST['type']; $location = $_POST['place']; $radius = $_POST['radius']; $gplaces = New GooglePlaces; $gplaces->SetLocation("$location"); $gplaces->SetRadius($radius); $gplaces->SetTypes("$types"); $results = $gplaces->Search(); print_r($results); ?> That's when the form is submitted, I checked the variables, and they are echoing out correctly. Then I thought I'd hard-code the values in, same results Code: [Select] <?php require('places_class.php'); $gplaces = New GooglePlaces; $gplaces->SetLocation("40.5267,81.4778"); $gplaces->SetRadius(50); $gplaces->SetTypes("food"); $results = $gplaces->Search(); print_r($results); ?> Here is the class Code: [Select] <?php class GooglePlaces { private $APIKey = ""; public $OutputType = "json"; //either json, xml or array public $Errors = array(); private $APIUrl = "https://maps.googleapis.com/maps/api/place"; private $APICallType = ""; private $IncludeDetails = false; //all calls private $Language = 'en'; //optional - https://spreadsheets.google.com/pub?key=p9pdwsai2hDMsLkXsoM05KQ&gid=1 //Search private $Location; //REQUIRED - This must be provided as a google.maps.LatLng object. private $Radius; //REQUIRED private $Types; //optional - separate tyep with pipe symbol http://code.google.com/apis/maps/documentation/places/supported_types.html private $Name; //optional //Search, Details, private $Sensor = 'false'; //REQUIRED - is $Location coming from a sensor? like GPS? //Details & Delete private $Reference; //Add private $Accuracy; public function Search() { $this->APICallType = "search"; return $this->APICall(); } public function Details() { $this->APICallType = "details"; return $this->APICall(); } public function Checkin() { $this->APICallType = "checkin-in"; return $this->APICall(); } public function Add() { $this->APICallType = "add"; return $this->APICall(); } public function Delete() { $this->APICallType = "delete"; return $this->APICall(); } public function SetLocation($Location) { $this->Location = $Location; } public function SetRadius($Radius) { $this->Radius = $Radius; } public function SetTypes($Types) { $this->Types = $Types; } public function SetLanguage($Language) { $this->Language = $Language; } public function SetName($Name) { $this->Name = $Name; } public function SetSensor($Sensor) { $this->Sensor = $Sensor; } public function SetReference($Reference) { $this->Reference = $Reference; } public function SetAccuracy($Accuracy) { $this->Accuracy = $Accuracy; } public function SetIncludeDetails($IncludeDetails) { $this->IncludeDetails = $IncludeDetails; } private function CheckForErrors() { if(empty($this->APICallType)) { $this->Errors[] = "API Call Type is required but is missing."; } if(empty($this->APIKey)) { $this->Errors[] = "API Key is is required but is missing."; } if(($this->OutputType!="json") && ($this->OutputType!="xml") && ($this->OutputType!="json")) { $this->Errors[] = "OutputType is required but is missing."; } } private function APICall() { $this->CheckForErrors(); if($this->APICallType=="add" || $this->APICallType=="delete") { $URLToPostTo = $this->APIUrl."/".$this->APICallType."/".$this->OutputType."?key=".$this->APIKey."&sensor=".$this->Sensor; if($this->APICallType=="add") { $LocationArray = explode(",", $this->Location); $lat = trim($LocationArray[0]); $lng = trim($LocationArray[1]); $paramstopost[location][lat] = $lat; $paramstopost[location][lng] = $lng; $paramstopost[accuracy] = $this->Accuracy; $paramstopost[name] = $this->Name; $paramstopost[types] = explode("|", $this->Types); $paramstopost[language] = $this->Language; } if($this->APICallType=="delete") { $paramstopost[reference] = $this->Reference; } $result = json_decode($this->CurlCall($URLToPostTo,json_encode($paramstopost))); $result->errors = $this->Errors; return $result; } if($this->APICallType=="search") { $URLparams = "location=".$this->Location."&radius=".$this->Radius."&types=".$this->Types."&language=".$this->Language."&name=".$this->Name."&sensor=".$this->Sensor; } if($this->APICallType=="details") { $URLparams = "reference=".$this->Reference."&language=".$this->Language."&sensor=".$this->Sensor; } if($this->APICallType=="check-in") { $URLparams = "reference=".$this->Reference."&language=".$this->Language."&sensor=".$this->Sensor; } $URLToCall = $this->APIUrl."/".$this->APICallType."/".$this->OutputType."?key=".$this->APIKey."&".$URLparams; $result = json_decode(file_get_contents($URLToCall),true); $result[errors] = $this->Errors; if($result[status]=="OK" && $this->APICallType=="details") { foreach($result[result][address_components] as $key=>$component) { if($component[types][0]=="street_number") { $address_street_number = $component[short_name]; } if($component[types][0]=="route") { $address_street_name = $component[short_name]; } if($component[types][0]=="locality") { $address_city = $component[short_name]; } if($component[types][0]=="administrative_area_level_1") { $address_state = $component[short_name]; } if($component[types][0]=="postal_code") { $address_postal_code = $component[short_name]; } } $result[result][address_fixed][street_number] = $address_street_number; $result[result][address_fixed][address_street_name] = $address_street_name; $result[result][address_fixed][address_city] = $address_city; $result[result][address_fixed][address_state] = $address_state; $result[result][address_fixed][address_postal_code] = $address_postal_code; } return $result; } private function CurlCall($url,$topost) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $topost); $body = curl_exec($ch); curl_close($ch); return $body; } } ?> And yes, I do have the correct API Key, I just took it out Can anybody see what the issue is? 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 I developed a web app using PHP, Mysql. Now I want to give login access for Gmail id's which are already existed in my database, so I used login with Google API, but want to deny login access for any other gmails which do not exist in my database.? So how can i do this?? currently iam using Google+ API For Login With Google & it is giving login access to everyone. Edited September 11, 2019 by cyberRobot Removed image |