<?php
header('Content-Type: image/png');
$official = "myImage.png";
if(!isset($_GET['url']))
$imageurl = $official;
else
$imageurl = $_GET['url'];
include 'dbc.php';
if($imageurl != $official)
{
$result = mysqli_query($myLink, "SELECT * FROM bannerimages WHERE url='".$imageurl."'");
if(mysqli_num_rows($result) != 0)
{
$bdata = mysqli_fetch_array($result);
if($bdata['status'] == 1)
$imageurl = $official;
}
else
mysqli_query($myLink, "INSERT INTO bannerimages SET url='".$imageurl."', status=0");
}
if(isset($_GET['id']))
mysqli_query($myLink, "UPDATE users SET credits=credits+1 WHERE id='".$_GET['id']."'");
$suffix = substr($imageurl, strlen($imageurl) - 3);
switch(strtolower($suffix))
{
case "jpg":
$image = imagecreatefromjpeg($imageurl);
break;
case "png":
$image = imagecreatefrompng($imageurl);
break;
default:
imagecreatefrompng($official);
break;
}
imagepng($image, NULL, 9);
?>
the idea is that it is a banner for a website where the user can customize the image if they want to and add one credit to their account every time someone shows the image. The code works perfectly except the fact that it updates the credit field with twice the amount. If I code it to update it with 50 it adds 100, if I code it to add 100 it adds 200...What am I doing wrong?
Edited by hampus.tagerud, 18 October 2010 - 04:47 AM.


Sign In
Create Account


Back to top









