Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 read values from url www.l.com/3@4.png
Index -> Programming, PHP -> PHP Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
abcdefghijklmnopqrstuvwxy




PostPosted: Wed Mar 21, 2007 9:15 pm   Post subject: read values from url www.l.com/3@4.png

How do i use the values 3 and 4 in php code from nothing but that url?
Sponsor
Sponsor
Sponsor
sponsor
octopi




PostPosted: Wed Mar 21, 2007 9:38 pm   Post subject: Re: read values from url www.l.com/3@4.png

the correct format for doing things like this it


www.host.com/path/to/file.php?var=value&var2=value2

now, in php you can do the following:
$var = $_REQUEST['var'];
$var2 = $_REQUEST['var2'];
print $var;
//out puts value;


print $var2;
//outputs value2


alternatively if your trying to do something custom (and stupid), you can access the HTTP_SERVER_VARS array, if you aren't doing the standard things, and develop your anwser from values in there.
abcdefghijklmnopqrstuvwxy




PostPosted: Wed Mar 21, 2007 10:01 pm   Post subject: RE:read values from url www.l.com/3@4.png

Cool... What i'm trying to do is make a signature image that will display in forums.

If I made the img link to say www.myhost.com/signature.png?var=value&var2=value2 will that work as expected?

EDIT:

not just a signature image but a php script that pretends to be a png image.
rdrake




PostPosted: Wed Mar 21, 2007 10:11 pm   Post subject: RE:read values from url www.l.com/3@4.png

Make sure your web server is set up to process the PNG files as PHP scripts first. As for whether or not it'd work, I doubt it. If the forum is using phpBB then it probably will work, other forums actually require you to have images in an image tag.

You would be better off just using a regular script with the PHP ending. Many images are in the PNG format and it would be impractical for you to use that as a PHP alias, as normal images would also be processed as scripts.
abcdefghijklmnopqrstuvwxy




PostPosted: Wed Mar 21, 2007 10:38 pm   Post subject: RE:read values from url www.l.com/3@4.png

unless you only had one folder that the server processed .png files as php scripts... in which case it is fine... and i've seen this done in multiple types of forums using the image tag...

Maybe it is for that reason that it has to end in .png and which is also why it is custom (and stupid) to use the forum www.myhost.com/sigs/4@2@3.png. But I don't understand how I can title the php script that actually resides in the .png script to work with that syntax. As in, what is www.myhost.com/sigs4@2.png actually called...
abcdefghijklmnopqrstuvwxy




PostPosted: Wed Mar 21, 2007 11:05 pm   Post subject: RE:read values from url www.l.com/3@4.png

No matter what I do this script keeps giving me "this file can't be displayed because there is an error in it" every time i try to view it.


code:

<?php
        header("Content-type: image/png");
     
        $player_name = $_REQUEST['player'];
    $laddertype = $_REQUEST['ladder'];
        $game = $_REQUEST['game'];
?>


That's not the whole thing, but the bug resides in that code. I'm guessing there is no such thing as a $_REQUEST array if you don't embed the php in html?
abcdefghijklmnopqrstuvwxy




PostPosted: Wed Mar 21, 2007 11:09 pm   Post subject: RE:read values from url www.l.com/3@4.png

I know trying to understand me must be hell so just take a look at my signature.. that is what i'm trying to do. I think it has to end in .png but I don't know how to extract that values, nor do i know what to actually name the fake .png file (that is actually a php script)


EDIT: Disregard my last post... _REQUEST does exist i just tested it.
octopi




PostPosted: Wed Mar 21, 2007 11:17 pm   Post subject: Re: read values from url www.l.com/3@4.png

You probally want to do something like this


make a file named something like show_image.php

now you'll have a variable named like image_file
$image_file = $_REQUEST['image_file'];

now when you goto
show_image.php?image_file=flower.png

the filename 'flower.png' will be in the variable $image_file,
so now you want to output it to the browser.
The reason your getting errors is probally because you don't output anything to the browser.

code:

<?php
header("Content-type: image/png");
$image_file=$_REQUEST['image_file'];
readfile($image_file);

?>


that should work, provided the file exists, also note that it is not advisable to just grab and retreive files off your server....can potentially used to steal your data. (access any file on your server)
Sponsor
Sponsor
Sponsor
sponsor
octopi




PostPosted: Wed Mar 21, 2007 11:21 pm   Post subject: Re: read values from url www.l.com/3@4.png

I looked at your signature, it looks like you want to overlay text onto the image, you'll need to look up the GD image functions, they provide means to place text on images.

http://ca3.php.net/manual/en/function.imagettftext.php

also look at the stuff on the left. (other functions you can use)
abcdefghijklmnopqrstuvwxy




PostPosted: Wed Mar 21, 2007 11:37 pm   Post subject: RE:read values from url www.l.com/3@4.png

Thanks, yeah I already know how to overlay text onto the sig with GD I just don't know how to pass in values to aid in the text i'm overlaying onto the image Very Happy
abcdefghijklmnopqrstuvwxy




PostPosted: Thu Mar 22, 2007 2:33 am   Post subject: RE:read values from url www.l.com/3@4.png

Alright, I've done a lot of fiddling nothing you've suggested works for the forums.

It seems the ? in the query is parsed by the forum and then not displayed.

It has to end in .png and include no "?"s.

If you click my signature and choose view image you will see how skwizz.com managed to accomplish this.

IF ANYONE HAS ANY IDEA HOW TO ACCOMPLISH WHAT SKWIZZ HAS I'D MARRY YOU OR THANK YOU FOREVER!

I've spent hours trying to figure it out...
md




PostPosted: Thu Mar 22, 2007 7:26 am   Post subject: RE:read values from url www.l.com/3@4.png

the URL requested is in one of the $_SERVER vars iirc. you can always take and parse that.
octopi




PostPosted: Thu Mar 22, 2007 8:21 am   Post subject: Re: read values from url www.l.com/3@4.png

You need to use mod_rewrite to convert that wild url you want to use, into one your web server will understand.
Thats about all I can say.

http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

Theres stuff on the internet, but your gonna have to find/figure this one out yourself.
Amailer




PostPosted: Thu Mar 22, 2007 1:04 pm   Post subject: RE:read values from url www.l.com/3@4.png

I think you have to marry Octopi now Razz
And thank lol

Thats the way I would have done it, thats the only way I know how to do it :/ (unless, you check the acess logs hmmm)
abcdefghijklmnopqrstuvwxy




PostPosted: Thu Mar 22, 2007 3:28 pm   Post subject: RE:read values from url www.l.com/3@4.png

Thanks octopi i guess i'll look into it. After searching on the net endlessly and turning up nothing, I got a bright idea which works and is fairly simple.

Basically I added a directive to send any 404s to a php script. That php script parses it and if it meets the criteria it'll display the signature.

In essence it allows me to have: www.host.com/name@45@32@87.png and actually have an image display.

Since I figured out a way first I don't have to marry anyone, however!
Display posts from previous:   
   Index -> Programming, PHP -> PHP Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 23 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: