I have a database of Postal Codes in Canada and the scripting to do my searches. But for some reason I am not get the nearest campground based on a Postal Code search. I am doing something wrong with my SQL Query as when I am selecting the campgrounds it displays a business within range by not the nearest.
When I run the SQL Query to get Postal Codes within range order by distance I get this PHP
Array (
[N0C 1K0] => 0
[N0C 1G0] => 9.36
[N0C 1L0] => 9.36
[N0C 1E0] => 9.97
[N0H 2S0] => 12.95
[N0C 1H0] => 13.01
[N0G 1R0] => 15.04
[N0C 1B0] => 19.03
[N0G 2A0] => 19.07
[N0H 1C0] => 19.55
[N0G 1N0] => 20.24
[N0C 1J0] => 21.67
[N0G 2L1] => 25.39
[N0G 2L3] => 25.39
[N0G 2L0] => 25.39
[N0H 1R0] => 25.8 campground found
[N0C 1C0] => 25.83
[N0H 2V0] => 27.43
[N0G 1C0] => 29.1
....
[N0G 1A0] => 41.54
[L0N 1G0] => 41.86
[N0G 2J0] => 41.94
[N0G 2V0] => 42.21
[L0M 1P0] => 43.21
[N0H 2P0] => 43.76
[N0G 1Y0] => 44.27
[L0M 1L0] => 44.27
[N0G 2P0] => 44.28 campground found
[L0M 1G0] => 44.48
[N4L 1R4] => 44.49 campground found
)
I would like to get the campground details for 25.8, except I am getting the one for 44.28, help!
SELECT camp_id FROM campgrounds WHERE postal = '".addslashes($key)."' LIMIT 1;
Should I have an ORDER BY? - I did try this. But maybe the wrong order by in my query.
You might want to have a look at the discussion on this SO topic it starts from a dataset of longitudes and lattitudes - but the objective is still all about proximity.
HTH
C.
Related
I have two arrays:
(
[lineCode] => C
[serviceRequest] => Ext, Warr auth.#19091100102 for $650.64 to be paid by c/card(fax#817-785-6700). Cust owes balance
[skillCode] => 90SB
[opCode] => 90SB
[jobType] => CUSTOMER
[techNo] =>
[lineStatus] => C
)
(
[id] => 755350
[rid] => 252178
[lineCode] => C
[serviceRequest] => Ext, Warr auth.#19091100102 for $650.64 to be paid by c/card(fax#817-785-6700). Cust owes balance
[skillCode] => 90SB
[opCode] => 90SB
[jobType] => CUSTOMER
[techNo] =>
[lineStatus] => W
[timeA] => 1575497139
[timeC] => 0
)
When i perform $diff = array_diff($arry1, $arry2);, it does not find the lineStatus to be different. Could it be because of service Request line with special characters? Although as a test, I set both lines to blanks, and it still did not see the difference.
Any help would be great. Stumped for the day.
UPDATE w/ MORE INFO
As this is part of a larger loop through mulitple arrays, the diff check before this one above is below:
$arry1= Array
(
[lineCode] => B
[serviceRequest] =>
[skillCode] => 15
[opCode] => 15
[jobType] => CUSTOMER
[techNo] => A05
[lineStatus] => C
)
$arry2= Array
(
[id] => 755362
[rid] => 252184
[lineCode] => B
[serviceRequest] =>
[skillCode] => 15
[opCode] => 15
[jobType] => CUSTOMER
[techNo] => A05
[lineStatus] => W
[timeA] => 1575504138
[timeC] => 0
)
$diff= Array
(
[lineStatus] => C
)
the code for the diff is $diff=array_diff($arry1,$arry2);
If it works correctly for this one, why would it not for the next.
Why does it not find it the way you originally did it...?
array_diff() does not care about key-value combinations, it only compares the values in the different arrays that are compared.
To better understand what's happening: if in your updated data you introduce an array element [dummy] => "C" into $arry2 you will no longer get [lineStatus] => "C" returned into $diff. As the value C is now found in both $arry1 and $arry2.
Have a look at this demo
I'm on a Drupal7 site, and I'm not used to Drupal. When I edit a node (standard page), and try to save it, the menu disappears. Not all node's are like this, only the ones that uses a field group of heatmaps, probably a custom field group (legacy).
System specs are:
CentOS 6.6
Apache 2.2
Mysql 5.5
Php 7
At first, I thought it was a bug in Drupal 7, and I tried solutions as Menu items disappearing in Drupal 7. But the suggested solutions didn't work. So I started to suspect post_max_size or memory_limit, because the form with the custom field grows very large when it uses the field or the field group. So I've maxed the memory settings and it looks good but is still not working.
The field group array tends to be very large and I tried to find some info about nestling level too big in a post but found no hints.
The post size is:
post_max_size in bytes = 536870912
post CONTENT_LENGTH = 1020347
The field group contains Heatmaps with Geolocations and endless of data:
[field_heatmap_data] => Array
(
[und] => Array
(
[0] => Array
(
[tablefield] => Array
(
[cell_0_0] => X
[cell_0_1] => Y
[cell_0_2] => Plastic
[cell_0_3] => Paper
[cell_0_4] => Glass
[cell_0_5] => Metal
[cell_0_6] => Organiskt
[cell_0_7] =>
[cell_0_8] =>
[cell_0_9] => Other
[cell_1_0] => 14.1741233638
[cell_1_1] => 57.7797089972
[cell_1_2] => 0
[cell_1_3] => 0
[cell_1_4] =>
[cell_1_5] =>
[cell_1_6] =>
[cell_1_7] => 1
[cell_1_8] =>
[cell_1_9] => 2
[cell_2_0] => 14.1784435935
[cell_2_1] => 57.7797106709
[cell_2_2] => 0
[cell_2_3] => 0
[cell_2_4] =>
[cell_2_5] =>
[cell_2_6] =>
[cell_2_7] =>
[cell_2_8] =>
[cell_2_9] =>
[cell_3_0] => 14.1656472109
[cell_3_1] => 57.7831198751
[cell_3_2] => 1
[cell_3_3] => 2
[cell_3_4] => 1
[cell_3_5] => 1
[cell_3_6] =>
[cell_3_7] =>
[cell_3_8] =>
[cell_3_9] =>
[cell_4_0] => 14.1753179083
[cell_4_1] => 57.7826699822
[cell_4_2] => 0
[cell_4_3] => 5
[cell_4_4] =>
[cell_4_5] => 3
[cell_4_6] =>
[cell_4_7] => 9
[cell_4_8] => 4
[cell_4_9] =>
[cell_5_0] => 14.1602465906
[cell_5_1] => 57.7824661754
[cell_5_2] => 2
[cell_5_3] => 0
[cell_5_4] => 1
[cell_5_5] =>
[cell_5_6] =>
[cell_5_7] => 4
[cell_5_8] =>
[cell_5_9] => 1
[cell_6_0] => 14.1552312791
[cell_6_1] => 57.7788985858
[cell_6_2] => 0
[cell_6_3] => 1
[cell_6_4] =>
[cell_6_5] => 1
[cell_6_6] =>
[cell_6_7] => 4
[cell_6_8] =>
[cell_6_9] =>
[cell_7_0] => 14.1631063952
[cell_7_1] => 57.7813178687
[cell_7_2] => 1
[cell_7_3] => 0
[cell_7_4] =>
[cell_7_5] =>
[cell_7_6] =>
[cell_7_7] => 2
[cell_7_8] => 3
[cell_7_9] =>
[cell_8_0] => 14.1742044644
[cell_8_1] => 57.7827544419
[cell_8_2] => 0
[cell_8_3] => 0
[cell_8_4] =>
[cell_8_5] =>
[cell_8_6] =>
[cell_8_7] => 4
[cell_8_8] => 1
[cell_8_9] =>
[cell_9_0] => 14.157952438
[cell_9_1] => 57.7818974962
[cell_9_2] => 2
[cell_9_3] => 4
[cell_9_4] => 5
[cell_9_5] => 1
[cell_9_6] =>
[cell_9_7] => 8
[cell_9_8] => 2
[cell_9_9] =>
[cell_10_0] => 14.1706946744
[cell_10_1] => 57.7815507326
[cell_10_2] => 0
[cell_10_3] => 0
[cell_10_4] =>
And so on....
So I've figured out that there is a flaw in the architecture of the node because it cant clearly not handle that much data in a field group and should been handled as an separate node, but since this is a legacy project I don't want to mess things up.
If I var_dump the $_POST variable on different pages when editing, I can clearly see that the $_POST variable stops after the $_POST['field_heatmap'] element where there is data, while the pages that doesn't contain data in that field group the $_POST array continues after the $_POST['field_heatmap'] element.
So my question is, should I continue to try to find a bug in Drupal or should I investigate further some php settings (Or maybe apache). I've tried debugging with cachegrind but can't find any unusual. Or any hints are greatly appreciated!
Finally! The max_input_vars was set to 1000
Changed it to max_input_vars = 10000 and it worked!
I'm in a bind with a deadline and I cannot seem to figure this out.
I am trying to query the table to get the values for the corresponding max shipdate. My query is below. This is for Fox Pro using an ODBC driver.
SELECT
so1.sono,
so1.custno,
so1.item,
so1.shipdate as last_shipdate,
so1.price as last_price
FROM sotran01 so1
INNER JOIN (
SELECT
custno,
item,
MAX(shipdate) as last_shipdate
FROM sotran01
WHERE shipdate >= {d'2013-05-23'}
AND shipdate <= {d'2014-05-23'}
GROUP BY custno, item
) so2 ON (so1.custno = so2.custno AND so1.item = so2.item AND so1.shipdate = so2.last_shipdate)
WHERE so1.item IN (
SELECT item
FROM arpric01
)
ORDER BY so1.custno, so1.item, so1.shipdate
This is what I get (using ADOdb):
ADODB_vfp Object
(
[databaseType] => vfp
[fmtDate] => {^Y-m-d}
[fmtTimeStamp] => {^Y-m-d, h:i:sA}
[replaceQuote] => '+chr(39)+'
[true] => .T.
[false] => .F.
[hasTop] => top
[_bindInputArray] =>
[sysTimeStamp] => datetime()
[sysDate] => date()
[ansiOuter] => 1
[hasTransactions] =>
[curmode] =>
[dataProvider] => odbc
[hasAffectedRows] => 1
[binmode] => 1
[useFetchArray] =>
[_genSeqSQL] => create table %s (id integer)
[_autocommit] => 1
[_haserrorfunctions] => 1
[_has_stupid_odbc_fetch_api_change] => 1
[_lastAffectedRows] => 0
[uCaseTables] => 1
[_dropSeqSQL] => drop table %s
[database] =>
[host] => DRIVER={Microsoft Visual FoxPro Driver};SOURCETYPE=dbf;SOURCEDB=C:\Sites\hub.fieldfresh.dev\_cache\VP10\PRAXIS\;EXCLUSIVE=NO;
[user] =>
[password] =>
[debug] =>
[maxblobsize] => 262144
[concat_operator] => +
[substr] => substr
[length] => length
[random] => rand()
[upperCase] => upper
[nameQuote] => "
[charSet] =>
[metaDatabasesSQL] =>
[metaTablesSQL] =>
[uniqueOrderBy] =>
[emptyDate] =>
[emptyTimeStamp] =>
[lastInsID] =>
[hasInsertID] =>
[hasLimit] =>
[readOnly] =>
[hasMoveFirst] =>
[hasGenID] =>
[genID] => 0
[raiseErrorFn] =>
[isoDates] =>
[cacheSecs] => 3600
[memCache] =>
[memCacheHost] =>
[memCachePort] => 11211
[memCacheCompress] =>
[sysUTimeStamp] =>
[arrayClass] => ADORecordSet_array
[noNullStrings] =>
[numCacheHits] => 0
[numCacheMisses] => 0
[pageExecuteCountRows] => 1
[uniqueSort] =>
[leftOuter] =>
[rightOuter] =>
[autoRollback] =>
[poorAffectedRows] =>
[fnExecute] =>
[fnCacheExecute] =>
[blobEncodeType] =>
[rsPrefix] => ADORecordSet_
[autoCommit] => 1
[transOff] => 0
[transCnt] => 0
[fetchMode] => 2
[null2null] => null
[bulkBind] =>
[_oldRaiseFn] =>
[_transOK] =>
[_connectionID] => Resource id #8
[_errorMsg] => [Microsoft][ODBC Visual FoxPro Driver]Syntax error.
[_errorCode] => 37000
[_queryID] =>
[_isPersistentConnection] =>
[_evalAll] =>
[_affected] =>
[_logsql] =>
[_transmode] =>
[_error] =>
)
The error doesn't say much. I can copy and paste the code into MySQL and it runs fine and returns what I expect. Hopefully another set of eyes, with more Fox Pro experience, can see what the issue is here.
Thanks for any assistance.
Your subquery is incorrect. This is the subquery:
INNER JOIN (
SELECT custno, item, MAX(shipdate) as last_shipdate
FROM sotran01
WHERE shipdate >= {d'2013-05-23'}
AND shipdate <= {d'2014-05-23'}
GROUP BY custno, item, last_shipdate
-------------------------------^
)
That is an aggregation column. Remove it:
INNER JOIN (
SELECT custno, item, MAX(shipdate) as last_shipdate
FROM sotran01
WHERE shipdate >= {d'2013-05-23'}
AND shipdate <= {d'2014-05-23'}
GROUP BY custno, item
)
since hours I try to solve the following error from the paypal Instant Update API
[L_ERRORCODE0] => 11832
[L_SHORTMESSAGE0] => Maximum amount of order is less than itemized amounts.
[L_LONGMESSAGE0] => Maximum amount of order is less than itemized amounts.
Here is the Request:
Method: SetExpressCheckout
Request:
Formatted Request: Array
(
[PAYMENTREQUEST_0_AMT] => 3.00
[PAYMENTREQUEST_0_CURRENCYCODE] => EUR
[PAYMENTREQUEST_0_ITEMAMT] => 1.00
[PAYMENTREQUEST_0_SHIPPINGAMT] => 1.00
[PAYMENTREQUEST_0_NOTIFYURL] => http://www.eee.de/ipn.php
[PAYMENTREQUEST_0_CALLBACK] => http://www.eee.de/ajax.php?action=eee
[PAYMENTREQUEST_0_MAXAMT] => 11.00
[LOGO] => https://www.eee.de/template/img/logo-eee.png
[CANCELURL] => http://eee.de/bestellung.php?paypal_express=cancel
[RETURNURL] => http://eee.de/bestellung.php?paypal_express=return
[L_PAYMENTREQUEST_0_AMT0] => 1.00
[L_PAYMENTREQUEST_0_NAME0] => Item
[L_PAYMENTREQUEST_0_DESC0] => Desc
[L_PAYMENTREQUEST_0_QTY0] => 1
[L_PAYMENTREQUEST_0_NUMBER0] => 123
[CALLBACKVERSION] => 82.0
[CALLBACK] => http://www.eee.de/ajax.php?action=ppe_shipping
[L_SHIPPINGOPTIONISDEFAULT0] => true
[L_SHIPPINGOPTIONNAME0] => UPS0
[L_SHIPPINGOPTIONAMOUNT0] => 1.00
[L_SHIPPINGOPTIONISDEFAULT1] => false
[L_SHIPPINGOPTIONNAME1] => UPS2
[L_SHIPPINGOPTIONAMOUNT1] => 2.00
[L_SHIPPINGOPTIONISDEFAULT2] => false
[L_SHIPPINGOPTIONAMOUNT2] => 3.00
[PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED] => true
[PAYMENTREQUEST_0_INSURANCEAMT] => 1.00
)
I tried every combination of values
this is the response from the Callbackurl:
METHOD=CallbackResponse
&OFFERINSURANCEOPTION=true
&L_SHIPPINGOPTIONNAME0=UPS0
&L_SHIPPINGOPTIONAMOUNT0=1.00
&L_INSURANCEAMOUNT0=1.00
&L_SHIPPINGOPTIONISDEFAULT0=true
&L_SHIPPINGOPTIONNAME1=UPS1
&L_SHIPPINGOPTIONAMOUNT1=2.00
&L_INSURANCEAMOUNT1=1.00
&L_SHIPPINGOPTIONISDEFAULT1=false
&L_SHIPPINGOPTIONNAME2=UPS2
&L_SHIPPINGOPTIONAMOUNT2=3.00
&L_INSURANCEAMOUNT2=1.00
&L_SHIPPINGOPTIONISDEFAULT2=false
As far as I understand, the MAXAMT value is the total of items + max shipping + tax + factor x so why to hell does it compare it this way? 11.00 < 3.00 (3.00 = item+shipping+insurance)
I am totally lost!
Thanks for any hint!
Try to use MAXAMT instead of PAYMENTREQUEST_0_MAXAMT.
Actually the PayPal documentation sucks as same things are described totally differently in PayPal documentation.
I'm trying to query FB for a Page Stream using FQL in PHP, and I get all the data except impressions. The FB_ACCESS_TOKEN used is the OAuth token for my FB App, where I have granted the following scope: offline_access,manage_pages,email,read_insights,sms,publish_stream
Code example:
$this->fb->api(array(
"method" => "fql.multiquery",
"queries" => json_encode(array(
"post" => "SELECT post_id, source_id, updated_time, created_time, actor_id,
message, attachment, impressions, likes, privacy,
permalink, comments
FROM stream WHERE source_id='".$source_id."'
AND created_time > '".$date_updated."'",
"comment" => "SELECT post_id, fromid, time, text, id, likes, object_id
FROM comment WHERE post_id IN (SELECT post_id FROM #post)
AND time> '".$date_updated."'"
)), access_token" => FB_ACCESS_TOKEN
));
Here is the example output:
[...]
[0] => Array(
[post_id] => 107112482661088_236459409726394
[source_id] => 107112482661088
[updated_time] => 1312884237
[created_time] => 1312884237
[actor_id] => 608795063
[message] => funker jo ikke detta nå da :( får ikke spilt i det hele tatt :#
[attachment] => Array(
[description] =>
)
[impressions] =>
[likes] => Array(
[href] => http://www.facebook.com/browse/?type=likes&id=236459409726394
[count] => 0
[sample] => Array()
[friends] => Array()
[user_likes] =>
[can_like] =>
)
[privacy] => Array(
[value] =>
)
[permalink] => http://www.facebook.com/hacktheplanet.no/posts/236459409726394
[comments] => Array(
[can_remove] =>
[can_post] =>
[count] => 0
[comment_list] => Array()
)
)
[...]
Any suggestions or reasons why I don't get the impression data?
Have you tried this query for a post that is several days old?
Facebook Insights seems to usually be 24 to 48 hours behind and I believe that is the source of the impressions value.
To validate, I ran your FQL query for a post created today on a page that I have read_insights permissions for. The result for "impressions" was null (like in your example).
I then ran the same query for a post three days ago and the number of impressions was present.