PHP if not statements

Your logic is slightly off. The second || should be &&: You can see why your original line fails by trying out a sample value. Let’s say $action is “delete”. Here’s how the condition reduces down step by step: Oops! The condition just succeeded and printed “error”, but it was supposed to fail. In fact, … Read more

SSL error SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

The file that you downloaded (http://curl.haxx.se/ca/cacert.pem) is a bundle of the root certificates from the major trusted certificate authorities. You said that the remote host has a self-signed SSL certificate, so it didn’t use a trusted certificate. The openssl.cafile setting needs to point to the CA certificate that was used to sign the SSL certificate … Read more

How to make a countdown using PHP

If your need your counter to be displayed only on page refresh and be static once the page is loaded, then PHP will be fine. If you need the countdown to get refreshed when the page is displayed, you’ll need to use JavaScript. Personally I would go for something already implemented, like that small script.

How do I expire a PHP session after 30 minutes?

You should implement a session timeout of your own. Both options mentioned by others (session.gc_maxlifetime and session.cookie_lifetime) are not reliable. I’ll explain the reasons for that. First: session.gc_maxlifetimesession.gc_maxlifetime specifies the number of seconds after which data will be seen as ‘garbage’ and cleaned up. Garbage collection occurs during session start. But the garbage collector is … Read more

Message: Trying to access array offset on value of type null [duplicate]

This happens because $cOTLdata is not null but the index ‘char_data’ does not exist. Previous versions of PHP may have been less strict on such mistakes and silently swallowed the error / notice while 7.4 does not do this anymore. To check whether the index exists or not you can use isset(): Which means the line should look something like … Read more

Reference — What does this symbol mean in PHP?

Incrementing / Decrementing Operators ++ increment operator — decrement operator These can go before or after the variable. If put before the variable, the increment/decrement operation is done to the variable first then the result is returned. If put after the variable, the variable is first returned, then the increment/decrement operation is done. For example: Live example In the case above ++$i is … Read more

How to create cron job using PHP?

This is the best explanation with code in PHP I have found so far: http://code.tutsplus.com/tutorials/managing-cron-jobs-with-php–net-19428 In short: Although the syntax of scheduling a new job may seem daunting at first glance, it’s actually relatively simple to understand once you break it down. A cron job will always have five columns each of which represent a … Read more

Are PDO prepared statements sufficient to prevent SQL injection?

The short answer is NO, PDO prepares will not defend you from all possible SQL-Injection attacks. For certain obscure edge-cases. I’m adapting this answer to talk about PDO… The long answer isn’t so easy. It’s based off an attack demonstrated here. The Attack So, let’s start off by showing the attack… In certain circumstances, that will return more than … Read more

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