LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-18-2005, 10:34 PM   #1
Dave Kelly
Member
 
Registered: Aug 2004
Location: Todd Mission Texas
Distribution: Linspire
Posts: 215

Rep: Reputation: 31
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.
 
Old 09-18-2005, 10:44 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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 ;-)!

Last edited by paulsm4; 09-18-2005 at 10:53 PM.
 
Old 09-18-2005, 10:47 PM   #3
caged
Member
 
Registered: Jan 2004
Location: new zealand
Distribution: Mandrake,Slackware
Posts: 165

Rep: Reputation: 30
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.

Last edited by caged; 09-18-2005 at 10:50 PM.
 
Old 09-19-2005, 12:27 AM   #4
Dave Kelly
Member
 
Registered: Aug 2004
Location: Todd Mission Texas
Distribution: Linspire
Posts: 215

Original Poster
Rep: Reputation: 31
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
 
Old 09-19-2005, 12:34 AM   #5
Dave Kelly
Member
 
Registered: Aug 2004
Location: Todd Mission Texas
Distribution: Linspire
Posts: 215

Original Poster
Rep: Reputation: 31
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
 
Old 09-19-2005, 01:28 AM   #6
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing out http request in php abrb220 Programming 1 11-19-2005 02:23 AM
apache http://localhost/mysite ---> http://localhost/mysite/index.php how? ilnli Linux - General 8 06-04-2005 03:23 PM
Logwatch http response code(s) 200 php4u Linux - Security 2 01-26-2005 08:41 AM
Accessing http header in PHP artois_val Programming 1 08-07-2004 10:20 AM
HTTP AUTHENTICATION with PHP lemotion Programming 1 04-22-2004 02:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration