Not equal to != and !== in PHP

== and != do not take into account the data type of the variables you compare. So these would all return true: === and !== do take into account the data type. That means comparing a string to a boolean will never be true because they’re of different types for example. These will all return false: You should compare data types for functions that … Read more

How do I embed PHP code in JavaScript?

If your whole JavaScript code gets processed by PHP, then you can do it just like that. If you have individual .js files, and you don’t want PHP to process them (for example, for caching reasons), then you can just pass variables around in JavaScript. For example, in your index.php (or wherever you specify your layout), you’d do something … Read more

What is PHPSESSID?

PHP uses one of two methods to keep track of sessions. If cookies are enabled, like in your case, it uses them. If cookies are disabled, it uses the URL. Although this can be done securely, it’s harder and it often, well, isn’t. See, e.g., session fixation. Search for it, you will get lots of SEO advice. The conventional wisdom … Read more

Why use $_SERVER[‘PHP_SELF’] instead of “”

The action attribute will default to the current URL. It is the most reliable and easiest way to say “submit the form to the same place it came from”. There is no reason to use $_SERVER[‘PHP_SELF’], and # doesn’t submit the form at all (unless there is a submit event handler attached that handles the submission).

PDO with INSERT INTO through prepared statements

You should be using it like so Prepared statements are used to sanitize your input, and to do that you can use :foo without any single quotes within the SQL to bind variables, and then in the execute() function you pass in an associative array of the variables you defined in the SQL statement. You may also use ? instead of :foo and then pass in … Read more

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