Skip to content

Undefined variable argc PHP

I’m trying to execute this code: But I’m getting the following error: PHP Notice: Undefined variable: argc in /home/me/test.php on line 15 I thought that $argv and $argc were global variables. How can I get rid of this error? I’m running this from command line. Answer Add a after Those varia…

Accessing a public/private function inside a static function?

Due to the fact that you can not use $this-> inside a static functio, how are you supposed to access regular functions inside a static? This throws an error, because you can’t use $this-> inside a static. This throws the following error: How can you access regular methods inside a static method? I…

PHP array unique by column

How to filter an array to give unique elements according to one or more columns. Example: If we choose type and type2 as the unique column. The result of the algorithm should gives I can think of an algorithm by hashing the type concatenate with type2, store in a table and using isset to find the existence. B…

No database selected error message

I am changing all my queries that are using PHP MySQL to MySQLi. I have made a file called db.php with the connection settings. The file includes <?php $db = new mysqli('localhost','…

PHP getting days of a month for a database

I’m making a calender planner with php/css/javascript/html. I am trying to set each day of the month a class which is “day”. I tried using the following: It does not work correctly, it kept duplicating every month and I am not sure how to correctly right the php to achieve what was intended.…

PHP, $this->{$var} — what does that mean?

I have encountered the need to access/change a variable as such: The context is with CI datamapper get rules. I can’t seem to find what this syntax actually does. What do the {‘s do in this context? Why can’t you just use: Answer This is a variable variable, such that you will end up with $t…

Select unexisting values

I have a database with images which can be tagged. To tag them I put a value (which represents a color) in a database table called Tagged Tagged ImgId (example 5) TagId (example 3) I also have …

“no acceptable variant” from MultiViews in Apache

In one deployment of a PHP-based application, Apache’s MultiViews option is being used to hide the .php extension of a request dispatcher script. E.g. a request to …would be handled by …with the trailing part of the request URI available in PATH_INFO. Most of the time this works fine, but oc…