$_SERVER[‘PATH_INFO’] not working!

Written by leif. Posted in PHP, Programmering

if (isset($_SERVER['PATH_INFO'])) {
    $request_uri = trim($_SERVER['PATH_INFO'], '/');
} elseif (isset($_SERVER['ORIG_PATH_INFO'])) {
    $request_uri = trim(str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['ORIG_PATH_INFO']), '/');
} else {
    $request_uri = '';

echo "PATH_INFO = " . $_SERVER['PATH_INFO'] . "<br>"; 
echo "\$request_uri = ".$request_uri . "<br>";
echo "All server vars<br>";
echo "<pre>";
echo "</pre>";
echo "tested with: http://localhost:8080/wordpress/leif.php/asd/qwe<br>";
echo "Output:<pre>";
echo "

PATH_INFO = /asd/qwe
$request_uri = asd/qwe
All server vars
    [HTTP_HOST] => localhost:8080
    [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    [HTTP_CONNECTION] => keep-alive

How to ‘insert if not exists’ in MySQL?

Written by r2d2. Posted in Mysql, PHP, Tips

see http://bogdan.org.ua/2007/10/18/mysql-insert-if-not-exists-syntax.html

there’s also INSERT … ON DUPLICATE KEY UPDATE syntax, you can find explanations on dev.mysql.com

Post from bogdan.org.ua
18th October 2007

To start: as of the latest MySQL, syntax presented in the title is not possible. But there are several very easy ways to accomplish what is expected using existing functionality.

There are 3 possible solutions: using INSERT IGNORE, REPLACE, or INSERT … ON DUPLICATE KEY UPDATE.Imagine we have a table:

CREATE TABLE `transcripts` (

fpdf – tabel-cells example

Written by r2d2. Posted in PHP, Programmering


$pdf->Cell(40,5,'[ x ] checkbox1′,1,0,’L’,0);
$pdf->Cell(40,5,'[ x ] checkbox2′,1,0,’L’,0);
$pdf->Cell(40,5,'[ x ] checkbox3′,1,0,’L’,0);


$pdf->Cell(40,5,'[ x ] checkbox4′,1,0,’L’,0);
$pdf->Cell(40,5,'[ x ] checkbox5′,1,0,’L’,0);
$pdf->Cell(40,5,'[ x ] checkbox6′,1,0,’L’,0);


Written by leif. Posted in PHP, Programmering

Do not use any of the suggested versions of PHP_SELF. It is a security nightmare, opening up your PHP to a multitude of possible injection attacks.

What are you trying to achieve? Generate the URL for a form sending to itself? Use action=”” for that – it is a valid approach and will always use the URL for sending the form as for loading.

If you must know the requested script, use $_SERVER[‘SCRIPT_NAME’] instead.

Or $_SERVER[‘PHP_SELF’], not $PHP_SELF. See the docs