Jump to content

n00bing around


DeathStar

Recommended Posts

Hi there.

I REALY feel like a n00b right now :(

but my question is: How do i create a new line with an gd(php) image?

 

here is my script:

<?php
// create a 100*30 image
$im = imagecreate(195, 15);

// white background and blue text
$bg = imagecolorallocate($im, 0, 0, 0);
$textcolor = imagecolorallocate($im, 255, 0, 0);
$text = $info['name'];
$text .= $info['level'];

// write the string at the top left
imagestring($im, 5, 0, 0, $text, $textcolor);

// output the image
header("Content-type: image/png");
imagepng($im);
?> 

Link to comment
Share on other sites

<?php
include "db\connect.php";
include "func.php";

/*
in func.php:
$r = mysql_query("SELECT * FROM `users` WHERE `id`=$id");
$ir= mysql_fetch_array($r);
*/

// create a 100*30 image
$im = imagecreate(700, 20);

// white background and blue text
$bg = imagecolorallocate($im, 0, 0, 0);
$textcolor = imagecolorallocate($im, 255, 0, 0);
$text = "Name: ";
$text .= $ir['name']."\n";
$text .= "Level: ";
$text .= $ir['name'];

// write the string at the top left
imagestring($im, 5, 0, 0, $text, $textcolor);

// output the image
header("Content-type: image/png");
imagepng($im);
?> 

Link to comment
Share on other sites

what about

 

<?php
$im = imagecreate(700, 30);

// white background and blue text
$bg = imagecolorallocate($im, 0, 0, 0);
$textcolor = imagecolorallocate($im, 255, 0, 0);
$text = "Name: ";
$text .= $ir['name'];
imagestring($im, 5, 0, 0, $text, $textcolor);
$text = "Level: ";
$text .= $ir['name'];

// write the string at the top left
imagestring($im, 5, 0, 12, $text, $textcolor);

?>

Link to comment
Share on other sites

erm.. did on my server please note the 12

<?php
$im = imagecreate(700, 30);

// white background and blue text
$bg = imagecolorallocate($im, 0, 0, 0);
$textcolor = imagecolorallocate($im, 255, 0, 0);
$text = "Name: ";
$text .= $ir['name'];
imagestring($im, 5, 0, 0, $text, $textcolor);
$text = "Level: ";
$text .= $ir['name'];

// write the string at the top left
imagestring($im, 5, 0, 12, $text, $textcolor);  //<------12 not 0

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.