好的,所以我没有编码,所以我一直在拼凑代码。无论如何,我正在创建一个网站,将发布的数据从index.php发送到boutique.php。 the boutique.php页面上有imagecreatefrompngimagecreatefrompng:信息被发送但无法正常工作
当你从index.php发送表单数据时,它将从mysql数据库中选择你在索引上选择的选项,发送它,从数据库获取链接并发送链接到boutique.php。
现在我已经得到了它的工作,当我包含页面而没有放入标签时,我回应了boutique.php页面中的图像链接标签,链接url显示出来,所以代码本身正在正确发送。但同时也说明了乱码代码:
ÿØÿàJFIFÿþ> CREATOR:GD-JPEG V1.0(使用IJG JPEG V62),默认画质下YUC
,甚至当我把页面的代码被打破,但图像链接正在发送。
Boutique.php
<?php
header('Content-Type: image/png');
ob_start();
$image_data = ob_get_clean();
session_start();
mysql_connect('localhost', 'user', 'pw')
or die('Could not connect: ' . mysql_error());
mysql_select_db('data') or die('Could not select database');
$GetTanTable = "SELECT * FROM Pants WHERE maincolor='Tan'";
$GetTan = mysql_query($GetTanTable) or die('Query failed: ' . mysql_error());
while ($RowTan = mysql_fetch_array($GetTan, MYSQL_ASSOC))
{
$GetPantsImage = $RowTan['image'];
if(isset($_POST['PTsubmit']) && $RowTan['subcolor'] == $_POST['PTan'])
{
$horizontal = 'right';
$vertical = 'bottom';
$watermark = imagecreatefrompng($GetPantsImage);
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$src = $_GET["src"];
}
}
$image = imagecreatetruecolor(250, 500);
$black = imagecolorallocate($image, 0, 0, 0);
imagecolortransparent($image, $black);
imagealphablending($image, true);
imagesavealpha($image, true);
$horizontal = 'right';
$vertical = 'bottom';
switch ($horizontal) {
default:
$dest_x = $size[0] - 50;
}
switch ($vertical) {
default:
$dest_y = $size[1] - 50;
}
imagecopy($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width,$watermark_height);
imagejpeg($image);
imagedestroy($image);
imagedestroy($watermark);
?>
现在即使代码被正确发送,当我删除所有if,while语句,把一个普通的HTTP://代码在$ GetPantsImage,它的工作原理。所以,我真的不明白
代码工作WHEN:我走,如果/ while语句了,我把实际的URL,它是在datase
当你声明'header('Content-Type')时,你用['imagejpeg()'](http://us3.php.net/manual/en/function.imagejpeg.php) :image/png');'在文件顶部。 您可能正在寻找['imagepng()'](http://us3.php.net/manual/en/function.imagepng.php)。 – esqew
我希望这会解决它,但现在它只是在PNG – user3478701
为乱码代码'$ GetPantsImage'的值$ RowTan ['image']'变量设置后它的值是什么? – esqew