Dynamisch Plaatje maken
Ik ben met een "fun"-script bezig, deze telt voor elke unieke bezoeker 1 gestolen koekje, het ip van de bezoeker word opgeslagen in een database, waarna deze bezoeker niet nog eens een gestolen koekje erbij telt wanneer hij weer terug komt.
Dit is mijn count.php
dit is mijn createimg.php
Nu zegt ie :
De afbeelding “http://candancreations.co.uk/createimg.php” kan niet worden weergegeven, omdat hij fouten bevat.
Wat doe ik hier fout?
Dit is mijn count.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
include('config.php'); // include the db conection file
$ip = $_SERVER['REMOTE_ADDR']; //Get user IP
$check = mysql_query("SELECT * FROM users_online WHERE ip = '$ip'"); //Check the database for the IP
$check_ip = MYSQL_NUM_ROWS($check);
if($check_ip == 0) //If the Query shows 0 results
{
mysql_query("INSERT INTO users_online (ip) VALUES ('$ip')"); //Add the IP to the Database
}
$show = mysql_query("SELECT * FROM users_online"); //Get all the data from the database for showing the count
$show2 = MYSQL_NUM_ROWS($show); //Count the rows
?>
include('config.php'); // include the db conection file
$ip = $_SERVER['REMOTE_ADDR']; //Get user IP
$check = mysql_query("SELECT * FROM users_online WHERE ip = '$ip'"); //Check the database for the IP
$check_ip = MYSQL_NUM_ROWS($check);
if($check_ip == 0) //If the Query shows 0 results
{
mysql_query("INSERT INTO users_online (ip) VALUES ('$ip')"); //Add the IP to the Database
}
$show = mysql_query("SELECT * FROM users_online"); //Get all the data from the database for showing the count
$show2 = MYSQL_NUM_ROWS($show); //Count the rows
?>
dit is mijn createimg.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
include('count.php');
// Send png image header
header("Content-Type: image/png");
// Declare some vars
$text = $show2;
$font = "arial.ttf";
$fontsize = 7;
// Calc the text size
$box = ImageTTFbbox($fontsize, 0, $font, $text);
// Calc some props for the image
$width = $box[2] - $box[0];
$height = $box[1] - $box[7];
// 10 px empty space on each side
$imagewidth = $width + 30;
$imageheight = $height + 20;
// Create the image
$pic = ImageCreate($imagewidth, $imageheight);
// Set the colors
// Backgroundcolor
$bgcolor = ImageColorAllocate($pic, 0, 0, 255);
// Fontcolor
$fontcolor = ImageColorAllocate($pic, 0, 0, 0);
// Set the fontstart positions
$xstart = 10;
$ystart = $imageheight - 10;
// Write the text
ImageTTFText($pic, $fontsize, 0, $xstart, $ystart, $fontcolor, $font, $text);
// Finish image
ImagePng($pic);
// Clean up memory
ImageDestroy($pic);
?>
include('count.php');
// Send png image header
header("Content-Type: image/png");
// Declare some vars
$text = $show2;
$font = "arial.ttf";
$fontsize = 7;
// Calc the text size
$box = ImageTTFbbox($fontsize, 0, $font, $text);
// Calc some props for the image
$width = $box[2] - $box[0];
$height = $box[1] - $box[7];
// 10 px empty space on each side
$imagewidth = $width + 30;
$imageheight = $height + 20;
// Create the image
$pic = ImageCreate($imagewidth, $imageheight);
// Set the colors
// Backgroundcolor
$bgcolor = ImageColorAllocate($pic, 0, 0, 255);
// Fontcolor
$fontcolor = ImageColorAllocate($pic, 0, 0, 0);
// Set the fontstart positions
$xstart = 10;
$ystart = $imageheight - 10;
// Write the text
ImageTTFText($pic, $fontsize, 0, $xstart, $ystart, $fontcolor, $font, $text);
// Finish image
ImagePng($pic);
// Clean up memory
ImageDestroy($pic);
?>
Nu zegt ie :
De afbeelding “http://candancreations.co.uk/createimg.php” kan niet worden weergegeven, omdat hij fouten bevat.
Wat doe ik hier fout?
Gewijzigd op 01/01/1970 01:00:00 door Bugmenot125
Gesponsorde koppelingen:
Oh, daar kan van alles mis mee lopen.
Bv. heb jij die arial.ttf wel staan?
Je kan die downloaden.
Wat ik aanraad:
Probeer nog eens stap voor stap.
Begin met enkel een achtergrond.
Voeg telkens iets toe; wanneer het mis loopt, weet je waar de fout ligt.
EDIT:
-verder zie ik dat je $show2 nergens een waarde krijgt (misschien heb je het gewoon niet gepost.).
-Zet je variabelen buiten de "" haakjes.
bv. "... WHERE id ='". $id ."'";
Bv. heb jij die arial.ttf wel staan?
Je kan die downloaden.
Wat ik aanraad:
Probeer nog eens stap voor stap.
Begin met enkel een achtergrond.
Voeg telkens iets toe; wanneer het mis loopt, weet je waar de fout ligt.
EDIT:
-verder zie ik dat je $show2 nergens een waarde krijgt (misschien heb je het gewoon niet gepost.).
-Zet je variabelen buiten de "" haakjes.
bv. "... WHERE id ='". $id ."'";
Gewijzigd op 01/01/1970 01:00:00 door Emmanuel Delay
Haal de header eens weg, dan krijg je de errors te zien..



