LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   php code in http (https://www.linuxquestions.org/questions/programming-9/php-code-in-http-364717/)

Dave Kelly 09-18-2005 10:34 PM

php code in http
 
I would like to put some php code in a http file and save it to my earthlink storage area.

I have no background in php coding and not a clue how it should look in the http file. I have done this looking as to css files and seeing other than http code in them. Will what I have work? I apologize for the long post.

Code:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>random tag line generator for phpbb sites</title>
</head>
<body>
<!-- Place php code here -->
<?

header('Content-Type: image/png');                        // its a png file - let the browser know that

HHHHHHHmmmmmmmmmmmmmmm!  Looking here again, I'm not asking if the code will work, only if I impliment it correctly.
So it does not have to be a long post.

imagepng($im2);                                    // write the file as a png

imagedestroy($im2);                                // no longer need the image

?>
<!-- end php code -->
</body>

Is their a better to way to call php code from the signature box?

Thanks.

paulsm4 09-18-2005 10:44 PM

1. My preference for PHP tags is:

<?php
..
?>

That's the current "standard", that's a convention that doesn't conflict with XML ("<? .. ?>" does).

2. Supposing you added PHP to your Earthlink page. Does your Earthlink account permit PHP? Probably not.

3. If it did (and most ISPs *will* let you do PHP, at least in specific directories: shop around if Earthlink doesn't), then you still probably need to suffix your file ".php" before it'll work.

4. There are *lots* of great PHP tutorials on the web.

(Please don't laugh), but my favorite introductory text for PHP is:

"Teach yourself PHP, mySQL and Apache in 24 Hours", Julie C. Meloni

I don't generally advocate SAMS books, and "teach yourself ANYTHING in 24 hours" is a ridiculous concept: but Ms. Meloni did a great job, and covers all the essentials you need to quickly get started.

Another great book is:

"PHP and MySQL Web Development", Luke Welling & Laura Thomson.

'Hope that helps .. PSM

PS:
Your post was fine and, as far as I could tel, your PHP code looked fine.
Heck - you even used the LQ "code" tags correctly - that's WAY more than most posters do ;-)!

caged 09-18-2005 10:47 PM

Hi.

Im not too sure what your asking but your code seems fine.
I place my php code is placed inside the <? ... ?> brackets. but the above persons recommendation to use <?php ... ?> makes a lot of sense.
I'm not familar with the header(), imagepng() or imagedestroy() functions but if they exist the code shouldnt have any problems...... as long as the server is configured to process php code. (php is server side)

hope that helps ?
cheers,
Ben.

Dave Kelly 09-19-2005 12:27 AM

Quote:


PS:
Your post was fine and, as far as I could tel, your PHP code looked fine.
Heck - you even used the LQ "code" tags correctly - that's WAY more than most posters do ;-)!

Thank you for the compliment. Kind words always make me feel good.

Quote:

Originally posted by paulsm4

2. Supposing you added PHP to your Earthlink page. Does your Earthlink account permit PHP? Probably not.

3. If it did (and most ISPs *will* let you do PHP, at least in specific directories: shop around if Earthlink doesn't), then you still probably need to suffix your file ".php" before it'll work.
I had not considered that, I must check. Thanks for bringing it up.

Quote:

I don't generally advocate SAMS books, and "teach yourself ANYTHING in 24 hours" is a ridiculous concept: but Ms. Meloni did a great job, and covers all the essentials you need to quickly get started.
I tend to agree with you. All the 24 hour and dummy books I have bought wound up been sent to the outhouse for usage if the paper wasn't too slick.

You seem to have read my mind. I was going to ask about toturals. I will get my hands on your recommendations and search for what else is available. I have alway thought that if I had/knew what to read I could answer my own questions quicker that I could wait for an answer.

Again, Thanks
Dave

Dave Kelly 09-19-2005 12:34 AM

Quote:

Originally posted by caged
Hi.

Im not too sure what your asking but your code seems fine.
I place my php code is placed inside the <? ... ?> brackets. but the above persons recommendation to use <?php ... ?> makes a lot of sense.
I'm not familar with the header(), imagepng() or imagedestroy() functions but if they exist the code shouldnt have any problems...... as long as the server is configured to process php code. (php is server side)

I'm not too sure what I was asking either. Both of you answered what I think I wanted to know. Had I implimented my code correctly. I haven't got a clue about those function calls. I thought for a while they were from the imagemagick suite but have decided they aren't.

Again Thanks for responding.
Dave

paulsm4 09-19-2005 01:28 AM

Oh yes - sorry I didn't notice it at first: if you're going to use "header()", it *MUST* come before you output *ANY* other HTML. Including HTML output of any kind from PHP.

Here's a link that explains why:

http://us3.php.net/header

Your .. PSM


All times are GMT -5. The time now is 12:04 PM.