Web Analytics Made Easy -
StatCounter Help with PHP Image & Random Symbols. - CodingForum

Announcement

Collapse
No announcement yet.

Help with PHP Image & Random Symbols.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with PHP Image & Random Symbols.

    Well, I'm fairly new to PHP and trying to build a little personal Image that would display my latest twitter, so that I can put it in my forum signatures and such, and maybe when I'm done with it, I can make it into a generator ( It would be simple )

    I have just about everything done, but the actual image. I get a whole bunch of symbols, and It's only when I include my page that pulls the information for the 1 status message.

    Here's the source to one of many ways I tried this,

    PHP Code:
    <?php
    include("includes.php");
    header("Content-Type: image/png");
    $im imagecreatefrompng("http://i13.photobucket.com/albums/a287/Rickmasta185/149d6e5d2da9f136898079693.png");



    if (
    $im)
    {
    ImageString($im,  1,  17,  4,  $final,  2);


    ImagePNG($im);
    }
    ?>
    That's only one of the ways I've tried to organize it. (Don't worry about the picture, it was a random box I found)


    And here's the code to the includes.php
    PHP Code:
    <?php    
    require_once( './my_twitter.php' );



    $twitter =  new MyTwitter('TwitterUser''TwitterPass');

    $status $twitter->userTimeLine();

    $total count(1);


        
    for ( 
    $i=0$i $total $i++ )
            { 
            
            
            
    $final $status[$i]['text'];
            
            }
            
    ?>
    I know that the TwitterUser and Pass has to be changed, I just changed it here, but can anyone else me?
    I've been trying to figure this thing out for hours, and nothing.

    It'll be greatly appreciated.
    Thanks in Advance
    ~Rick

  • #2
    The output your referring to is the image in raw text format. If for instance you changed the line to
    PHP Code:
    ImagePNG($im'myimage.png'); 
    and put a file in your folder called myimage.png and chmod that to 777. And took out the line
    PHP Code:
    header("Content-Type: image/png"); 
    Then it would store it as a png image to the file myimage.png. However i guess you want the php file to display the image. Which i am still working on
    You can not say you know how to do something, until you can teach it to someone else.

    Comment


    • #3
      Anyway i have had a play and i got this script working. I signed up to twitter especially to help and downloaded the mytwitter class. And your code works. The code i used is identical. Look for yourself.

      http://cybadev.co.uk/timmy.php

      I can include that in an img tag in html like so

      Code:
      <img src="http://cybadev.co.uk/timmy.php" alt="" />
      The only thing that might be wrong is you have got error reporting turned off on your server and the headers are already being sent. This is a problem i had and it was because the twitter class i downloaded had a few whitspaces after the PHP closing tag ?> I removed the whitespaces which meant the headers wern't already being sent so i didnt get that warning anymore and then the line

      PHP Code:
      header('Content-type: image/png'); 
      worked.

      Well im 100% sure that the code above is not working for you since its displaying the image in raw text format and can only imagine your not receiving a warning about this because error reporting is turned off on your server. I suggest going through your files my_twitter.php and includes.php and making sure there are no white spaces before or after the <?php and ?>

      To test if error reporting is turned off just type some goobledygook in a file run it and see if it returns and error something like this

      PHP Code:
      <?php
      $timmy
      423862y3r 7qtsd6rtq0e12lad'sd'ad;'adkosajd8q;
      ?>
      If this gives a blank then you know error reporting is turned off. If it says
      Parse error: syntax error, unexpected T_STRING in .......
      then error reporting is turned on and i don't know whats stopping your header function working :/
      Last edited by timgolding; Apr 4, 2009, 08:42 PM.
      You can not say you know how to do something, until you can teach it to someone else.

      Comment

      Working...
      X