[Solved] PHP generate json – list of categories [closed]

[ad_1] You can use an multi-dimensional array with the json_encode function to achieve this structure. $var = array( “contacts” => array ( array( “id” => 1, “name” => “foo” ), array( “id” => 2, “name” => “bar” ) ) ); echo json_encode($var); 4 [ad_2] solved PHP generate json – list of categories [closed]

[Solved] Switch case from PHP to python

[ad_1] In python there is the if …. elif …. elif….else It is the switch in other languages. But in your code you do not need a switch statement. It’s enough to use a if then else. if flagRound == floor: totalUnits = floor(totalParts / partsInUnit) else: totalUnits = ceil(totalParts / partsInUnit) 3 [ad_2] solved … Read more

[Solved] PHP require_once ‘………..’;

[ad_1] To avoid this type of problems, and for best practice, i advice to use the root path: $root = realpath($_SERVER[“DOCUMENT_ROOT”]); The code above will assign to $root your realpath on the server. After that just use the require/include etc according to your localhost/webserver root : require_once($root/Api/Autotask/vendor/autoload.php) For example, if your file is located in … Read more

[Solved] php form doesn’t post on the page

[ad_1] First, your English is good. Second, there are a lot of things I would recommend working on before being concerned if it posts or not. mysql vs mysqli mysql extension depreciation warning mysql extensions have been depreciated, so you will want to use mysqli. The benefit of working with PHP is that the documentation … Read more

[Solved] Ways of banning someone from a website [closed]

[ad_1] It would be impossible to stop him completely, but you can make it much harder for him. Cookies You can attept to store a cookie on the banned users computer. As long as the user doesn’t delete his cookies or change browser, you can ban his new ips. Registration You can require new users … Read more

[Solved] PHP error: “syntax error, unexpected T_STRING, expecting ‘)’ [closed]

[ad_1] You have issued an if statement. So Naturally, PHP looks to complete the statement. Hence why your getting the error stating an expected closing bracket. Remove your if statement and your code should look like this: if(OS == “XP”){ header(‘Location: XP.html’); exit(); } PHP error reporting isn’t the best tool in the world. It … Read more

[Solved] php help – need to echo php using strings

[ad_1] Concatenate. $tests[] = “http://www.123.com/folder/subfolder.php?u=”.$var2; $tests[] = “http://www.456.com?u=”.$var2.”&myimagelink&mydescription”; $tests[] = “http://www.some-other-site.com/okay/?u=”.$var2.”&myimagelink&mydescription”; Or even simpler, $tests[] = “http://www.123.com/folder/subfolder.php?u=$var2”; $tests[] = “http://www.456.com?u=$var2&myimagelink&mydescription”; $tests[] = “http://www.some-other-site.com/okay/?u=$var2&myimagelink&mydescription”; 1 [ad_2] solved php help – need to echo php using strings

[Solved] find the sum of array value [closed]

[ad_1] <?php $sum1 = 0; $sum2 = 0; foreach($array[‘a’] AS $smallArray){ $sum1 += $smallArray[‘x’]; } foreach($array AS $smallArray){ $sum2 += $smallArray[‘h’][‘n’]; } [ad_2] solved find the sum of array value [closed]

[Solved] Joining queries

[ad_1] SELECT a.id, a.name, a.player_count, a.rating, AVG(p.total_people_count) AS `average` FROM p_alliances a INNER JOIN p_players p ON (p.alliance_id = a.id) GROUP BY a.id ORDER BY a.rating DESC, a.player_count DESC, a.id ASC LIMIT %s,%s If there could be 0 players you might want to change INNER JOIN to LEFT JOIN, but it may impact performance in … Read more

[Solved] warning of mysqli_real_escape_string() for this code [closed]

[ad_1] Your parameters are in the wrong order, read the documentation again. For example: $username = mysqli_real_escape_string(trim($_POST[“username”]), $db); Should be: $username = mysqli_real_escape_string($db, trim($_POST[“username”])); See http://php.net/mysqli_real_escape_string (the procedural style) for the right parameter order. 5 [ad_2] solved warning of mysqli_real_escape_string() for this code [closed]

[Solved] How to show all arrays without numbers etc

[ad_1] This is nothing related to PDO. You might wanna do this: for ($i = 0; $i < count($tijdlijn); $i++) print_r ($tijdlijn[$i][‘bericht’]); Or in a better way: foreach ($tijdlijn as $tijd) print_r ($tijd[‘bericht’]); 0 [ad_2] solved How to show all arrays without numbers etc

[Solved] How to nest php inside if statement

[ad_1] I like this syntax myself ( when working in mixed HTML/PHP ) <?php $blogname = get_bloginfo(‘name’); if ($blogname == ‘Wobbling Willy’): //-note- colon not semi-colon ?> <meta name=”description” content=”<?= bloginfo(‘description’); ?>” /> <meta name=”keywords” content=”keyword1, keyword2, keyword3” /> <?php endif; ?> OR <?php $blogname = get_bloginfo(‘name’); if ($blogname == ‘Wobbling Willy’){ //open bracket ?> … Read more