Friday, August 16, 2013

php: split is deprecated explode doesnt work passing query parameters

php: split is deprecated explode doesnt work passing query parameters

I am doing some website maintenance and have a file called pic_large.php
which retrieves passed parameters and displays a full size image using
javascript:createWindow. The code is working fine on the prod server but
on my test machine running a later version of php i am getting a function
split is deprecated error. I have tried replacing the split function with
reg_split and explode but am not having any success. With either of these
functions, the popup window is displayed but the image fails to appear.
Here is my code:
<html>
<?php
//retrieve passed parameters
$p = split('[=&]',(string)$_SERVER['QUERY_STRING']);
?>
<head><title><?php echo $p[6]; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="popup.css" type="text/css">
</head><body>
<div>
<center>
<?php echo "<img src=\"photos/$p[1]\" width=$p[3] height=$p[5]
alt=\"$p[6]\">\n"; ?>
</center>
</div>
</body>
I am pretty sure the problem lies with the following line but despite my
best efforts i have been unable to fix it.
$p = split('[=&]',(string)$_SERVER['QUERY_STRING']);
The code that calls the pic_large.php is:
echo "<a href=\"javascript:createWindow('pic_large.php?";
It may be a simple fix but i am still learning php so would appreciate any
help..

No comments:

Post a Comment