dflow Posted November 4, 2013 Share Posted November 4, 2013 I have the following <img> on a completed.php after a signup.php <img src="http://example.com/pixelimage.php?AffID=98798" width="1" height="1"> the pixel is generated here pixelimage.php <?php // Create an image, 1x1 pixel in size $im=imagecreate(1,1); // Set the background colour $white=imagecolorallocate($im,255,255,255); // Allocate the background colour imagesetpixel($im,1,1,$white); // Set the image type header("content-type:image/jpg"); // Create a JPEG file from the image imagejpeg($im); // Free memory associated with the image imagedestroy($im); if (isset($_GET['AffID'])) { // $query_add="UPDATE auth_table SET etat = replace(etat,'$anc','$nv') where user_id LIKE // '%$log%'"; // $query_exec=mysql_query($query_add) or die(mysql_error()); // <script language='JavaScript'>alert('Activation termine')</script> echo $AffID = $_GET['AffID']; $date = date("Y-d-m"); $hour = date("H:i"); $op=$date.$hour.'Affiliate ID : '.$AffID; $op .= "\n"; $file = 'log.txt'; $search = file_get_contents($file); $check = strpos($search, $log); if ($check === FALSE) { $fp = @fopen($file, 'a'); $write = @fputs($fp, $op); @fclose($fp); } } ?> the image is generated but the action does not get logged. I can only get it logged when I reload the completed.php page. what did I mess up? Quote Link to comment https://forums.phpfreaks.com/topic/283582-pixel-image-not-logged-basic-conversion-tracking/ Share on other sites More sharing options...
.josh Posted November 4, 2013 Share Posted November 4, 2013 i don't think it's the only problem but one thing I see is that $log is not defined when you are using it in your strpos Quote Link to comment https://forums.phpfreaks.com/topic/283582-pixel-image-not-logged-basic-conversion-tracking/#findComment-1456870 Share on other sites More sharing options...
dflow Posted November 4, 2013 Author Share Posted November 4, 2013 i don't think it's the only problem but one thing I see is that $log is not defined when you are using it in your strpos how else can I test the img firing back? Quote Link to comment https://forums.phpfreaks.com/topic/283582-pixel-image-not-logged-basic-conversion-tracking/#findComment-1456873 Share on other sites More sharing options...
.josh Posted November 4, 2013 Share Posted November 4, 2013 well what I'm saying is $check = strpos($search, $log); you don't define $log anywhere. Quote Link to comment https://forums.phpfreaks.com/topic/283582-pixel-image-not-logged-basic-conversion-tracking/#findComment-1456877 Share on other sites More sharing options...
dflow Posted November 4, 2013 Author Share Posted November 4, 2013 well what I'm saying is $check = strpos($search, $log); you don't define $log anywhere. even with $log defined It isn't logged via the remote page. Quote Link to comment https://forums.phpfreaks.com/topic/283582-pixel-image-not-logged-basic-conversion-tracking/#findComment-1456878 Share on other sites More sharing options...
Ch0cu3r Posted November 4, 2013 Share Posted November 4, 2013 (edited) Remove the error suppression ( the @) from in front of the fopen, fwrite and fclose functions and turn error reporting on. They could be returning an error when trying to write to the log. If an error occurs then nothing will be written to the log. Also what is the purpose of $check = strpos($search, $log); Edited November 4, 2013 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/283582-pixel-image-not-logged-basic-conversion-tracking/#findComment-1456882 Share on other sites More sharing options...
dflow Posted November 4, 2013 Author Share Posted November 4, 2013 Remove the error suppression ( the @) from in front of the fopen, fwrite and fclose functions and turn error reporting on. They could be returning an error when trying to write to the log. If an error occurs then nothing will be written to the log. Also what is the purpose of $check = strpos($search, $log); I used a quick script I found, I removed the $check and still I the <img> is not logged and no errors, the log works when I reload pixelimage.php Quote Link to comment https://forums.phpfreaks.com/topic/283582-pixel-image-not-logged-basic-conversion-tracking/#findComment-1456893 Share on other sites More sharing options...
dflow Posted November 4, 2013 Author Share Posted November 4, 2013 I managed to get it working, thanks for the input Quote Link to comment https://forums.phpfreaks.com/topic/283582-pixel-image-not-logged-basic-conversion-tracking/#findComment-1456895 Share on other sites More sharing options...
.josh Posted November 4, 2013 Share Posted November 4, 2013 what was the problem? I was gonna next suggest image caching.. Quote Link to comment https://forums.phpfreaks.com/topic/283582-pixel-image-not-logged-basic-conversion-tracking/#findComment-1456903 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.