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

Regex to check for new line

I want to check if an if statement is on one line or the next line without a brace like so: or: The regex i have currently is But doesnt work. Anyone have any ideas? To elaborate the only If statement that would not be pulled by this regex is the following:

Cookies vs. sessions

The concept is storing persistent data across page loads for a web visitor. Cookies store it directly on the client. Sessions use a cookie as a key of sorts, to associate with the data that is stored on the server side. It is preferred to use sessions because the actual values are hidden from the … Read more

Error 500: Premature end of script headers

It was a file permission issue. All files on my website were set to a permission level of ‘644.’ Once I changed the permission level to 705 (chmod 705) everything worked. Note that I changed it to 705, but 755 will also work. I also changed the folder it was in to 701 (to hide … Read more

Resize image in PHP

You need to use either PHP’s ImageMagick or GD functions to work with images. With GD, for example, it’s as simple as… And you could call this function, like so… From personal experience, GD’s image resampling does dramatically reduce file size too, especially when resampling raw digital camera images.

What is difference between PHP cli and PHP cgi?

These are the most important differences between CLI and CGI: Unlike the CGI SAPI, CLI writes no headers to the output by default There are some php.ini directives which are overridden by the CLI SAPI because they do not make sense in shell environments: html_errors: CLI default is FALSE implicit_flush: CLI default is TRUE max_execution_time: … Read more

Is a new line = \n OR \r\n?

\n is used for Unix systems (including Linux, and OSX). \r\n is mainly used on Windows. \r is used on really old Macs. PHP_EOL constant is used instead of these characters for portability between platforms.

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