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

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 solved PHP generate json – list of categories [closed]

[Solved] Switch case from PHP to python

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 solved Switch case … Read more

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

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 websiterootfolder/php/nice_folder … Read more

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

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 is … Read more

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

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 to … Read more

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

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 alerts … Read more

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

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 solved php help – need to echo php using strings

[Solved] Joining queries

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 mysql. … Read more

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

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 solved warning of mysqli_real_escape_string() for this code [closed]

[Solved] How to show all arrays without numbers etc

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 solved How to show all arrays without numbers etc

[Solved] How to nest php inside if statement

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 ?> <meta … Read more