[Solved] Pass PHP variable to server

[ad_1] First of all, you can’t send arrays directly through GET requests (GET requests are the ones with the parameters visible in the url, in layman terms) therefore, you should do the following: $date = “$year-$month”; //example: 2013-09 $link = admin_url(‘admin-ajax.php?my_date=”.$date.”&post_id=’.$post->ID.’&nonce=”.$nonce); breaking the url down to the components, in layman terms: everything before the ? … Read more

[Solved] How to benchmark code to see which runs faster

[ad_1] To benchmark code, you can use microtime() http://php.net/manual/en/function.microtime.php <?php echo ‘modify: ‘; $time = microtime(1); for ($x = 0; $x < 10000; $x++) { $datetime = new DateTime(‘2013-01-29’); $datetime->modify(‘+1 day’); } echo $datetime->format(‘Y-m-d H:i:s’); $end = microtime(1); $time = $end – $time; echo $time . “\n”; echo ‘interval: ‘; $time = microtime(1); for ($x … Read more

[Solved] How to add xml child to first index of an array using php

[ad_1] There are a lot if issues with the code you have, so I’ve just written something new… $result = [“<mo>+</mo><mi>x</mi><mo>=</mo><mfrac><mrow><mo>-</mo><mi>b</mi><mo>±</mo><msqrt><msup><mi>b</mi><mn>2</mn></msup><mo>-</mo><mn>4</mn><mi>a</mi><mi>c</mi></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac>”, “<mo>+</mo><mi>x</mi><mo>+</mo><mn>2</mn><mo>=</mo><mn>3</mn>”, “<mfrac><mrow><mn>2</mn><mi>x</mi><mo>+</mo><mn>2</mn></mrow><mn>3</mn></mfrac><mo>-</mo><mn>3</mn><mo>=</mo><mn>2</mn>”, “<mo>-</mo><mn>3</mn><mo>+</mo><mn>2</mn><mo>=</mo><mi>x</mi>” ]; $arr_result=[]; for ($i=0; $i < count($result) ; $i++) { if (substr($result[$i],0,4)!=”<mo>”) { $arr_result[]= “<mo>+</mo>”.$result[$i]; } else { $arr_result[]= $result[$i]; } } print_r($arr_result); This just goes through each line at a … Read more

[Solved] ok I’ve made a plain api of google translate [closed]

[ad_1] $url = “http://raizen.tk/translate/?lang=”.$_POST[‘lang’].”&term=”.$_POST[‘term’].; has an extra . at the end of the line before the semicolon. Try this: $url = “http://raizen.tk/translate/?lang=”.$_POST[‘lang’].”&term=”.$_POST[‘term’]; 7 [ad_2] solved ok I’ve made a plain api of google translate [closed]

[Solved] I want make a list and and show in double list [closed]

[ad_1] You need to count the records, and then calculate how many rows are required per column: $result = mysql_query(“SELECT * FROM `my_table` WHERE `foo` = ‘bar'”); $num_records = mysql_num_rows($result); $num_columns = 2; $rows_per_col = ceil($num_records / $num_columns); $records = array(); while($row = mysql_fetch_array($result)) { $records[] = $row; } // Now get the columns in … Read more

[Solved] Redirect & Headers already sent [duplicate]

[ad_1] You can only use header(‘…’); before any other output. In your case it should be: <?php //beginning of the file if (isset($_POST[‘Submit’])) { $message = $_POST[‘message’]; $subject = $_POST[‘subject’]; $country_id = $_POST[‘country_id’]; createrow($message, $subject, $country_id); header(‘Location: memberprofile.php’); } ….. ?><!DOCTYPE …. <HTML>…. ….. [ad_2] solved Redirect & Headers already sent [duplicate]

[Solved] Android to PHP and Back [closed]

[ad_1] public void postData() { // Create a new HttpClient and Post Header HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(“http://www.yoursite.com/script.php”); try { // Add your data List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair(“id”, “12345”)); nameValuePairs.add(new BasicNameValuePair(“stringdata”, “AndDev is Cool!”)); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Execute HTTP Post Request HttpResponse response = httpclient.execute(httppost); } catch … Read more

[Solved] how assign value to a variable using anchor tag [duplicate]

[ad_1] No you can not assign values to PHP variable using onClick (JavaScript Function), but it is possible to capture and set URL param through $_GET method. If you are using Codeigniter, you must load CodeIgniter URL Helper Library first. $this->load->helper(‘url’); try below, <?php if(isset($_GET[‘view_set’]) && $_GET[‘view_set’] == ‘list’) { $view_set = “list”; echo “i … Read more

[Solved] Database updates from web host in android

[ad_1] You need to create a webservice. This can be done in PHP (I also use RESTful Api’s). These services will return JSON which you can parse through. Try this out: http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/ [ad_2] solved Database updates from web host in android

[Solved] how can foreach mysql result?

[ad_1] Try PDO. It’s a much better and safer way of interacting with databases for PHP. http://php.net/manual/en/pdo.connections.php $dbh = new PDO(“mysql:host=$host;dbname=$dbname”, $user, $pass); $hetimostfin = array(); $coppers = 3000; $line = 0; $query = <<<SQL SELECT playerID, COUNT(valami2) AS `count` FROM players_extra GROUP BY playerID; SQL; foreach($dbh->query($query, PDO::FETCH_ASSOC) as $row) { $hetimostfin[[$row[‘playerID’]] = $row[‘count’]; // … Read more

[Solved] Filter JSON value encapsulated inside HTML DOM using Regex

[ad_1] Code: (Demo) function extractColumnData($html,$key){ if(!preg_match(“~\.put\(‘\d+’,\s+(.+?)\);~”,$html,$out)){ return “alert yourself of the preg_match failure”; } if(($array=@json_decode($out[1],true))===null && json_last_error()!==JSON_ERROR_NONE){ return “alert yourself of the json decode failure”; } return array_column(current(array_column(current($array),’options’)),$key,’name’); // this assumes the static structure of your json/array data } $html=<<<HTML <script> HZ.productVariation.Manager.setSpaceId(‘33503761’); HZ.data.Variations.put(‘33503761’, {“availVar”: [{“id”: “c”, “label”: “Color”, “options”: [{“name”: “Chrome”, “avail”: 1, “stock”: 1, … Read more

[Solved] How to Remove Duplicates Values from table [duplicate]

[ad_1] Since your screenshot is of phpMyAdmin, I’m going to assume that we’re talking about MySQL here (when asking questions, that’s helpful information as various SQL dialects have different tools that can be used). If you don’t need id in your results, you can just use DISTINCT: SELECT DISTINCT Username, Video FROM YourTableName This returns … Read more