Failed image upload in Joomla 1.5

July 31, 2008

If we encounter error 403 while uploading images in Joomla 1.5, try adding these 2 lines in .htaccess:

SecFilterEngine Off
SecFilterScanPOST Off

The fix works for me.

References: http://www.dart-creations.com/the-joomla-blog/blog/media-manager-upload-failed-403-error.html


How to display PHP compilation errors

May 30, 2008

It’s frustrating when PHP compilation errors are not shown during development. To make such compilation errors visible on the web pages, add this line in .htaccess:

php_value display_errors 1

Alternatively, if access to .htaccess is not allowed, this PHP code achieves the same result too:

ini_set(’display_errors’,1);


LAMP Virtual Appliance

June 19, 2007

This is a LAMP VM that’s certified by VMWare: http://www.virtualappliances.net/products/lamp.php

Default username/password is root/root.


WURFL

May 29, 2007

The WURFL is an XML configuration file which contains information about capabilities and features of many mobile devices: http://wurfl.sourceforge.net/index.php


PEAR: No handlers error

May 17, 2007

When running PEAR manager to install a package (eg, ./pear install Log), if you encounter this error “No handlers for package.xml version 2.0″, it means your PEAR needs upgrading.

The command to upgrade PEAR:

./pear upgrade PEAR

When upgrading PEAR, you might be prompted to upgrade some other dependencies (such as Archive_Tar):

./pear upgrade Archive_Tar


Template for PHP MySQL queries

May 7, 2007

<?
$link = mysql_connect(’localhost’, ‘root’, ‘password’);
if (!$link) {
die(’Could not connect: ‘ . mysql_error());
}

$db_selected = mysql_select_db(’jsfbasic’, $link);

$result = mysql_query(’SELECT * FROM recipe’, $link);

if (!$result) {
die(’Invalid query: ‘ . mysql_error());
}

while ($row = mysql_fetch_array($result)) {
echo $row[0] . ‘<br />’;
}

mysql_close($link);
?>


Last inserted ID in MySQL

May 6, 2007

To retrieve the last inserted ID of the auto_increment column:

mysql> select last_insert_id();

The PHP equivalent is:

mysql_insert_id

The above must be invoked from the same thread that performed the insertion.


Predefined variables in PHP

April 9, 2007

A list of predefined variables in PHP:

  • $GLOBALS
  • $_SERVER
  • $_GET
  • $_POST
  • $_COOKIE
  • $_FILES
  • $_ENV
  • $_REQUEST
  • $_SESSION

Source of info: http://sg.php.net/en/language.variables.predefined