Nov 22, 2009

Php: Write Random Text As Image - Having problems, help needed!

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

Php: Write Random Text As Image - Having problems, help needed!

Rejected
I'm trying to create a script that writes text to an image.
CODE
header("Content-type: image/png");
$_phrases = array(
[tab][/tab]"Test 1",
[tab][/tab]"Test 2",
[tab][/tab]"Test 3",
[tab][/tab]"Test 4",
[tab][/tab]"etc."
);
$_rand_phrase = $_phrases[rand(0,count($_phrases)-1)];
$_image = imagecreatefrompng("gmail.png");
$_user_width = imaagettfbbox(9,0,"tahoma.ttf",$_rand_phrase);
$_x_value = (200-($user_width[2] + 113));
$_color = imagecolorallocate($_image, 165, 164, 164);
imagettftext($_image, 9, 0, $_x_value, 16, $_color, "tahoma.ttf", $_rand_phrase);
imagepng($_image);
imagedestroy($_image);

I can't see what I'm doing wrong.. I know it should work, I'm making a dumb mistake of some sort.

Can anyone help?

 

 

 


Comment/Reply (w/o sign-up)

szupie
You spelled imagettfbbox with an extra a (imaagettfbbox).

And why do you have all your variables start with underscores? You need them only when you want numbers at the beginning of a varible, like $_42lasljwoie. Are you trying to make the variables starting with numbers to look the same as variables starting with letters?
The underscores don't cause a problem, but I'm just curious.

Comment/Reply (w/o sign-up)

Hercco
QUOTE (Rejected @ Jul 16 2005, 08:50 AM)
I'm making a dumb mistake of some sort.
*


The worst ones to debug.


QUOTE (szupie @ Jul 17 2005, 04:53 AM)
And why do you have all your variables start with underscores?
*


It's a coding convention, I've seen that in few other places too. I don't quite get the point, but that's not the first time...

Comment/Reply (w/o sign-up)

jvizueta
I've seen that coding convention before but only for private methods, and for predefined global variables like $_GET, $_POST, $_SERVER, $_REQUEST, and so on wink.gif

I didn't know it was used for userdefined variables too blink.gif

that's new for me unsure.gif

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : php, write, random, text, image, problems, needed

  1. Php Random Selector
    whats the code (2)
  2. Dynamic Php Image And Better Php Code Question
    (10)
    Im working on a dynamic image, can i put 2 images in same dynamic image, and can i make this code
    shorter? if ( $goal == 31 ) { $xp2 = ('14833'); } elseif ( $goal == 32 ) { $xp2 =
    ('16456'); } elseif ( $goal == 33 ) { $xp2 = ('18247'); } elseif ( $goal == 34 ) {
    $xp2 = ('20224'); } elseif ( $goal == 35 ) { $xp2 = ('22406'); } elseif ( $goal ==
    36 ) { $xp2 = ('24815'); } elseif ( $goal == 37 ) { $xp2 = ('27473'); } elseif (
    $goal == 38 ) { $xp2 = ('30408'); } elseif ( $goal == 39 ) { $xp2 = ('33648')....
  3. Dynamic Gd Image
    (2)
    I dont know if someone already made a topic like this, however it's not hard to understand if
    you can php, as many know we need to start a php script with CODE and end with CODE ?>
    to make a image you need a image type, I choos .png because its much cleaner then .jpg CODE
    header("Content-type: image/png"); for the background for the image we need this code CODE
    $image = imagecreatefrompng("http://www.imagefilez.com/out.php/i252132_Userbar.png"); if we wont
    a text in the image we need a font color, we get our font color from HEX values ....
  4. Random With Functions?
    (4)
    Hey! Is it possible to use a random script on functions. Lets say I have created three functions
    (Items that a user will win if he defeates a monster). One function is a function named shield()
    and another function is named sword() and a third function is named helmet(). Now when a player
    defeates a monster, he must be awarded. So.. How can I randomize what item he should get? something
    like CODE rand(sheild(), sword(), helmet()); or? Thanks //Feelay....
  5. Image Popup On Mouseover
    (23)
    I need a script that does this: Lets say I have form with options...you surely know what that is...
    CODE Who do you wanna race?           Derbi Senda 50      Honda NS 50 R      Suzuki ZR
    50      Yamaha DT 50 MX      Aprilia RS 50      - ?         When i put my mouse over
    one of them i want a picture of bike on which your mouse is on to pop up... I hope you understand
    what i mean...i can't rephrase it to be more meaningful...i tried /wink.gif"
    style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" />....
  6. Need Help With Background Image...
    (12)
    I want to add background image to all sites on my website but some include "foot.php" and "head.php"
    and some "footer.php" and "header.php" but all include "config.php" but i dont know in which should
    i put it....any help??....
  7. How To Disable The Enter Key Of An Input Text Box
    (7)
    Hi everybody, i don't know if this is the correct place to post this topic so in case it is not
    please mods move it to the correct place, thanks. I have a page with a FORM that contains one or
    more INPUT TEXT boxes, a standard SELECT box, a standard SUBMIT button, a standard BUTTON button,
    and some hidden TEXT boxes, that will be used to Edit or to Add a record from a MySql database as
    usual, in Edit mode this form will get all the information from the database and in Add mode simply
    will fill it with default values, this page will be opened with the window.open() j....
  8. Five Common Php Database Problems
    (0)
    I just read this excelent article from the IBM's developerWorks website, it's name is Five
    common PHP database problems . This article shows five database problems that occur in PHP
    applications as well as their solutions and include database schema design, database access, and the
    business logic code that uses the database. It is a bit older -a year ago more or less- but i
    think that can be helpful for everybody that works with PHP and MySql. Best regards,....
  9. I'm Having Problems With Sessions
    (2)
    I haven't really read much about sessions, i usually study PHP by viewing other's codes and
    learning from it. Here's what keeps on popping out when I open the page. CODE Warning:
    session_start() : Cannot send session cookie - headers already sent by (output started at
    C:\Program Files\xampp\htdocs\maple-radio-live\loggingin.php:7) in C:\Program
    Files\xampp\htdocs\maple-radio-live\loggingin.php on line 40 and CODE Warning: Cannot
    modify header information - headers already sent by (output started at C:\Program
    Files\xampp\htdocs\maple-radio-live....
  10. Htaccess/gd Problems.
    (0)
    On this shell, that has shared apache, php and gd, I have this file working.
    http://users.phoenix-network.org/~tobylane/gd.php But, with the normal htaccess of CODE
    RewriteEngine on RewriteRule ^sig.png$ gd.php http://users.phoenix-network.org/~tobylane/sig.png
    Doesn't work. Also, another gd picture doesn't display the text. CODE
    header("(anti-spam-(anti-spam-(anti-spam-content-type:))) image/png"); $im =
    imagecreatefrompng("button.png"); $bg = imagecolorallocate($im,255,55,25); imagefill($im,0,0,$bg);
    imagestring($im,3,20,5,"Your IP is ",$b....
  11. Making My Album
    problems with rights (3)
    We have to make something in PHP for school, so I decided to make a complete photoalbum. One of the
    things that it can is creating and storing thumbnails, but here is where the problems start. The
    thumbnails have to be stored in a subfolder called 'thumbnails', if this folder doesn't
    exist, my script creates this folder and everything works like it is supposed to be. But it
    doesn't do that the way I want. The folder is made with: CODE mkdir($thumbnail_folder,
    0777); but when I check it via FTP, it is set to 755. Even worse is that I can't acce....
  12. Random Name Generator
    For a fantasy RPG forum (2)
    Well, I did this particular piece of coding a few days back, and I forgot to display it to you all
    here at AstaHost. I have just started a fantasy RPG forum. The naming rules are pretty strict
    because it has to be based on a construted langage called Pasen. No matter how much I explained, I
    thought, it would be hard for a newbie to understand the syllable formation constraints. Hence, I
    wrote a script and put it at my Drupal powered site, that generates random names for the four races
    for both genders. http://www.WiseTome.com/name-generator-for-chaos-and-order I ....
  13. Php :: Image Pixel Per Inch And Conversion
    Please Guide (1)
    Hi Masters I want soemone to let me know (maybe through a good tutorial and/or PHP Sample Code)
    the following : 1 - User will only allowed to upload images with minimum 120 and maximum 300 Pixel
    Per Inches 2 - User will only allowed to upload JPG images, however, if Gif / BMB / PNG / ETC is
    uploaded the script will convert that into jpg. 3 - If the Image's PPI is > 300 it will set
    to 300. Please guide . I know this can'y be done by GD it requires ImageMagick, Pleae help
    !!!!!!! ....
  14. Image Works With Php And Gd
    (3)
    Hi I have a 1 Big map. What i want is that the user will enter the latitude and longitude. the
    script will show that location in the image. I know how to convert Image X,Y Coordinates into
    Latitide and Longitude and vise versa. But there point is that the image is 1000x1000 wide but i
    want to show only the particular region of that latitude / longitude in 300x300 image. means that
    the PHP script will CROP wht Image (1000x1000) to 300x300. That way, the script will be shoing the
    part of an image, not the whole image. please help !!....
  15. Php :: Adding Image Over Image
    (5)
    Hi Masters & Champions. I want some help regarding putting and image over some location (x pixel ,
    y pixel) of an image. Here it is quite important to note that the mage which is Inserted over an
    image must be clickable. Like for example suppose i put T on an image DD then the T must be
    clickable. Please gudie as this is quite important for me . Thanks ....
  16. Script For Viewing A Random Image Needed
    (3)
    While browsing the web, I bumped into a script that I could really use, since it's different
    from everything that I saw. Most scripts that view a random image contain a code that chooses an
    image, and then puts the part into the page itself. However, on the www.greenplastic.com web
    site (dedicated to Radiohead), in the top left corner there is a random image module. If you look at
    the code, here's what is used: CODE Now, how can a PHP script be an image, and what
    kind of script that is? If you do visit that URL , you don't get a normal page, b....
  17. User Authentication Session Handling Problems
    Authorization server variables not staying across pages (14)
    This is quite a bit of problem I am facing, and I cannot point exactly where I am going wrong. I
    have been lurking around here at the Asta Host forums with regard to login and user authentication
    scripts and I have got as far as this: - Starting a session - Registering a session variable -
    Using the variable to check if the user is authenticated or not. - Authenticating the user through
    MySQL database - Logging of the user, by setting the session variable to un-authenticated I have
    been able to achive the following things too that I think is not related to this proble....
  18. Simple PHP News System Problems
    (1)
    For the new version of my website I'm trying to make a very simple newssytem based on php. Each
    newsitem will get it's own html page, something like this: CODE Welkom HERE
    COMES THE TXT All other data will be stored in a file called news.inc CODE $news
    = array(); $news = '110706_jovolka.html'; $news = '110706_lorum.html'; $news =
    '090706_welkom.html'; $title = array(); $title = 'Over JoVolKa'; $title =
    'Lorum Ipsum'; $title = 'Welkom'; $date = array(); $date = '11/....
  19. How Do I Resize An Image On The Fly?
    (8)
    I was wondering how I would go about resizing an image from a databse without saving it to a file.
    CODE include("settings.inc.php"); $get_a=$_GET ; $get_b=$_GET ; $get_width=$_GET ;
    $get_height=$_GET ; $query="SELECT * FROM $get_a WHERE id='$get_b'";
    $result=mysql_query($query); $image=mysql_result($result,0,"coverimg");
    $size=mysql_result($result,0,"imagesize"); $type=mysql_result($result,0,"imagetype");
    header("Content-length: $size"); header("Content-type: $type"); echo $image; ?> Obviously the
    image I want to resize is $image. The page name....
  20. Problem With PHP Scripts Without MySQL
    i have problems with scripts (1)
    I've been working on my site, and the first time i tried my hand witha php guestbook script, i
    did good, it worked on my host. but although i successfully installed an "send email" php script,
    but somehow although on the site when i tired out the form, though it says email has been sent,
    i've not received any email at all!!! and i've checked the account that was to specified
    for the email to be sent , i have entered everything right. This are the steps the manual asked me
    to do, QUOTE 1) Open up config.php with a word editor such as notepad. Fill ....
  21. Some Problems Sometimes On Other Sites!
    Others come up with wierd problems! (2)
    I am not the most regular contributer to PHP Builder but every now and then there is just a question
    from a newbie or someone that can not be fixed. I do not know if it is that they do not know how to
    ask the question but this one has been going on too long. It seemed from the question that they
    asked that they wanted to insert some data froma text file into the MySQL database. So after looking
    at their query (the original question) QUOTE Here's part of my code: Code: $result =
    mysql_query("INSERT INTO AL_BVA (contact, time, phone, address, city, state, zip, ....
  22. Display Text If Line Not Empty In Config File
    (8)
    I have been working on a new template and I would like it so that if in the global configuration
    file, I have a variable for a global site announcement that would go on every page. The line in the
    global configuration file is this: CODE $announcement = "ANNOUNCEMENT"; In my template file,
    I could easily add CODE but that would leave a blank space and with the announcement style
    (similar to the Invision Power Board error box). Is there some sort of script that could be put in
    the template page so I could have the global config file look something like t....
  23. Uploading Image Via Admin Menu?
    (2)
    There's never much action in here. Here's a question for all you php guys out there.
    Here's what I want. Let's say I create a simple administration menu for someone to
    Add/Edit/Delete a record/item from a database. Now in the add function, let's say I want to
    store a URL to a image. Rather than having to go in and FTP that image up on the server, how could
    a person create a 'Browse' button and find that image on your harddrive, then create a
    script to upload the image to the server? Just wondering how to do it, or if it could be done e....
  24. How Do I Make PHP Based Image Gallery Like This?
    Help Needed (20)
    is it possible to make a page in php, with a url like this:
    httq://www.mysite.com/viewer.php?http://www.mysite.com/galleries/01 (This is a sample link, read
    below) so that in what i change the last part the gallery will change with it? so that i just have
    to make one php-page and this page just shows all the imaes in the map thats in the url after the
    questionmark?? thanks,....
  25. Saving A Php Generated Image To The Server
    Help Needed Please (5)
    I'm trying to create a script that will generate an image and send it back to the browser while
    saving the same image to the server. I'm doing this because the image should be dynamically
    generated but because of the load that would place on a server if the image happened to be requested
    frequently, I've decided to build in a means to serve the static version of the image most of
    the time. What isn't included here is the function that will check the age of the file in cache
    directory and serve the static image if it is less than an hour old. This isn....
  26. Is It Possible To Create A String Image In Chinese
    (0)
    CODE Using imageloadfont $im = imagecreate(50, 20); $black = imagecolorallocate($im, 0, 0, 0);
    $white = imagecolorallocate($im, 255, 255, 255); imagefilledrectangle($im, 0, 0, 49, 19, $white);
    $font = imageloadfont("04b.gdf"); imagestring($im, $font, 0, 0, "Hello", $black); imagepng($im); ?>
      This is an example for illustrating how to create a image including a string with a specific
    font. In the codes, a font named "04b.gdf" is loaded and the string is created according to the
    font. What is the font named gdf? I mean what's the limitation or specificatio....
  27. Problem: Php And Sendmail - Sendmail Times Out
    Problems with PHP and sendmail (2)
    Hi Guys, On other hosting service I have had major problems using the sendmail function (i.e.
    mail()) from php. Basically the script times out waiting for sednmail to return from the function
    call. Anyone else had this problem and is there a solution? Notice from
    m^e: Make your topic titles as descriptive as possible. Topic title to message body
    relevance is counted as a big factor on this board, and is the key to elicitation of good replies
    from other members. ....
  28. Forum Signature-image With Php
    Use PHP to create an image in real-time (8)
    With interest I have read these Topics. What I want to do with PHP is the following:
    Signatue-image This is the Forum Signature of my cousin, who lives in Europe. The image is
    generated in real-time. (Refresh the page, and see for yourself) My cousin refuses to tell me how
    he did this. But I want to do the same thing, also with PHP. Any ideas? Greetings, John.
    Notice from microscopic^earthling: This is NOT a tutorial and in future you
    should be more careful about where you're posting your threads. Moved to Programming > Script....
  29. Php Random Text Generating
    How to Generate Random Text (6)
    I was trying to figure out how to make random texts for random passwords and stuff, and I found
    someone who created this code. QUOTE //author: polmme $codelenght = 10;
    while($newcode_length $x=1; $y=3; $part = rand($x,$y); if($part==1){$a=48;$b=57;}  // Numbers
    if($part==2){$a=65;$b=90;}  // UpperCase if($part==3){$a=97;$b=122;} // LowerCase
    $code_part=chr(rand($a,$b)); $newcode_length = $newcode_length + 1; $newcode = $newcode.$code_part;
    } echo $newcode; ?> I think it's pretty good. If anyone has a better one or suggestions,
    please tell me.....
  30. Random Banners Rotation...
    set by percentages (2)
    alright, I know a few different ways to make a random banner with php - where a different banner
    would rotate with every refresh/click. But I've had some "customers" complain how they think
    their banner should show up more then others for one reason or another, and I completely agree with
    them. So now I kinda want to have a code (most perferably php or javascript) that would have the
    banner rotation where I could set a peticular banner to show up say 15% of the time and another 5%
    so I could satisfy my more loyal members over the ones simply looking for more hits to ....

    1. Looking for php, write, random, text, image, problems, needed

See Also,

*SIMILAR VIDEOS*
Searching Video's for php, write, random, text, image, problems, needed
advertisement



Php: Write Random Text As Image - Having problems, help needed!

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com