Categories
Mastering Development

Notice: Array to string conversion in PHP Json problems

I’m very new to php I have been watching some youtube videos I have a json file [{"name":"hally","ip":{"ip":[1,2,3,4]}},{"name":"Olojak","ip":{"ip":[11,22,33,44]}},{"name":"Andy","ip":{"ip":[111,222,333,444]}},{"name":"NoMad","ip":{"ip":[1111,2222,3333,4444]}},{"name":"ni","ip":{"ip":[11111,22222,33333,44444]}},{"name":"Nish","ip":{"ip":[111111,222222,333333,444444]}},{"name":"hs","ip":{"ip":[1111111,2222222,333333,4444444]}},{"name":"Kif","ip":{"ip":[11111111,22222222,33333333,44444444]}},{"name":"Kip","ip":{"ip":[111111111,111111111,111111111,11111111]}}] and i want to display each name and ip address this is my php file <?php $jsondata = file_get_contents("info.json"); $names = json_decode($jsondata, true); foreach ($names as $user){ echo $user[‘name’]."<br/>"; echo "IP:".$user[‘ip’]; echo "<br/>"; }; //echo "<br/>"; echo […]

Categories
Mastering Development

Regex to find all quotes between square brackets

Seems pretty simple but I can’t find anything that works. Just want to capture all double quotes between square brackets so I can replace them with an empty string. The values between the quotes are always between [0-9]. Thanks for your help. Input “someText”=[“1111″,”2222”] Output “someText”=[1111,2222]

Categories
CMS Development Wordpress

(T_CONSTANT_ENCAPSED_STRING), expecting ‘) Error [closed]

I’m running into this error with the following Code: $sql=”select * from feeddata2″; $result=mysql_query($sql); $outfile=fopen(“gbase.txt”,”w”); $line1=”id\ttitle\tdescription\tgoogle_product_category\tproduct_type\tlink\timage_link\tcondition\tavailability\tprice\tbrand\tgtin\tmpn\ttax\tshipping\r\n”; fwrite($outfile,$line1); while($rowA=mysql_fetch_array($result)){ $slog1=sprintf(“select itemnum,itemname,itemnum2,picture,shortcat,price1,unitofmeasure from itemmstr2 where itemnum='”.$rowA[“itemnum”].”‘”); $result1 = mysql_query($slog1); $skip = array(“0451″,”0452″,”8682″,”8681″,”1551″,”0451″,”0452″,”7011″,”7012″,”TR238″,”TOL71″,”SN907″,”SN2100″,”SH191″,”S5903″,”PH604″,”PF0493″,”NY243″,”NP4872″,”N8112″,”N4804″,”N4703″,”N3773″,”N3508″,”N3354″,”N3319″,”N3186″,”N3168″,”N3142″,”N3141″,”N3016″,”N2964″,”N2962″,”N2448″,”N2053″,”N1676″,”N0453″,”N0165″,”N0104″,”N0064″,”LH0143″,”KR10″,”JN705″,”JN078″,”HE20″,”GS738″,”G3″,”93714″,”50133″,”41760″,”41600″,”40123″,”35500″,”30001″,”24108″,”20042″,”15059″,”11241″,”10841″,”10642″,”10091″,”10042″,”9662″,”9661″,”9622″,”9621″,”9601″,”9567″,”9561″,”9552″,”9551″,”9513″,”9512″,”9503″,”9501″,”9483″,”9481″,”9441″,”9278″,”9213″,”9042″,”9041″,”8941″,”8922″,”8921″,”8781″,”8741″,”8740″,”8518″,”8482″,”8480″,”8422″,”8421″,”8362″,”8121″,”8092″,”8091″,”8024″,”8011″,”8001″,”7963″,”7962″,”7911″,”7865″,”7861″,”7731″,”7599″,”7533″,”7448″,”7442″,”7441″,”7424″,”7232″,”7231″,”7222″,”7221″,”7182″,”7181″,”7144″,”7092″,”7090″,”7051″,”6982″,”6981″,6771″,”6752″,”6751″,”6732″,”6731″,”6702″,”6701″,”6571″,”6510″,”6492″,”6491″,”6470″,”6452″,”6451″,”6427″,”6392″,”6391″,”6371″,”6362″,”6361″,”6303″,”6301″,”6232″,”6231″,”6112″,”6111″,”6042″,”6041″,”5982″,”5981″,”5896″,”5893″,”5696″,”5693″,”5621″,”5482″,”5481″,”5302″,”5301″,”5291″,”5162″,”5161″,”5136″,”4967″,”4871″,”4859″,”4856″,”4845″,”4665″,”4661″,”4562″,”4561″,”4543″,”4542″,”4541″,”4519″,”4511″,”4434″,”4430″,”4272″,”4271″,”4172″,”4171″,”4072″,”4071″,”4004″,”3925″,”3903″,”3902″,”3820″,”3801″,”3782″,”3781″,”3712″,”3711″,”3682″,”3681″,”3639″,”3631″,”3500″,”3425″,”3352″,”3321″,”3313″,”3311″,”3222″,”3135″,”3094″,”3064″,”3022″,”3021″,”2990″,”2802″,”2761″,”2760″,”2729″,”2726″,”2723″,”2629″,”2621″,”2552″,”2551″,”2542″,”2541″,”2530″,”2513″,”2492″,”2491″,”2472″,”2471″,”2436″,”2395″,”2279″,”2223″,”2222″,”2182″,”2175″,”2137″,”2125″,”2121″,”2094″,”2092″,”2082″,”2033″,”2032″,”2031″,”1860″,”1824″,”1821″,”1782″,”1781″,”1763″,”1761″,”1750″,”1710″,”1633″,”1632″,”1631″,”1541″,”1536″,”1522″,”1521″,”1492″,”1491″,”1394″,”1376″,”1372″,”1362″,”1328″,”1233″,”1231″,”1222″,”1213″,”1211″,”1092″,”1062″,”1061″,”1042″,”1041″,”0942″,”0911″,”0877″,”0811″,”0713″,”0636″,”0622″,”0621″,”0611″,”0575″,”0551″,”0492″,”0491″,”0462″,”0461″,”0435″,”0431″,”0253″,”0213″,”0212″,”0211″,”0161″,”146″,”144″,”134″,”0090″,”0071”); while ($row = mysql_fetch_array($result1)) { if(!in_array($row[“itemnum”],$skip)){ $upcsql=”select UPC from UPC where itemnum='”.$row[“itemnum”].”‘”; echo $upcsql; $upcresult=mysql_query($upcsql); $upcrow=mysql_fetch_array($upcresult); $UPC=$upcrow[“UPC”]; //$title1=str_replace(“<br>”,” “,$row[“itemname”]); //$itemname=ucwords(str_replace(“<BR>”,” “, $title1)); $txt1=”\””.$row[“itemnum”].”\”\t”; $txt1.=ucwords(strtolower($rowA[“itemname”])).”\t”; $txt1.=$rowA[“description”].”\t”; […]

Categories
Development

ERROR 1064 (42000) in MySQL while importing a csv data sheet from another mysql table

I’m very confused why my data isn’t being imported into my table. I’m using the server import and selecting a CSV sheet without formatting. I exported this data from another MySQL table. Here is the error: 15:17:56 Restoring E:\data.csv Running: mysql.exe –defaults-file=”c:\users\user\appdata\local\temp\tmps4jnlt.cnf” –protocol=tcp –host=127.0.0.1 –user=root –port=3306 –default-character-set=utf8 –comments –database=scouting < “E:\data.csv” ERROR 1064 (42000) at […]

Categories
Development

ERROR 1064 (42000) in MySQL while importing a csv data sheet from another mysql table

I’m very confused why my data isn’t being imported into my table. I’m using the server import and selecting a CSV sheet without formatting. I exported this data from another MySQL table. Here is the error: 15:17:56 Restoring E:\data.csv Running: mysql.exe –defaults-file=”c:\users\user\appdata\local\temp\tmps4jnlt.cnf” –protocol=tcp –host=127.0.0.1 –user=root –port=3306 –default-character-set=utf8 –comments –database=scouting < “E:\data.csv” ERROR 1064 (42000) at […]

Categories
Development

Creating a new array from the parents of array child element

I have the following array { “id”: “111”, “name”: “1111”, “children”: [ { “id”: “22222”, “name”: “2222”, “children”: [ { “id”: “AAAA”, “name”: “AAAA”, “children”: [ { “id”: “DDD”, “name”: “DDD” }, { “id”: “EEE”, “name”: “EEE” } ] }, { “id”: “BBBB”, “name”: “BBB”, “children”: [ { “id”: “FFF”, “name”: “FFF” }, { “id”: […]

Categories
Development

Erlang, how to filter out repetead value not using sort

I code as the below. InputList = {1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888}, %% myFunction(Input) returns {ok, Result} %% ResultWithOkList is form of [{ok, Result1}, {ok, Result2},…] ResultWithOkList = [myFunction(Input) || Input <- InputList], ResultList = [Result || {ok, Result} <- ResultWithOkList] ct:pal(“ResultList ~p”, [ResultList]), ResultList is printed [6,6,7,7,4,4,5,5]. What I hope is […]

Categories
Development

Assign groups based on a maximum sum

I need to group rows by some columns and by a running sum until it reaches a threshold. The closest I got was with a query based on this answer, but this solution is not as precise as I need it to be, because the sum has to be reset and restarted when it reaches […]