PHP get image width & height
September 25, 2014
To get the width and height of the image use getimagesize(path_name), this function returns the array which contains the height, width, image_type constant and other image related info. By the following code you can achive that. See also PHP resize image using ratio
PHP delete file in directory
September 15, 2014
If to delete a single file, use the unlink() function. Unlink can safely remove a single file. That function will delete what you pass it as a parameter. For example, delete single file Delete multiple file in a directory, use loop:
PHP check if image file exists
September 12, 2014
File_exists does something weird, it does not say if a file exists, it says if path exists. So, to check if it is a file then you should use is_file together with file_exists to know if there is really a file behind the path, otherwise file_exists will return true for any existing path. Example:
PHP MySql query for random record from database table
September 5, 2014
The simplest way of selecting random rows from the MySQL database is to use “ORDER BY RAND()” clause in the query. Example:
PHP array random value array_rand
September 5, 2014
Returns a set of keys for random entries of array. If you want to pick all entries in a randomized fashion you should be using: ref: http://stackoverflow.com/questions/18046630/php-array-rand-random-value/25678043#25678043
jQuery get which radio is selected
August 22, 2014
Use the :checked selector along with the radio selector. With form id, can do this Without form is, it will still work:
AWS Use of undefined constant CURLE_COULDNT_RESOLVE_HOST
August 22, 2014
It appears that you are missing curl. If you are linux you can usually install it via the package manager package would be named something similar to php-curl. If windows, enable the curl extension in php.ini To check if curl installed in php, you may create a phpinfo.php file in your server root and run […]
Ubuntu phpmyadmin connect to mysql error: #2002 cannot log in to the mysql server
August 22, 2014
If phpmyadmin cannot connect to mysql error: #2002 cannot log in to the mysql server Run: sudo nano /etc/mysql/my.cnf Update bind-address = 192.168.0.2 To bind-address = localhost This fixed the problem. Enjoy. ref: here
Ubuntu 10.04.4 upgrade php 5.3.2 to 5.3.6
August 22, 2014
For anyone who wants to upgrade Ubuntu 10.04 LTS to PHP 5.3.10, this is how I have done it. Note sudo apt-add-repository ppa:brianmercer/php5 doesn’t work anymore. Suspect has been taken down. sudo apt-add-repository ppa:brianmercer/php5 will not work anymore However the steps below do work!! sudo add-apt-repository ppa:bjori/php5 sudo apt-get update sudo aptitude show php5 Package: […]
PHP get first key in associative array
August 7, 2014
If efficiency is not that important can use array_keys($yourArray)[0] in PHP 5.4 (and higher). Output: a
Recent Comments