PHP - Another Array Problem With Google Charts
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 Similar TutorialsGood morning,
I am doing a small project including google charts API but I am having trouble getting my results into the json format that is required.
Google's documentation states the json format should be:
{ "cols": [ {"id":"","label":"Topping","pattern":"","type":"string"}, {"id":"","label":"Slices","pattern":"","type":"number"} ], "rows": [ {"c":[{"v":"Mushrooms","f":null},{"v":3,"f":null}]}, {"c":[{"v":"Onions","f":null},{"v":1,"f":null}]}, {"c":[{"v":"Olives","f":null},{"v":1,"f":null}]}, {"c":[{"v":"Zucchini","f":null},{"v":1,"f":null}]}, {"c":[{"v":"Pepperoni","f":null},{"v":2,"f":null}]} ] }the query works perfectly fine thats not the problem but getting it into the above format is proving hard than I expected. The below is what I am trying to do to populate the json data in the correct format. function graphdata() { $array['cols'][] = array('type' => 'string'); $array['cols'][] = array('type' => 'string'); $array['cols'][] = array('type' => 'string'); $result = sqlsrv_query($conn, $query); while($row = sqlsrv_fetch_object($result)){ $array['rows'][] = array('c' => array( array('v'=>'$row->DateCreated->format('d-m-Y')'), array('v'=>$row->UnitPrice)) ); } return $array; } print json_encode(graphdata());I am using MSSQL and not the normal mysql hence the above code, i am a starter when it comes to php so I may be doing something basic totally wrong but I cannot seem to get it to work. Thanks 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. Hello, I am new to pHp and javascript languages and I am trying to do some math calculations in pHp, then display the results with google charts. However, I got stuck with inserting data from pHp using json_encode. It works for the most simple array, with using 2 values. When using array of arrays, it does not work. I believe it could be a syntax errors with all those brackets but I could not figure it out. Thanks for any ideas! <?php // some arrays with dim 2x2 $testarr0 = array( 0.1, 2.5); $testarr = array( 1.0, 3.5); $testarr = array( $testarr0, $testarr ) ; // this is how it looks in pHp $json = json_encode($testarr); echo($json); echo '<br/>'; echo json_encode($json); ?> <html> <head> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"> </script> <script type="text/javascript"> google.charts.load('current', {'packages':['line']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = new google.visualization.DataTable(); data.addColumn('number', 'x values'); data.addColumn('number', 'y1 '); //var dataArray = <?php echo json_encode($testarr);?>; //document.body.innerHTML = " Data Array with json: " + dataArray ; // defining array here works well /* data.addRows( [ [0.1 ,2.5], [1.0 ,3.5] ] ); */ // this here does not work: data.addRow( <?php echo json_encode($testarr);?> ); // some options for the chart var options = { chart: { title: 'Points over time', }, width: 600, height: 400, axes: { x: { 0: {side: 'top'} } } }; var chart = new google.charts.Line(document.getElementById('line_top_x')); chart.draw(data, google.charts.Line.convertOptions(options)); } </script> </head> <body> <div id="line_top_x" style="width: 900px; height: 500px"></div> </body> </html>
my value, selectname.push(element.name); selectqty.push(element.qty); How to pass Google charts function,
$.each(data, function(index, element) { selectname.push(element.name); selectqty.push(element.qty); google.charts.load('current', { 'packages': ['corechart'] }); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data1 = google.visualization.arrayToDataTable([ ['Task', 'Hours per Day'], ['Work', 11], ['Eat', 2], ['Commute', 2], ['Watch TV', 2], ['Sleep', 7] ]); // var data1 = google.visualization.arrayToDataTable([ // [element.name, element.qty], // // // ]); var options = { title: 'Top 5 Best Selling Products' }; var chart = new google.visualization.PieChart(document.getElementById('piechart')); chart.draw(data1, options); }
Hi
I am trying to create a google chart from data in query.php and using the google api to load it. Everything works until I want to change the MetalSourceID from a drop select box.
PHP CODE FOR DROP DOWN BOX:
<form> <select name="users" onchange="showUser(this.value);drawChart();"> <option value=""> Select a Metal: </option> <?php $query = "SELECT TOP(31) tblMetalPrice.MetalSourceID, tblMetalSource.MetalSourceName from tblMetalPrice INNER JOIN tblMetalSource ON tblMetalPrice.MetalSourceID=tblMetalSource.MetalSourceID ORDER BY tblMetalPrice.DateCreated DESC "; $result = sqlsrv_query( $conn, $query); while( $row = sqlsrv_fetch_object ($result)) { echo "<option value='".$row->MetalSourceID ."'>". $row->MetalSourceName ."</option>"; } sqlsrv_close( $conn); ?> </select> </form>This works fine and generates all the correct values. One part of this changes contents of a table which works fine. But I also echo the MetalSourceID into the javascript for the google api, JS script below: <script type="text/javascript"> google.load('visualization', '1', {'packages':['corechart']}); google.setOnLoadCallback(drawChart); function drawChart() { var jsonData = $.ajax({ url: "query.php", dataType:"json", async: false, data: { 'MetalSourceID' : <?php $q = intval($_GET['q']); echo $q; ?> } }).responseText; var data = new google.visualization.DataTable(jsonData); var chart = new google.visualization.LineChart(document.getElementById('chart_div')); chart.draw(data); } </script>This then runs the query.php script and returns the google line chart, a copy of the query.php script is below: i've to populate google charts with dynamic data. the data looks llike. +----+-------+---------+-------+-----------+---------+------+ | id | name | physics | maths | chemistry | biology | sst | +----+-------+---------+-------+-----------+---------+------+ | 1 | Name1 | 10 | 25 | 35 | 42 | 62 | | 2 | Name2 | 80 | 45 | 45 | 45 | 25 | | 3 | Name3 | 63 | 25 | 63 | 36 | 36 | | 4 | Name4 | 82 | 36 | 75 | 48 | 42 | | 5 | Name5 | 45 | 45 | 78 | 25 | 24 | | 6 | Name6 | 36 | 36 | 15 | 75 | 36 | | 7 | Name7 | 99 | 45 | 24 | 24 | 45 | | 8 | Name8 | 45 | 85 | 85 | 85 | 96 | +----+-------+---------+-------+-----------+---------+------+ i have to create google charts based on this such that # namewise - such that when i select a name it displays all subject marks of that particular name in a column chart #markswise - when i select a subject, it displays all the names with marks in that particular subject. conisdiering that data may be added and i've to accumulate that also, for namewise i did // chart.php <?php include("connection.php"); $query = "SELECT name FROM csv GROUP BY name DESC"; $statement = $connect->prepare($query); $statement->execute(); $result = $statement->fetchAll(); ?> <!DOCTYPE html> <html> <head> <title>Google charts</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> </head> <body> <br /><br /> <div class="container"> <div class="panel panel-default"> <div class="panel-heading"> <div class="row"> <div class="col-md-9"> <h3 class="panel-title">Student Wise Marks Data</h3> </div> <div class="col-md-3"> <select name="name" class="form-control" id="name"> <option value="">Select Student</option> <?php foreach($result as $row) { echo '<option value="'.$row["name"].'">'.$row["name"].'</option>'; } ?> </select> </div> </div> </div> <div class="panel-body"> <div id="chart_area" style="width: 1000px; height: 620px;"></div> </div> </div> </div> </body> </html> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {packages: ['corechart', 'bar']}); google.charts.setOnLoadCallback(); function load_student_data(name, title) { var temp_title = title + ' '+name+''; $.ajax({ url:"fetch.php", method:"POST", data:{name:name}, dataType:"JSON", success:function(data) { drawStudentwiseChart(data, temp_title); } }); } function drawStudentwiseChart(chart_data, chart_main_title) { var jsonData = chart_data; var data = new google.visualization.DataTable(); data.addColumn('number', 'Physics'); data.addColumn('number', 'Maths'); data.addColumn('number', 'Chemistry'); data.addColumn('number', 'Biology'); data.addColumn('number', 'SST'); $.each(jsonData, function(i, jsonData){ var Physics = jsonData.Physics; var Maths = jsonData.Maths; var Chemistry = jsonData.Chemistry; var Biology = jsonData.Biology; var SST = jsonData.SST; data.addRows([[Physics,Maths,Chemistry,Biology,SST]]); }); var options = { title:chart_main_title, hAxis: { title: "Subjects" }, vAxis: { title: 'Percentage' } }; var chart = new google.visualization.ColumnChart(document.getElementById('chart_area')); chart.draw(data, options); } </script> <script> $(document).ready(function(){ $('#name').change(function(){ var name = $(this).val(); if(name != '') { load_student_data(name, 'Student wise marks data'); } }); }); </script> and in order to fetch data // fetch.php <?php //fetch.php include('connection.php'); if(isset($_POST["name"])) { $query = " SELECT * FROM csv WHERE name = '".$_POST["name"]."' ORDER BY id ASC "; $statement = $connect->prepare($query); $statement->execute(); $result = $statement->fetchAll(); foreach($result as $row) { $output[] = array( 'Physics' => $row["Physics"], 'Maths' => $row["Maths"], 'Chemistry' => $row["Chemistry"], 'Biology' => $row["Biology"], 'SST' => $row["SST"], ); } echo json_encode($output); } ?> it diplays a blank page. however when i play with singular values i.e one subject at a time it displays fine Edited March 19, 2019 by zetastreakI am trying to add markers on my google maps which will show the location of all users with the status “active” and on click of the marker it displays the following results from the arrays i am getting over API
login This is my index.php file <!DOCTYPE html> <html> <body> <?php $api_url = 'xxxx'; // please set your x URL $admin_login = "xxxx"; // x administrator login $admin_password = "xxxx"; // administrator password $api = new SplynxAPI($api_url); $api->setVersion(SplynxApi::API_VERSION_2); $isAuthorized = $api->login([ 'auth_type' => SplynxApi::AUTH_TYPE_ADMIN, 'login' => $admin_login, 'password' => $admin_password, ]); if (!$isAuthorized) { exit("Authorization failed!\n"); } $customerApiUrl = "admin/customers/customer/"; print "<pre>"; $result_customers = $api->api_call_get($customerApiUrl); $customers_list = $api->response; if ($result_customers) { } else { print "Fail! Error code: $api->response_code\n"; print_r($api->response); } ?> <table> <thead align="left" style="display: table-header-group"> <tr> <th>CLIENT</th> <th>STATUS</th> <th>GPS</th> </tr> </thead> <tbody> <?php foreach($customers_list as $item) :?> <tr class="item_row"> <td> <?php echo $item['login']; ?></td> <td> <?php echo $item['status']; ?></td> <td> <?php echo $item['gps']; ?></td> </tr> <?php endforeach;?> </tbody> </table> </body> </html> This is the output result |CLIENT|STATUS|GPS| |---|---|---| | user1@example.com| active| -00.269704939193858,00.085300236009065| | user2@example.com| active| -00.29697452399767,00.120804981797505| But now i need this to generate the google maps markers on the map and this is my map below var handleGoogleMapSetting = function() { "use strict"; var mapDefault; var mapOptions = { zoom: 14, center: new google.maps.LatLng(-00.297106, 00.119429), mapTypeId: google.maps.MapTypeId.ROADMAP, disableDefaultUI: true, }; mapDefault = new google.maps.Map(document.getElementById('google-map-default'), mapOptions); $(window).resize(function() { google.maps.event.trigger(mapDefault, "resize"); }); var defaultMapStyles = []; var flatMapStyles = [{"stylers":[{"visibility":"off"}]},{"featureType":"road","stylers":[{"visibility":"on"},{"color":"#ffffff"}]},{"featureType":"road.arterial","stylers":[{"visibility":"on"},{"color":"#fee379"}]},{"featureType":"road.highway","stylers":[{"visibility":"on"},{"color":"#fee379"}]},{"featureType":"landscape","stylers":[{"visibility":"on"},{"color":"#f3f4f4"}]},{"featureType":"water","stylers":[{"visibility":"on"},{"color":"#7fc8ed"}]},{},{"featureType":"road","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"poi.park","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#83cead"}]},{"elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"landscape.man_made","elementType":"geometry","stylers":[{"weight":0.9},{"visibility":"off"}]}]; var turquoiseWaterStyles = [{"featureType":"landscape.natural","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#e0efef"}]},{"featureType":"poi","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"hue":"#1900ff"},{"color":"#c0e8e8"}]},{"featureType":"landscape.man_made","elementType":"geometry.fill"},{"featureType":"road","elementType":"geometry","stylers":[{"lightness":100},{"visibility":"simplified"}]},{"featureType":"road","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"water","stylers":[{"color":"#7dcdcd"}]},{"featureType":"transit.line","elementType":"geometry","stylers":[{"visibility":"on"},{"lightness":700}]}]; var icyBlueStyles = [{"stylers":[{"hue":"#2c3e50"},{"saturation":250}]},{"featureType":"road","elementType":"geometry","stylers":[{"lightness":50},{"visibility":"simplified"}]},{"featureType":"road","elementType":"labels","stylers":[{"visibility":"off"}]}]; var oldDryMudStyles = [{"featureType":"landscape","stylers":[{"hue":"#FFAD00"},{"saturation":50.2},{"lightness":-34.8},{"gamma":1}]},{"featureType":"road.highway","stylers":[{"hue":"#FFAD00"},{"saturation":-19.8},{"lightness":-1.8},{"gamma":1}]},{"featureType":"road.arterial","stylers":[{"hue":"#FFAD00"},{"saturation":72.4},{"lightness":-32.6},{"gamma":1}]},{"featureType":"road.local","stylers":[{"hue":"#FFAD00"},{"saturation":74.4},{"lightness":-18},{"gamma":1}]},{"featureType":"water","stylers":[{"hue":"#00FFA6"},{"saturation":-63.2},{"lightness":38},{"gamma":1}]},{"featureType":"poi","stylers":[{"hue":"#FFC300"},{"saturation":54.2},{"lightness":-14.4},{"gamma":1}]}]; var cobaltStyles = [{"featureType":"all","elementType":"all","stylers":[{"invert_lightness":true},{"saturation":10},{"lightness":10},{"gamma":0.8},{"hue":"#293036"}]},{"featureType":"water","stylers":[{"visibility":"on"},{"color":"#293036"}]}]; var darkRedStyles = [{"featureType":"all","elementType":"all","stylers":[{"invert_lightness":true},{"saturation":10},{"lightness":10},{"gamma":0.8},{"hue":"#000000"}]},{"featureType":"water","stylers":[{"visibility":"on"},{"color":"#293036"}]}]; $('[data-map-theme]').click(function() { var targetTheme = $(this).attr('data-map-theme'); var targetLi = $(this).closest('li'); var targetText = $(this).text(); var inverseContentMode = false; $('#map-theme-selection li').not(targetLi).removeClass('active'); $('#map-theme-text').text(targetText); $(targetLi).addClass('active'); switch(targetTheme) { case 'flat': mapDefault.setOptions({styles: flatMapStyles}); break; case 'turquoise-water': mapDefault.setOptions({styles: turquoiseWaterStyles}); break; case 'icy-COLOR_BLUE': mapDefault.setOptions({styles: icyBlueStyles}); break; case 'cobalt': mapDefault.setOptions({styles: cobaltStyles}); inverseContentMode = true; break; case 'old-dry-mud': mapDefault.setOptions({styles: oldDryMudStyles}); break; case 'dark-red': mapDefault.setOptions({styles: darkRedStyles}); inverseContentMode = true; break; default: mapDefault.setOptions({styles: defaultMapStyles}); break; } if (inverseContentMode === true) { $('#content').addClass('content-inverse-mode'); } else { $('#content').removeClass('content-inverse-mode'); } }); }; var MapGoogle = function () { "use strict"; return { //main function init: function () { handleGoogleMapSetting(); } }; }(); $(document).ready(function() { MapGoogle.init(); });
This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=352327.0 Hello, I'm working on a project that takes a CSV (poorly formated unfortunately) and turns it in charts. What should I use? Maani XML/PHP, Pcharts, ...? There are so many possibilities, I'm lost. What do you guys recommend? thanks (if maani is any good, how do I convert something like Array ( => Array ( => Array ( => FORMULE ENTREE+PLAT [1] => 24 ) [1] => Array ( => FORMULE PLAT+DESSERT [1] => 34 ) ) [1] => Array ( => Array ( => ASSIETTE DE FRITES [1] => 2 ) [1] => Array ( => ASSIETTE MIXTE [1] => 1 ) [2] => Array ( => SALADE AUVERGNATE [1] => 8 ) [3] => Array ( => SALADE CHARENTAISE [1] => 17 ) [4] => Array ( => SALADE DU BURON [1] => 10 ) [5] => Array ( => SALADE FERMIERE [1] => 3 ) ) into a XML file? I have an existing PHP array ($products) with various fields in it.... id / title / description / link / image link etc. etc. as per requirements for a Google Products feed (https://support.google.com/merchants/answer/7052112). My issue is that, for clothing, Google want a separate record for each size available. My array includes the "size" field as a comma separated list e.g. 6,8,10,12,14 or XS,S,M,L,XL etc. etc. So before creating the feed (a text file, which is currently outputting fine except for the size field issue) I need to duplicate each id where there's more than 1 size in that field, for each size, and then manipulate the fields a little so that (ignoring all the duplicated fields that would remain unchanged) instead of the single record : -
id size item group id I'd have 11 records, item group id would be what the id is, the size appended to the id, and the size field only one (in sequence of those from the original), so: - id size item group id
52-6 6 52 That's just one product....there are quite a lot, each with multiple sizes, but all in the same format within the $products array. As always, any help / pointers / solutions much appreciated! This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=322864.0 HI guys Im developing Health site using PHP and mysql. I want to create graphs from using data in the database on weekly basis. so please tell me what is the best method of creating graphs and charts in php thank in advance Hi 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); ?> Hello everybody,
I am honestly quite a newb when it comes to mod_rewrite.
We run a small social media page with different areas and I would like to change the URLs to something more clean and professional.
User profiles look like this:
http://www.sky-mp3.com/index.php?action=cm&siteid=59&wahl=artists&tat=details&keyid=477siteid 59 is the artists list and the keyid at the end is the ID of the artist but should be like: http://www.sky-mp3.com/mischuraor in worse case like: http://www.sky-mp3.com/user/mischuraCMS pages look like this: http://www.sky-mp3.com/index.php?siteid=106but should be like: http://www.sky-mp3.com/charts(page name instead of siteid) What I know so far: - I have to add something to the .htaccess file - I need to change something in the code (but I don`t know where) Im good he? What would be the first step on the path to clean URLs for me? I found alot of infos here and there but found nothing yet for this specific case. Kind regards from and thx in advance from Cologne 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 |