PHP “&” operator

Those are references, and they are similar to “pointers” in C or C++. More information is in the PHP manual. In this case, since $db_hosts is empty, the construct $db_hosts[$db_item[‘hostid’]] will create a new array with an empty item on the index of $db_item[‘hostid’] and return the item’s reference, making $db_host act as an ‘alias’ for whatever $db_hosts[$db_item[‘hostid’]] is currently.

Fatal error: Out of memory, but I do have plenty of memory (PHP)

I ran accross the same kind of problem with the server dying when trying to use the swap. This is because mod_php does not free memory ever. So Apache processes keep growing either reaching apache or PHP’s memory limit or, if there’s no limit, crashing the server. Restarting apache makes it to spawn new fresh slim … Read more

How to convert string to boolean php

Strings always evaluate to boolean true unless they have a value that’s considered “empty” by PHP (taken from the documentation for empty): “” (an empty string); “0” (0 as a string) If you need to set a boolean based on the text value of a string, then you’ll need to check for the presence or otherwise of that value. … Read more

Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)

Changing the memory_limit by ini_set(‘memory_limit’, ‘-1′); is not a proper solution. Please don’t do that. Your PHP code may have a memory leak somewhere and you are telling the server to just use all the memory that it wants. You wouldn’t have fixed the problem at all. If you monitor your server, you will see that it is now probably using … Read more

What does MYSQLI_NUM mean and do?

MYSQLI_NUM is a constant in PHP associated with a mysqli_result. If you’re using mysqli to retrieve information from the database, MYSQLI_NUM can be used to specify the return format of the data. Specifically, when using the fetch_array function, MYSQLI_NUM specifies that the return array should use numeric keys for the array, instead of creating an … Read more

Laravel 5 MethodNotAllowedHttpException in RouteCollection.php line 201:

This is how I do it. Routes.php admin_login.blade.php dashboard.blade.php UsersController.php Your Code: In routes.php, you have only 1 route, i.e., And there is no declaration of post method, hence, the MethodNotAllowedHttpException Also, in your controller, you are returning the view first and then processing the form which is not going to work at all. You first need to process … Read more

MySQL query to get column names?

The best way is to use the INFORMATION_SCHEMA metadata virtual database. Specifically the INFORMATION_SCHEMA.COLUMNS table… It’s VERY powerful, and can give you TONS of information without need to parse text (Such as column type, whether the column is nullable, max column size, character set, etc)… Oh, and it’s standard SQL (Whereas SHOW … is a MySQL specific extension)… For more information … Read more

Laravel 5 Class ‘Collective\Html\HtmlServiceProvider’ not found on AWS

When you update your composer it will check the providers. Because you haven’t installed laravelcollective/html yet he can’t find it and throws an error: So first require your packeges, then add them to the config file. You can also work with composer require laravelcollective/html, it will add it to the json file automatically. Then it doesn’t matter if … Read more

“Fatal error: Cannot redeclare function”

This errors says your function is already defined ; which can mean : you have the same function defined in two files or you have the same function defined in two places in the same file or the file in which your function is defined is included two times (so, it seems the function is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)