BLOB gegevens omzetten naar image
dit:
Show.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
include ('config.php');
$query = 'SELECT id, ean, filename, image FROM pink_covers ORDER BY id ASC LIMIT 5';
$result = mysql_query($query) or die ('Query error!');
?>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#111111" width="100%">
<tr>
<td width="34%" bgcolor="#FF9900" height="21">
<p style="margin-left: 10"><b><font size="2" face="Verdana" color="#FFFFFF">
ID</font></b></td>
<td width="33%" bgcolor="#FF9900" height="21">
<p style="margin-left: 10"><b><font face="Verdana" size="2" color="#FFFFFF">
Type</font></b></td>
<td width="33%" bgcolor="#FF9900" height="21">
<p style="margin-left: 10"><b><font face="Verdana" size="2" color="#FFFFFF">
Download</font></b></td>
</tr>
<?php
while($row = mysql_fetch_array($result))
{
?>
<tr>
<td width="34%" bgcolor="#FFDCA8" height="21">
<p style="margin-left: 10; margin-right: 10">
<font face="Verdana" size="1">
<?php echo $row["id"]; ?>
</font>
</td>
<td width="33%" bgcolor="#FFDCA8" height="21">
<p style="margin-left: 10">
<font face="Verdana" size="1">
<?php echo 'image/jpg'; ?>
</font>
</td>
<td width="33%" bgcolor="#FFDCA8" height="21">
<p style="margin-left: 10"><font face="Verdana" size="1">
<a href="downloadfile.php?id=<?php echo $row["id"]; ?>">
Download
</a></font>
</td>
</tr>
<?php
}
echo "</table>";
?>
include ('config.php');
$query = 'SELECT id, ean, filename, image FROM pink_covers ORDER BY id ASC LIMIT 5';
$result = mysql_query($query) or die ('Query error!');
?>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#111111" width="100%">
<tr>
<td width="34%" bgcolor="#FF9900" height="21">
<p style="margin-left: 10"><b><font size="2" face="Verdana" color="#FFFFFF">
ID</font></b></td>
<td width="33%" bgcolor="#FF9900" height="21">
<p style="margin-left: 10"><b><font face="Verdana" size="2" color="#FFFFFF">
Type</font></b></td>
<td width="33%" bgcolor="#FF9900" height="21">
<p style="margin-left: 10"><b><font face="Verdana" size="2" color="#FFFFFF">
Download</font></b></td>
</tr>
<?php
while($row = mysql_fetch_array($result))
{
?>
<tr>
<td width="34%" bgcolor="#FFDCA8" height="21">
<p style="margin-left: 10; margin-right: 10">
<font face="Verdana" size="1">
<?php echo $row["id"]; ?>
</font>
</td>
<td width="33%" bgcolor="#FFDCA8" height="21">
<p style="margin-left: 10">
<font face="Verdana" size="1">
<?php echo 'image/jpg'; ?>
</font>
</td>
<td width="33%" bgcolor="#FFDCA8" height="21">
<p style="margin-left: 10"><font face="Verdana" size="1">
<a href="downloadfile.php?id=<?php echo $row["id"]; ?>">
Download
</a></font>
</td>
</tr>
<?php
}
echo "</table>";
?>
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
44
45
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
44
45
<?php
global $id;
$id = $row["id"];
if(is_numeric($id))
die("Geen geldig ID");
include ('config.php');
$query = ('SELECT image FROM pink_covers WHERE id = "'.$id.'"');
$result = mysql_query($query) or die("Kan file lijst niet opvragen");
if(mysql_num_rows($result) == 1)
{
$fileContent = @mysql_result($result, 0, "image");
header("Content-type: Image/jpg");
echo $fileContent;
}
else
{
echo "Record bestaat niet.";
}
?>
global $id;
$id = $row["id"];
if(is_numeric($id))
die("Geen geldig ID");
include ('config.php');
$query = ('SELECT image FROM pink_covers WHERE id = "'.$id.'"');
$result = mysql_query($query) or die("Kan file lijst niet opvragen");
if(mysql_num_rows($result) == 1)
{
$fileContent = @mysql_result($result, 0, "image");
header("Content-type: Image/jpg");
echo $fileContent;
}
else
{
echo "Record bestaat niet.";
}
?>
Het lukt niet echt hebben jullie nog suggesties?
* Dit is trouwens een tijdelijke oplossing nadat ik de images heb opgehaald
wil ik dit voortaan lokaal opslaan
Gewijzigd op 28/10/2010 14:45:29 door Koen -
Wat lukt er niet? Krijg je een foutmelding?
Gewijzigd op 28/10/2010 14:44:15 door Koen -
Boven je script en kijk voor foutmeldingen.
en de normale php error?
Gewijzigd op 28/10/2010 14:48:59 door Koen -
mysql_fetch_array($result)) maar er is assoc van ipv van array
hier komt het door:
Quote:
if(is_numeric($id))
moet zijn:
Quote:
if(!is_numeric($id))
Ik heb waarschijnlijk te snel getypt toch bedankt voor alles :)