Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-04-2009, 07:38 AM   PM User | #1
Rickmasta
New to the CF scene

 
Join Date: Apr 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Rickmasta is an unknown quantity at this point
Angry 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
Rickmasta is offline   Reply With Quote
Old 04-05-2009, 01:19 AM   PM User | #2
timgolding
Senior Coder

 
timgolding's Avatar
 
Join Date: Aug 2006
Location: Southampton
Posts: 1,460
Thanks: 89
Thanked 110 Times in 109 Posts
timgolding is on a distinguished road
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.
timgolding is offline   Reply With Quote
Old 04-05-2009, 01:40 AM   PM User | #3
timgolding
Senior Coder

 
timgolding's Avatar
 
Join Date: Aug 2006
Location: Southampton
Posts: 1,460
Thanks: 89
Thanked 110 Times in 109 Posts
timgolding is on a distinguished road
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
Quote:
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 :/
__________________
You can not say you know how to do something, until you can teach it to someone else.

Last edited by timgolding; 04-05-2009 at 01:42 AM..
timgolding is offline   Reply With Quote
Reply

Bookmarks

Tags
image, php, symbols, twitter

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:20 AM.


Advertisement
Log in to turn off these ads.