Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 5th, 2006, 3:09 PM   #1
leo1502
Newbie
 
Join Date: Apr 2006
Posts: 16
Rep Power: 0 leo1502 is on a distinguished road
Problem with include

I've installed an apache server on my computer so I can learn and run some php.

I'm trying the following :

<?php

/**
 *
 *
 * @version $Id$
 * @copyright 2006
 */

echo "test one<br>";
include "sample.shtml";
//include ("http://www.google.com/index.html");
?>

and I get:
Warning: Failed opening 'http://www.google.com/index.html' for inclusion (include_path='.;C:/phpdev/php/includes;C:/phpdev/php/class') in c:\phpdev\www\index.php on line 12

It seems it won't include anything from the web.

What could be the problem?

Thanks.
leo1502 is offline   Reply With Quote
Old Aug 5th, 2006, 3:18 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Quote:
What could be the problem?
Your lack of understanding of what "include" does? Might one inquire if you've bothered to refer to the manual? It's an action that comes highly recommended, and particularly in regards to the PHP manual, which is very good.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Aug 5th, 2006, 5:33 PM   #3
mleonid
Newbie
 
Join Date: Aug 2005
Posts: 12
Rep Power: 0 mleonid is on a distinguished road
Friendly as usual I see.
I understand what include does.
The problem is that my php version doesn't support what I'm doing.

Thanks for everything
mleonid is offline   Reply With Quote
Old Aug 5th, 2006, 7:30 PM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Why are you using two user names? Have you read the forum's rules/FAQ? I will say that if you understand what "include" does, and you're trying to include Google's web-resident index page, you aren't paying any attention to yourself. That doesn't bode well for the outside help. Your php version may not support what you're trying to do, but it didn't promise to tie your shoes and cater to your every dream. It, like most other software, recalcitrantly insists that you play by its rules.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Aug 6th, 2006, 2:57 AM   #5
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by DaWei
I will say that if you understand what "include" does, and you're trying to include Google's web-resident index page, you aren't paying any attention to yourself.
DaWei is probably correct in this regard. The PHP manual page says:
Quote:
The include() statement includes and evaluates the specified file.
This means that any <?PHP ?> tags on Google's page will be executed by your server. Now, it's somewhat unlikely that Google would have such tags on their homepage, but you're essentially turning control of your server over to Google, or any other site you choose to include. Any of these sites with malicious intentions could then wipe your harddrive, or download your data, or conceivably anything at all.

Thus, including sites that you do not control is not a very good idea.
Arevos is offline   Reply With Quote
Old Aug 6th, 2006, 5:07 AM   #6
mleonid
Newbie
 
Join Date: Aug 2005
Posts: 12
Rep Power: 0 mleonid is on a distinguished road
I was just trying something. I know including google doesn't look so good.

Thanks guys.
About the 2 users, I logged in from different computers and turns out one of them remembered a user I forgot existed.
mleonid is offline   Reply With Quote
Old Aug 6th, 2006, 6:39 AM   #7
Ade
Hobbyist Programmer
 
Ade's Avatar
 
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0 Ade is an unknown quantity at this point
Is this include() function a potential security risk? I mean I've had php errors before that have displayed something such as my database password, could someone include a php file and potentially see any of the information between <?php .... ?>s ?
__________________
Don't wound what you can't kill
Ade is offline   Reply With Quote
Old Aug 6th, 2006, 11:18 AM   #8
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3 Jimbo is on a distinguished road
I don't think it would be a risk, as they would be including your file (most likely) through HTTP, so you server would evaluate whatever the PHP was, and send the result (e.g. the HTML) and their page would then just be including the HTML. I'm pretty sure that's how it would go... :o
Jimbo is offline   Reply With Quote
Old Aug 10th, 2006, 1:20 PM   #9
Xeoncross
Newbie
 
Xeoncross's Avatar
 
Join Date: Aug 2006
Posts: 11
Rep Power: 0 Xeoncross is on a distinguished road
Lightbulb About PHP's Include...

Jimbo is right, PHP will process all external PHP files (meaning OUT SIDE of your server) and THEN give the result to the file that is including them. So there is NO risk in including google or anyone else’s page. (at lest in the PHP code that is :p)

If you want to learn more about PHP's include function I wrote a lesson on it at:
learnphpfree.com - PHP Include
Xeoncross is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
having problem with data not saving to a file codylee270 C++ 5 Apr 13th, 2006 7:39 PM
Dev-C++ - #include .cpp/.h files Cache C++ 5 Nov 25th, 2005 11:34 AM
Help! I have a problem thomas55 C++ 1 Apr 24th, 2005 1:16 PM
Problem with #include <linux/sched.h> linusoft C++ 1 Mar 28th, 2005 3:13 AM
string problem when passing in linked list quantz C++ 0 Feb 27th, 2005 10:11 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:30 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC