August 29, 2008
James Fairhurst has come up with an excellent series of postings on how to build a full application using CakePHP. It is a wonderful tutorial for newbies who are starting on CakePHP. Thanks James!
Follow the whole series here: http://www.jamesfairhurst.co.uk/tags/view/cakephp/
Leave a Comment » |
cakephp, php |
Permalink
Posted by singchyun
August 26, 2008
If Unicodes end up as funny characters after inserting into MySQL, then try executing SET NAMES ‘utf8′ immediately after obtaining a DB connection. For example:
$link = mysql_connect(‘localhost’,'myuser’,'mypassword’);
mysql_query(“SET NAMES ‘utf8′”);
mysql_select_db(‘mydb’);
References: http://www.adviesenzo.nl/examples/php_mysql_charset_fix/
2 Comments |
mysql, php |
Permalink
Posted by singchyun
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);
Leave a Comment » |
php |
Permalink
Posted by singchyun
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
Leave a Comment » |
php |
Permalink
Posted by singchyun
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);
?>
Leave a Comment » |
mysql, php |
Permalink
Posted by singchyun
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.
2 Comments |
mysql, php |
Permalink
Posted by singchyun