Page 1 of 1

img src

Posted: Sat Aug 05, 2006 12:53 pm
by kesef
Weirdan | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I use the folowing!
[syntax="html"]
<img src="button.php?button=button_down&text=Home&color=red" width="120" height="15" alt="Home" border="0" />
But the text on the button is: button_down
and it should be: Home


Weirdan | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sat Aug 05, 2006 12:55 pm
by Burrito
we would need to see the contents of button.php to help you figure out why that's happening.

content of button.php

Posted: Sat Aug 05, 2006 1:11 pm
by kesef
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Code: Select all

<?php
// GD's built-in fonts are numbered from 1 - 5
$font = 3;
//image size
$image_height = 15;
$image_width = 120;
// Create the image
$image = imagecreatefrompng("button.png");

// Create the colors to use in the image
// blue text
$text_color = imageColorAllocate($image, 0, 0, 255);
// black border
$rect_color = imageColorAllocate($image, 0, 0, 0);
// Figure out where to draw the text
// (Centered horizontally and vertically
$x = ($image_width - (imageFontWidth($font) * strlen($_GET['button']))) / 2;
$y = ($image_height - imageFontHeight($font)) / 2;
// Draw the text
imageString($image, $font, $x, $y, $_GET['button'], $text_color);
// Draw a black border
imageRectangle($image, 0, 0, imageSX($image) - 1, imageSY($image) - 1, $rect_color);
// Send the image to the browser
header('Content-Type: image/png');
imagePNG($image);
imageDestroy($image);
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sat Aug 05, 2006 1:11 pm
by thiscatis
it's best that you use the [syntax=php]content[/syntax] tags.

Posted: Sat Aug 05, 2006 1:29 pm
by onion2k
Why do you think it should be "Home" rather than "button_down"? That script clearly draws the content of the $_GET['button'] variable.

Posted: Sat Aug 05, 2006 1:34 pm
by kesef
onion2k wrote:Why do you think it should be "Home" rather than "button_down"? That script clearly draws the content of the $_GET['button'] variable.
I don't think it should be Home :(
I would like that it is home :D
and now it is:
button_down
button_up
button_over
instead of the color that has to change

Posted: Sat Aug 05, 2006 4:20 pm
by Ollie Saunders
You seriously can't work this out?
Try:

Code: Select all

imageString($image, $font, $x, $y, $_GET['text'], $text_color);
instead of:

Code: Select all

imageString($image, $font, $x, $y, $_GET['button'], $text_color);