Tag Archive | "php"

PHP : Cannot use a scalar value as an array

Tuesday, February 26, 2008

9 Comments

I was working on a WordPress plugin today and came across the most disturbing PHP warning error which I have never seen before in all the time that I’ve worked with PHP. The warning error message was : Warning: Cannot use a scalar value as an array What caused this error was when I tried [...]

Continue reading...

Xampp phpMyAdmin Problem

Saturday, February 23, 2008

11 Comments

I started XAMPP today and tried to open phpMyAdmin (http://localhost/phpmyadmin/) in my browser in order to do some database management. Unfortunately I was presented with the following error message : cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly After playing around [...]

Continue reading...

PHP: Random string with numbers and letters

Monday, October 1, 2007

91 Comments

I thought that some of you might find it useful to learn how to generate a random string or a random number with PHP. I wrote a quick function to use PHP to generate random. See it below : function genRandomString() {     $length = 10;     $characters = ’0123456789abcdefghijklmnopqrstuvwxyz’;     $string [...]

Continue reading...

PHP : Strip or find a file extension

Saturday, September 29, 2007

4 Comments

Getting a file’s extension is essential when working with uploads and other manipulations complying with files. You might have a user uploading a file and you need to rename the file before moving it from the temporary upload directory. In order to do so, you can obtain the file extension and then rename it to [...]

Continue reading...

CakePHP : Delete multiple records

Thursday, September 20, 2007

6 Comments

With CakePHP, you can remove multiple records from a database table using the deleteAll() model method. deleteAll() Usage $this -> Model -> deleteAll($conditions, $cascade = true); Lets say that you wanted to remove all the records for a specific user from the Item model. Below is a quick example. deleteAll() Example $this -> Item -> [...]

Continue reading...