in reply to Image on web page

It is working if i declare the image name directly ($image = "imag1.gif";).

So the first step to debugging the issue would be to print out the value of $image in the case that you retrieve it via ->param(). And depending on the outcome of that check, decide where to dig deeper...  Also, it's never entirely wrong to take a peek at the webserver's error log... (if you have access)