I'm trying to diagnose an error that we are receiving on our priceGen script. The error that shows up is:
[Wed Jun 22 13:07:42 2011] [error] [client 178.203.13.221] PHP Notice: Use of undefined constant p - assumed 'p' in /var/www/vhosts/cardhoarder.com/httpdocs/store/priceGen.php on line 5, referer: http://www.cardhoarder.com/store/index.php?target=products&product_id=5366
When I visit that URL the image based price does show up as expected. However, I don't know why I receive this error or how to fix it.
<?php
header('Content-Type: image/gif');
$price = $_REQUEST[p];
/*$currencyType = $_REQUEST[c];
if ( $currencyType == 1 ) {
$currencySymbol = '$';
} elseif ( $currencyType == 2 ) {
$currencySymbol = '€';
} elseif ( $currencyType == 3 ) {
$currencySymbol = '';
}*/
$encryptedPrice = $price;
if ( file_exists("prices/$encryptedPrice.gif") ) {
$im = imagecreatefromgif("prices/$encryptedPrice.gif");
imagegif($im);
imagedestroy($im);
} else {
$fontSize = 10;
$salt1 = "EveryoneKnowsIt'sWindy!";
$salt2 = "JohnnyHatesJazz_:-(";
$priceForArray = 0;
while ( $priceForArray <= 2000 ) {
$formattedPrice = number_format($priceForArray,2);
$rawPriceArray[md5($salt1.$formattedPrice.$salt2)] = $formattedPrice;
$priceForArray += .01;
}
$price = $rawPriceArray[$price];
// Debug :: Output price array.
/*$data = implode("\n",$rawPriceArray);
file_put_contents("rawPrice.txt",$data);*/
$im = imagecreatetruecolor(50, $fontSize+1);
$white = imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 153, 0, 0);
imagefilledrectangle($im,0,0,100,$fontSize+1,$white);
imagecolortransparent($im,$white);
$text = $price;
$font = 'arial.ttf';
imagettftext($im, $fontSize, 0, 0, $fontSize+1, $red, $font, $text);
$price = str_replace('.',"",$price);
$price = str_replace('$',"",$price);
imagegif($im,"prices/$encryptedPrice.gif");
imagegif($im);
imagedestroy($im);
}
?>
Thanks for the assistance.
Movaria