Forum Moderators: coopster

Message Too Old, No Replies

php script in jpg?

         

CodilX

3:39 pm on Sep 19, 2008 (gmt 0)

10+ Year Member



hi there,

I can't get this darn thing to work..

what I'm trying to create, is a method for counting views on my pic's. the idea is that I have an image, let's say [mydomain.com...] and when the user goes to that image, a mysql counter would add a value to a database, and show the user the image as it normaly does.

my setup is:

i'm using the rewrite engine, and the test image is setup like this:

RewriteRule ^egypt.jpg$ count.php [L]

count.php looks like this:

<?
ob_start();

mysql_add..stuff here

header( "Content-type: image/jpeg" );
@readfile(egypt.jpg);
?>

everything works, but the issue is that instead of the image showing up, i just get this text:

[mydomain.com...]

I tried making the count.php, instead of the readfile(), doing a print "<img.."; and it shows up if i go directly to it, but then if I try to add this image to let's say a forum, the image doesn't show up.

i've seen people at forums that have an image with a similar concept. the image is a counter, and every time someone saw it the counter would add 1 and show it.

hope someone understood my problem and could help me ;) thanks

cameraman

6:24 pm on Sep 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is that the whole script? You need to use ob_end_flush() [us2.php.net] to send the output buffer, or [better IMO] don't use it at all.
Also you need quotes around your filename in readfile.

CodilX

6:55 pm on Sep 19, 2008 (gmt 0)

10+ Year Member



yup that worked :) thx a bunch