Quick question about displaying...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

unsuaulvb
Forum Newbie
Posts: 11
Joined: Sat Nov 26, 2005 11:18 am

Quick question about displaying...

Post by unsuaulvb »

i need some php help i need to display an iframe ontop of a image

using

Code: Select all

ImageString($im, 0, 0, 0, "", $black);
Here is my code

Code: Select all

<?php
$im = imagecreate(204, 104);
$white = imagecolorallocate($im, 255, 255, 255);
$name =UnusualVB
ImageString($im, 0, 0, 0, "", $white);
////////////////////////////////////
Header('Content-type: image/png');
imagepng($im);
ImageDestroy ($im);
?>
Here is my Iframe
http://mysite.com/$name.card
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

Iframes have nothing to do with PHP. What is it you want to do?

If you want your iframe to have a certain background, just create an appropriate stylesheet in the file it displays.
unsuaulvb
Forum Newbie
Posts: 11
Joined: Sat Nov 26, 2005 11:18 am

Post by unsuaulvb »

i wana display a website as a image
ody
Forum Contributor
Posts: 147
Joined: Sat Mar 27, 2004 4:42 am
Location: ManchesterUK

Post by ody »

unsuaulvb wrote:i wana display a website as a image
yeah and I want the internet in paperback but sometimes we just dont get what we want.
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

unsuaulvb wrote:i wana display a website as a image
And I want to download the internet.
unsuaulvb
Forum Newbie
Posts: 11
Joined: Sat Nov 26, 2005 11:18 am

Post by unsuaulvb »

Its asimple question and if you have to be rude and be sarcastic then i could easily report you to the admin, I have not broken any rules, this forum is for asking questions about php and getting answers. Now if you do not know the answer then do not post.
ody
Forum Contributor
Posts: 147
Joined: Sat Mar 27, 2004 4:42 am
Location: ManchesterUK

Post by ody »

No no you are right, I am sorry, it was just a bit of humour.
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

unsuaulvb wrote:Its asimple question and if you have to be rude and be sarcastic then i could easily report you to the admin, I have not broken any rules, this forum is for asking questions about php and getting answers. Now if you do not know the answer then do not post.
If you would have said anything useful beyond, and I quote, "i wana display a website as a image", then maybe we'd be able to help. In that sentence, and your previous posts, you gave no indication of what exactly you want to do.

Cheers,

Tom
unsuaulvb
Forum Newbie
Posts: 11
Joined: Sat Nov 26, 2005 11:18 am

Post by unsuaulvb »

i need some php help i need to display an iframe ontop of a image using GD
Also i would like to know how to define a variable like this $username using

Code: Select all

http://mysite.com/index.php?username=unusualvb
Here is my code

Code: Select all

<?php
$im = imagecreate(204, 104);
$white = imagecolorallocate($im, 255, 255, 255);
$username =UnusualVB
ImageString($im, 0, 0, 0, "", $white);
////////////////////////////////////
Header('Content-type: image/png');
imagepng($im);
ImageDestroy ($im);
?>
Here is my Iframe
http://mysite.com/$name.card
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Is there any reason you can't just set the background of the iframe content as the image?
ody
Forum Contributor
Posts: 147
Joined: Sat Mar 27, 2004 4:42 am
Location: ManchesterUK

Post by ody »

you need to set the background image of the html page in the iframe to point to your php script that outputs the image.

when you pass a variable in the url it is known as a GET var, you would access it using $_GET['username']
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

unsuaulvb wrote:i need some php help i need to display an iframe ontop of a image using GD
Also i would like to know how to define a variable like this $username [etc. see first post
I was asking you to explain, not restate. We can all go back to the first post, that's not the problem. You need to provide more information. Do yourself a favor and make it easier to help you. It's in your own interest.
ody wrote:you need to set the background image of the html page in the iframe to point to your php script that outputs the image.
I already told him that, but that doesn't seem to be the problem. I am really at a loss here. No clue what unsualvb wants. :?
ody
Forum Contributor
Posts: 147
Joined: Sat Mar 27, 2004 4:42 am
Location: ManchesterUK

Post by ody »

foobar wrote:
unsuaulvb wrote:i need some php help i need to display an iframe ontop of a image using GD
Also i would like to know how to define a variable like this $username [etc. see first post
I was asking you to explain, not restate. We can all go back to the first post, that's not the problem. You need to provide more information. Do yourself a favor and make it easier to help you. It's in your own interest.
ody wrote:you need to set the background image of the html page in the iframe to point to your php script that outputs the image.
I already told him that, but that doesn't seem to be the problem. I am really at a loss here. No clue what unsualvb wants. :?
Either way dewd, getting the internet into paper back, how can we do that with PHP? :wink:
unsuaulvb
Forum Newbie
Posts: 11
Joined: Sat Nov 26, 2005 11:18 am

Post by unsuaulvb »

ok what im making is for xbox live

Code: Select all

<?php
$im = ImageCreate(204, 104);
$bg = imagecolorallocate($im, 0, 0, 0);
$fontcolor = imagecolorallocate($im, 255, 255, 522);
if ( $_GET['username'] == "" ) {
    $gamertag = "No Gamertag";
} else {
   $gamertag = $_GET['username'];
}
////////////////////////////////////
$str = "$gamertag";
$name = str_replace(" ", "%20", $str);
$name = str_replace(".png", "", $name);
$name = str_replace(".jpg", "", $name);
$name = str_replace(".gif", "", $name);
////////////////////////////////////
ImageString  ($im, 0, 0, 0, "<iframe src= http://gamercard.xbox.com/$name.card scrolling=no frameBorder=0 height=140</iframe>", $fontcolor);
////////////////////////////////////
Header('Content-type: image/png');
imagepng($im);
ImageDestroy ($im);

It does not work but this does

Code: Select all

<?php
$im = ImageCreate(204, 104);
$bg = imagecolorallocate($im, 0, 0, 0);
$fontcolor = imagecolorallocate($im, 255, 255, 522);
if ( $_GET['username'] == "" ) {
    $gamertag = "No Gamertag";
} else {
   $gamertag = $_GET['username'];
}
////////////////////////////////////
$str = "$gamertag";
$name = str_replace(" ", "%20", $str);
$name = str_replace(".png", "", $name);
$name = str_replace(".jpg", "", $name);
$name = str_replace(".gif", "", $name);
////////////////////////////////////
echo "<iframe src= http://gamercard.xbox.com/$name.card scrolling=no frameBorder=0 height=140</iframe>"
////////////////////////////////////
?>
But i need the top scipt because it uses GD to make it a image
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

unsuaulvb wrote:

Code: Select all

ImageString  ($im, 0, 0, 0, "<iframe src= http://gamercard.xbox.com/$name.card scrolling=no frameBorder=0 height=140</iframe>", $fontcolor);
^That's where you've got an error.

Your usage of imagestring() is incorrect. What your code will do is print the text "<iframe ... ></iframe>" on your image. I'm not sure what you're trying to achieve. If you want to get the xbox-live image, you could do the following:

Assuming it's a PNG image

Code: Select all

header('Content-Type: image/png');

//Get $name...
//$name = ... ;

$path = "http://gamercard.xbox.com/$name.card";

/* Create a GD image from a PNG file */
$image = @imagecreatefrompng($path);

/* Get image size */
list($width, $height) = getimagesize($path);

//Do whatever you want to with the image...

return $image;
As a side note, your iframe code is wrong, you forgot the > on your opening tag.
Post Reply