Jump to content

[SOLVED] PHP Image, linking to database troubles.


Kairu

Recommended Posts

Alright... Just spent a few hours trying to figure this out.... Have a headache and decided perhaps someone with a clear mind could look through the code to see if it makes sense.... After all, two heads are better then one.

This is the code in its entirety (Changed the pass and user name of course):

[code]<?php

header('content-type: image/jpeg');

mysql_connect('localhost:3306', 'User', 'Pass');

mysql_select_db('gaia_image');

$result = mysql_query('SELECT * FROM data WHERE id = ' . $_GET['id']);

$row = mysql_fetch_array($result);

$sig = $row[1];
$n = 1;
$avi = array(); $avi_width = array(); $avi_height = array(); $dest_x = array(); $dest_y =

array(); $a = array();

for ($i=2; $i<=($n * 3) + 3; $i+3)
{
array_push($a, $row[$i]);
}

for ($i=0; $i<=$n-1; $i++)
{
array_push($avi, imagecreatefrompng($a[$i]));
array_push($avi_width, imagesx($avi[$i]));
array_push($avi_height, imagesy($avi[$i]));
}

$image = imagecreatetruecolor($avi_width, $avi_height);

if (strpos($sig, '.jpg') !== FALSE) {
$image = imagecreatefromjpeg($sig);
}
elseif (strpos($sig, '.png') !== FALSE) {
$image = imagecreatefrompng($sig);
}
elseif (strpos($sig, '.gif') !== FALSE) {
$image = imagecreatefromgif($sig);
}
elseif (strpos($sig, '.bmp') !== FALSE) {
$image = imagecreatefromwbmp($sig);
}
else {
$image = imagecreatefromstring($sig);
}

$size = getimagesize($sig);

for ($i=4; $i<=($n * 3) + 3; $i+3)
{
$temp = "\$temp = " . $row[$i] . ";";
eval($temp);
array_push($dest_x , $temp );
$temp = "\$temp = " . $row[$i + 1] . ";";
eval($temp);
array_push($dest_y , $temp );
}
for ($i=0; $i<=$n-1; $i++)
{
imagecopy($image, $avi[$i], $dest_x[$i] , $dest_y[$i], 0, 0, $avi_width[$i], $avi_height[$i]);

imagedestroy($avi[$i]);
}

imagejpeg($image);
imagedestroy($image);

?>[/code]

I only have one row in the table at the moment, I'm trying to get it to work before I add more.

I am providing a [url=http://thedarkrealm.no-ip.org/data.csv]link[/url] to a CSV with the table export. I believe it can be viewed in Excel. (If it does not work the first time, try again. My service is being a bit buggy.

[i]Any[/i] help would be appreciated.

~Kairu~

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.