Convert DateTime to String PHP

You can use the format method of the DateTime class: If format fails for some reason, it will return FALSE. In some applications, it might make sense to handle the failing case:

Easy way to password-protect php page

Not exactly the most robust password protection here, so please don’t use this to protect credit card numbers or something very important. Simply drop all of the following code into a file called (secure.php), change the user and pass from “admin” to whatever you want. Then right under those lines where it says include(“secure.html”), simply … Read more

How to fix syntax error, unexpected T_IF error in php?

PHP parser errors take some getting used to; if it complains about an unexpected ‘something’ at line X, look at line X-1 first. In this case it will not tell you that you forgot a semi-colon at the end of the previous line , instead it will complain about the if that comes next. You’ll … Read more

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