Thursday, June 05, 2008

How to output a number with leading zero's?

Simple:

$number = 15;
printf("%05d", $number);

How do I set the browser timeout?

If your script is too complex to finish within the standard 30 seconds you can set a new value with the function:

set_time_limit(900);

this sets the timeout too 900 seconds / 15 minutes.

How do I format a number in a corect way?

You can use the number_format() function, you can find more information about the function in the PHP manual.

How to send HTML mail with php?

You would need to add a HTML content type to your mail header, as shown below:

mail($recipient, $subject, $message, From: $sender\nContent-Type: text/html;);

When I try to connect to mysql from php I get this error: "Call to unsupported or undefined function mysql_connect();"

Either you are missing mysql support in the php module or you need to load mysql dynamicly in your scripts by inserting:

dl("mysql.so"); (on unix)
dl("mysql.dll"); (on windows);

in the top of all the scripts that use mysql.

But it is recommended to compile php with mysql.