[PHP] Re: Include/Require limit?
Julian Wanke wrote: Hi, I use the pretty large Library PHP Image Workshop (http://phpimageworkshop.com/) at my project. It is about 75,5 KB. Everything works fine but if I try to include a 15 KB file with country codes, it fails. With the other files I easily get over 100 KB inclusion size, so my question; Is there a size limitation for include? Best regards Do you get an error message? Try removing the header() in the image output and see what happens. -- Cheers David Robley PARANOID:Paying MORE for Surge-Protectors than Computers -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include() Error
On 5/29/2013 1:39 PM, Ron Piggott wrote: Good morning all: I have recently purchased a computer and am using it as a dedicated server. A friend helped me install PHP and configure. I am saying this because I wonder if using a newer version of PHP (compared to my commercial web host) may be the reasoning behind the error I am receiving. I created a function to generate a form submission key. - This created hidden variable for forms - This is also session variable With this function I have an ‘ include ‘ for the file containing the mySQL database, username and password. I know this file is being accessed because I added: === echo $mySQL_user; === following the login credentials. But when I remove this line from mySQL_user_login.inc.php and place within the function on the line following the include the echo” returns nothing. === include(mySQL_user_login.inc.php); echo $mySQL_user; === Can any of you tell me why this is happening? Ron Piggott www.TheVerseOfTheDay.info #1 - it's not an include error. It's a programmer error #2 - that said - why would you want to do this? The release of usernames/passwords is a dangerous practice - even in development. If all you want to do is verify that you passed thru this bit of code, echo some less sensitive message, such as Connected successfully. Or even better have the connect function return true or false and check the return. #3 - global #4 - global and #5 global. Anytime you want to use a var withing a function include it in a global statement. I always forget too. But I'm getting pretty good at remembering how to resolve it. PS - do you store your .inc file with this sensitive info on your server outside of the web-accessible path? I hope so. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include() Error
You are most probable getting a fatal error, and the way PHP is configured now, doesn't show you that publicly. Enable that setting via php.ini or directly in the script (not recommended) or check out the webserver's error_log (assuming apache and a RedHat based distro this will be on /var/log/httpd/error_log). This will tell you what is really going on because we don't even know what mySQL_user_login.inc.php looks like or what it does, we also don't know what extensions are activated. Providing that information you'll get more luck getting great answers. Also try to mention what distro you're using. Greetings. On Wed, May 29, 2013 at 8:09 PM, Jim Giner jim.gi...@albanyhandball.comwrote: On 5/29/2013 1:39 PM, Ron Piggott wrote: Good morning all: I have recently purchased a computer and am using it as a dedicated server. A friend helped me install PHP and configure. I am saying this because I wonder if using a newer version of PHP (compared to my commercial web host) may be the reasoning behind the error I am receiving. I created a function to generate a form submission key. - This created hidden variable for forms - This is also session variable With this function I have an ‘ include ‘ for the file containing the mySQL database, username and password. I know this file is being accessed because I added: === echo $mySQL_user; === following the login credentials. But when I remove this line from mySQL_user_login.inc.php and place within the function on the line following the include the echo” returns nothing. === include(mySQL_user_login.inc.**php); echo $mySQL_user; === Can any of you tell me why this is happening? Ron Piggott www.TheVerseOfTheDay.info #1 - it's not an include error. It's a programmer error #2 - that said - why would you want to do this? The release of usernames/passwords is a dangerous practice - even in development. If all you want to do is verify that you passed thru this bit of code, echo some less sensitive message, such as Connected successfully. Or even better have the connect function return true or false and check the return. #3 - global #4 - global and #5 global. Anytime you want to use a var withing a function include it in a global statement. I always forget too. But I'm getting pretty good at remembering how to resolve it. PS - do you store your .inc file with this sensitive info on your server outside of the web-accessible path? I hope so. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include() Error
On Wed, May 29, 2013 at 8:09 PM, Jim Giner jim.gi...@albanyhandball.comwrote: On 5/29/2013 1:39 PM, Ron Piggott wrote: Good morning all: I have recently purchased a computer and am using it as a dedicated server. A friend helped me install PHP and configure. I am saying this because I wonder if using a newer version of PHP (compared to my commercial web host) may be the reasoning behind the error I am receiving. I created a function to generate a form submission key. - This created hidden variable for forms - This is also session variable With this function I have an ‘ include ‘ for the file containing the mySQL database, username and password. I know this file is being accessed because I added: === echo $mySQL_user; === following the login credentials. But when I remove this line from mySQL_user_login.inc.php and place within the function on the line following the include the echo” returns nothing. === include(mySQL_user_login.inc.**php); echo $mySQL_user; === Can any of you tell me why this is happening? Ron Piggott www.TheVerseOfTheDay.info #1 - it's not an include error. It's a programmer error #2 - that said - why would you want to do this? The release of usernames/passwords is a dangerous practice - even in development. If all you want to do is verify that you passed thru this bit of code, echo some less sensitive message, such as Connected successfully. Or even better have the connect function return true or false and check the return. #3 - global #4 - global and #5 global. Anytime you want to use a var withing a function include it in a global statement. I always forget too. But I'm getting pretty good at remembering how to resolve it. PS - do you store your .inc file with this sensitive info on your server outside of the web-accessible path? I hope so. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You are most probable getting a fatal error, and the way PHP is configured now, doesn't show you that publicly. Enable that setting via php.ini or directly in the script (not recommended) or check out the webserver's error_log (assuming apache and a RedHat based distro this will be on /var/log/httpd/error_log). This will tell you what is really going on because we don't even know what mySQL_user_login.inc.php looks like or what it does, we also don't know what extensions are activated. Providing that information you'll get more luck getting great answers. Also try to mention what distro you're using. Greetings. -- @unreal4u http://unreal4u.com/
[PHP] Re: include file syntax
PJ wrote: How does one deal with tag completion from an include file to the main(source)-file? i.e. c should a tag, such as head or div be closed withing the include file? Or can body be started in the include file and closed in the main-file? It doesn't really matter, however it may be easier to decipher and/or change later if things are in the same file. i.e. many apps use a header.php that includes html, title, head, and meta tags, maybe body. They include this on every page, then at the bottom of every page they include a footer.php that may add a standard copyright and closes out body html etc. Many times, repeatable html after the body tag may be included in the header or in another include file like menu.php or something. Crossing the border, so-to-speak, doesn't seem to matter; but how does this affect validation and execution? Anyone have a clarification, please? Validation is done on the resultant html output so it's not affected. Every file include takes time to execute the include, however it's probably negligible unless you have a very high number of includes. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Include File Errors with Comments
On Wed, Mar 11, 2009 at 7:51 PM, Patrick Moloney webpa...@gmail.com wrote: OK, I think I've got the problem. I had to go back further than where the problem appeared to be. The 1st error was the comment code on the div line before the menu is Included. It had the -- in the comment. Oddly, it interacts with the same error in the comment in the mainmenu file. I saw some suggestion that these work in pairs but fail in odd numbers. So, I have many pages that work like this. Adding another bad comment to the mainmenu, causes it to fail (3 bad lines). Or, without a third line, fixing the only bad line in the mainmenu also fails! Now, correcting the bad line in the web page fixes that -- (whoops) - but causes all the other similar web site pages to start failing. I'll have to fix them all, but at least I know the problem. No wonder nobody comments code! mainmenu.php !-- Comment on the First Line -- !-- Comment on the -- Second Line -- Functional Menu code ... webpage.php ... Body div id=menu !-- Include the -- menu here -- ?php include 'mainmenu.php'; ? /div ... I do use PHP comments (probably not as much as I should), but I don't usually use HTML comments. This is partly (largely?) because HTML comments get passed on to the client which wastes (albeit usually a small amount of) extra space and bandwidth for each request, and they give out implementation details to people who least need to know them. I can sort of see adding the HTML comments when designing a full page template so it is easier to determine where dynamic content needs to be inserted when you start slicing the template apart, but even then I usually remove those comments later in the design process before I put the code out for production. Then again, I haven't included files for anything other than function/class libraries in years either. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Include File Errors with Comments
Andrew Ballard wrote: I do use PHP comments (probably not as much as I should), but I don't usually use HTML comments. This is partly (largely?) because HTML comments get passed on to the client which wastes (albeit usually a small amount of) extra space and bandwidth for each request, and they give out implementation details to people who least need to know them. Andrew That's another issue, but a good point. I was thinking about that too, and I think it influenced some of my comments. This has been my first use of PHP so I'm still learning. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include File Errors with Comments
Thanks for all the replies. As I said in my original post the comments are on the first lines of the included file and are HTML comments. I'll have to look closer at comment syntax - I see there are empty comments and issues with pairs of double hyphens. My overall code worked well with 2 comment lines, then had issues with the third. I eventually removed my third comment (no problem) then copied my 2nd comment as the 3rd (problem returns). I had some double hyphens -- which seemed to cause problems sometimes. I'm also thinking that it is seeing pairs of -- that are causing issues in odd numbers (half-pairs) only. I'll have to look closer. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include File Errors with Comments
Patrick Moloney wrote: Thanks for all the replies. As I said in my original post the comments are on the first lines of the included file and are HTML comments. I'll have to look closer at comment syntax - I see there are empty comments and issues with pairs of double hyphens. My overall code worked well with 2 comment lines, then had issues with the third. I eventually removed my third comment (no problem) then copied my 2nd comment as the 3rd (problem returns). I had some double hyphens -- which seemed to cause problems sometimes. I'm also thinking that it is seeing pairs of -- that are causing issues in odd numbers (half-pairs) only. I'll have to look closer. By definition, A comment declaration starts with !, followed by zero or more comments, followed by . A comment starts and ends with --, and does not contain any occurrence of --. This being said, depending on how you do it, some browsers will get it wrong, so to keep it simple: An HTML comment begins with !--, ends with -- and does not contain -- or anywhere in the comment. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include File Errors with Comments
OK, I think I've got the problem. I had to go back further than where the problem appeared to be. The 1st error was the comment code on the div line before the menu is Included. It had the -- in the comment. Oddly, it interacts with the same error in the comment in the mainmenu file. I saw some suggestion that these work in pairs but fail in odd numbers. So, I have many pages that work like this. Adding another bad comment to the mainmenu, causes it to fail (3 bad lines). Or, without a third line, fixing the only bad line in the mainmenu also fails! Now, correcting the bad line in the web page fixes that -- (whoops) - but causes all the other similar web site pages to start failing. I'll have to fix them all, but at least I know the problem. No wonder nobody comments code! mainmenu.php !-- Comment on the First Line -- !-- Comment on the -- Second Line -- Functional Menu code ... webpage.php ... Body div id=menu !-- Include the -- menu here -- ?php include 'mainmenu.php'; ? /div ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include Problem
Shaun wrote: Hi, I am having problems with an include statement, i am using the following statement in an effort to include a footer file on my page: include(/cms/templates/footer.php); However I get the following error: Warning: main(/cms/templates/footer.php): failed to open stream: No such file or directory in /home/m/y/mysite/public_html/cms/news/index.php on line 38 Warning: main(/cms/templates/footer.php): failed to open stream: No such file or directory in /home/m/y/mysite/public_html/cms/news/index.php on line 38 Warning: main(): Failed opening '/cms/templates/footer.php' for inclusion (include_path='.:/lib/php') in /home/m/y/mysite/public_html/cms/news/index.php on line 38 The file is definitely there, the script just doesn't seem to be picking it up, has anyone else had this problem? What is the very first file that loads? Is it actually: /home/m/y/mysite/public_html/cms/news/index.php Or maybe something higher up like: /home/m/y/mysite/public_html/cms/index.php that then includes the file above. In the first case, this will work if the file is there: include(dirname(dirname(__FILE__)).'/templates/footer.php'); In the second case, this: include('templates/footer.php'); -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include config.php does not work anymore after PHP 5.2
Hello This is the same thing I always use. ? $host=localhost; $user=root; $password=123; $db=stud; $activation=1; $MAXATTACHSIZE = 100; $ATTACHDIRPATH=e:/www/stud/lattach/; ? By the way, I installed php 4.4.7 and everything is fine with this version though register_globals is again Off. Regards, Mac -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include???
Perhaps there is some whitespace before/after the 'C'... echo '$_POST[status_code]'br /\n; You should then see some whitespace inside the '' so you'll know it's there. This is a VERY good debugging technique to adopt. :-) My own methodology is to use one of the following to peer into an array (of any sort): code echo 'pre'; print_r($_POST); echo '/pre'; echo 'pre'; var_dump($_POST); echo '/pre'; /code Wrap one of those in a function or put it in a static class to call when needed, and voila!, instant array introspection. Useful for $_GET, $_COOKIE, $GLOBALS, $_SERVER, etc... p.s.: Could you use descriptive subjects; include doesn't really say much... -- Jared Farrish Intermediate Web Developer Denton, Tx Abraham Maslow: If the only tool you have is a hammer, you tend to see every problem as a nail. $$
[PHP] Re: Include???
Dan Shirah wrote: Okay, I think I'm doing everything right, but for whatever reason my include isn't working. ?php echo $_POST['status_code']; if ($_POST['status_code'] = C) { include ('complete_save.php'); } ? The echo of my status_code retruns the correct value so the if should trigger. This is my include page: ?php echo test; ? VERY simple, but for some reason is not working change this line: if ($_POST['status_code'] = C) { to this: if ($_POST['status_code'] == C) { You need 2 equal signs when comparing. Darren -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include file questions
1- No 2- Yes -- itoctopus - http://www.itoctopus.com Stephen [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] 1) Does the filename extension matter? I prefer *.inc? It seems to work fine, but I only see others using *.php 2) Does the include file need an opening ?php and ending ? ? Not big issues, but I am curious. Thanks Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Include files....
Hi Everyone, Thanks for the info, putting the opening and closing tags in the include file worked like a charm! Now I just need to get the SQL injection protection junk to work... Back to the web to read more! -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include files....
Hello, Short tags (? ?) are only available when they are enabled via the short_open_tag php.ini configuration file directive, or if php was configured with the --enable-short-tags option. Did you configure your php.ini file? -- Republic Of Turkey - Ministry of National Education Education Technology Department Ankara / TURKEY Web: http://www.haydartuna.net Jason Pruim [EMAIL PROTECTED], haber iletisinde sunlari yazdi:[EMAIL PROTECTED] Okay, Very Newbie-ish question coming! I can't figure out why my include won't work... Here's the text: index.php: ?PHP include 'defaults.php'; $link = mysql_connect($server, $username, $password) or die('Could not connect: ' . mysql_error()); echo 'Connected successfully BR'; mysql_select_db($database) or die('Could not select database: ' . mysql_error()); echo 'DB selected BR'; $result = mysql_query($query) or die(mysql_error()); $num=mysql_numrows($result); $i= 0; while($i $num) { $FName = mysql_result($result, $i,FName); $LName = mysql_result($result,$i,LName); $Add1 = mysql_result($result, $i,Add1); $Add2 = mysql_result($result, $i,Add2); $City = mysql_result($result, $i,City); $State = mysql_result($result, $i,State); $Zip = mysql_result($result, $i,Zip); $Date = date(m-d-y h:i:s,mysql_result($result, $i, Date)); $Record = mysql_result($result, $i, Record); $subName = mysql_result($result, $i,subName); $subEmail = mysql_result($result, $i,subEmail); $subPhone = mysql_result($result, $i,subPhone); $chkMember = unserialize(mysql_result($result, $i,chkMember)); $chkAdd = unserialize(mysql_result($result, $i,chkAdd)); $chkDel = unserialize(mysql_result($result, $i, chkDel)); $i++; //echo P$Record $FName, $LName,/P P$Add1,BR $Add2,BR/P P$City, $State, $Zip,/P $Date,BR $subName, $subEmail, $subPhone, $chkMember[$row], $chkAdd[$row], $chkDel[$row]BR; echo H3Name Address/H3; echo P id ='test' $FName $LName $Add1 $Add2 $Date/P; }; ? * defaults.php: $server = 'localhost'; $username = 'USERNAME'; $password = 'PASSWORD'; $database = 'DATABASE'; $query = 'SELECT * FROM current'; Yes I changed the values of username, password, and database. But when I use the same info inside the index.php file it all works just fine. Here is the error that it gives me: [Fri May 18 15:32:07 2007] [error] PHP Notice: Undefined variable: server in /Volumes/RAIDer/webserver/Documents/tests/legion/index.php on line 5 [Fri May 18 15:32:07 2007] [error] PHP Notice: Undefined variable: username in /Volumes/RAIDer/webserver/Documents/tests/legion/ index.php on line 5 [Fri May 18 15:32:07 2007] [error] PHP Notice: Undefined variable: password in /Volumes/RAIDer/webserver/Documents/tests/legion/ index.php on line 5 [Fri May 18 15:32:07 2007] [error] PHP Warning: mysql_connect() [a href='function.mysql-connect'function.mysql-connect/a]: Access denied for user 'USERNAME'@'localhost' (using password: NO) in / Volumes/RAIDer/webserver/Documents/tests/legion/index.php on line 5 Thanks in advance for helping me through my obvious friday afternoon brain fart... -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include file error, common one I think
Is it the whole code of your file, or is there any other html code? Chris Carter [EMAIL PROTECTED] escreveu na mensagem news:[EMAIL PROTECTED] Hi, Here is code that I got from the internet for random image. This file works perfect if I try it independently but not on any existing file. I think the error that I am getting is quite common on the net but its new for me. I am getting this error: Warning: Cannot modify header information - headers already sent by (output started at /folder/test.php:12) in /folder/randomimage.php on line 19 the code that I got from net: ? $folder = 'images/'; $exts = 'jpg jpeg png gif'; $files = array(); $i = -1; if ('' == $folder) $folder = './'; $handle = opendir($folder); $exts = explode(' ', $exts); while (false !== ($file = readdir($handle))) { foreach($exts as $ext) { if (preg_match('/\.'.$ext.'$/i', $file, $test)) { $files[] = $file; ++$i; } } } closedir($handle); mt_srand((double)microtime()*100); $rand = mt_rand(0, $i); Line 19 is below: header('Location: '.$folder.$files[$rand]); ? Thanks a bunch. Chris -- View this message in context: http://www.nabble.com/Include-file-error%2C-common-one-I-think-tf2971907.html#a8316202 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include and require
Dave Goodchild wrote: Hi all - I have several require_once statements in my web app to load in small function libraries. A common one bundles a variety of functions to handle date math and map month numbers to month names. I originally defined an array in that file plus a bunch of functions but when I loaded the page, the array variable, referenced further down the page, was NULL. I wrapped a function def around the array and returned it and all was fine. I may be suffering from mild hallucinations, but can you not define variables in a required file? It is not a scope issue as the array variable is referenced in the web page, not in any function. I know for a fact that you can define variables in PHP 4 and 5. The idea behind include and require is little more complex than copying and pasting the code. Many of my scripts include a config.php which has various variables created with setting information. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include and require
Dave Goodchild wrote: I use a config file too. That was a sanity check. The file extract looked like this: $months = array(1 = 'January', 2 = 'February', 3 = 'March', 4 = 'April', 5 = 'May', 6= 'June', 7 = 'July', 8 = 'August', 9 = 'September', 10 = 'October', 11 = 'November', 12 = 'December'); which was called in with require_once. The reference to $months in the calling page, checked with var_dump, was NULL. When I wrapped it like this: function getmonths() { $months = array(1 = 'January', 2 = 'February', 3 = 'March', 4 = 'April', 5 = 'May', 6= 'June', 7 = 'July', 8 = 'August', 9 = 'September', 10 = 'October', 11 = 'November', 12 = 'December'); return $months; } it worked. Not sure why the simple variable didn't work. On 14/08/06, *Adam Zey* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Dave Goodchild wrote: Hi all - I have several require_once statements in my web app to load in small function libraries. A common one bundles a variety of functions to handle date math and map month numbers to month names. I originally defined an array in that file plus a bunch of functions but when I loaded the page, the array variable, referenced further down the page, was NULL. I wrapped a function def around the array and returned it and all was fine. I may be suffering from mild hallucinations, but can you not define variables in a required file? It is not a scope issue as the array variable is referenced in the web page, not in any function. I know for a fact that you can define variables in PHP 4 and 5. The idea behind include and require is little more complex than copying and pasting the code. Many of my scripts include a config.php which has various variables created with setting information. Regards, Adam Zey. -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk Was the $months variable created inside an if statement or something else? PHP's rules of scope say that variables created inside a code block (like an if, a for, a while, a foreach), they stop existing the moment you exit that code block. So this: $foo = bar; if ( $foo == bar ) { $baz = narf; } echo $baz; That code will output nothing, because $baz is empty by the time I try to output it. The solution that I use is this: $foo = bar; $baz = ; if ( $foo == bar ) { $baz = narf; } echo $baz; In which case the output would be narf, because the variable existed before I changed it in the if. This sounds like it might be your problem, though I can't know without seeing the code. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Include and require
Adam Zey wrote: Dave Goodchild wrote: I use a config file too. That was a sanity check. The file extract looked like this: $months = array(1 = 'January', 2 = 'February', 3 = 'March', 4 = 'April', 5 = 'May', 6= 'June', 7 = 'July', 8 = 'August', 9 = 'September', 10 = 'October', 11 = 'November', 12 = 'December'); which was called in with require_once. The reference to $months in the calling page, checked with var_dump, was NULL. When I wrapped it like this: function getmonths() { $months = array(1 = 'January', 2 = 'February', 3 = 'March', 4 = 'April', 5 = 'May', 6= 'June', 7 = 'July', 8 = 'August', 9 = 'September', 10 = 'October', 11 = 'November', 12 = 'December'); return $months; } it worked. Not sure why the simple variable didn't work. On 14/08/06, *Adam Zey* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Dave Goodchild wrote: Hi all - I have several require_once statements in my web app to load in small function libraries. A common one bundles a variety of functions to handle date math and map month numbers to month names. I originally defined an array in that file plus a bunch of functions but when I loaded the page, the array variable, referenced further down the page, was NULL. I wrapped a function def around the array and returned it and all was fine. I may be suffering from mild hallucinations, but can you not define variables in a required file? It is not a scope issue as the array variable is referenced in the web page, not in any function. I know for a fact that you can define variables in PHP 4 and 5. The idea behind include and require is little more complex than copying and pasting the code. Many of my scripts include a config.php which has various variables created with setting information. Regards, Adam Zey. -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk Was the $months variable created inside an if statement or something else? PHP's rules of scope say that variables created inside a code block (like an if, a for, a while, a foreach), they stop existing the moment you exit that code block. So this: $foo = bar; if ( $foo == bar ) { $baz = narf; } echo $baz; That code will output nothing, because $baz is empty by the time I try to output it. That's wrong sorry :) $ php -a Interactive mode enabled ?php $foo = bar; if ( $foo == bar ) { $baz = narf; } echo $baz; narf Works fine. If you only create the variable inside the if you won't be able to use it if the code doesn't get into the if (it'll be an undefined variable): $ php -a Interactive mode enabled ?php error_reporting(E_ALL); if (1 == 0) { $foo = blah; } echo $foo; Notice: Undefined variable: foo in - on line 6 -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include Problem
Check the file's permissions with your ftp utility Shaun wrote: Hi, I am having problems with an include statement, i am using the following statement in an effort to include a footer file on my page: include(/cms/templates/footer.php); However I get the following error: Warning: main(/cms/templates/footer.php): failed to open stream: No such file or directory in /home/m/y/mysite/public_html/cms/news/index.php on line 38 Warning: main(/cms/templates/footer.php): failed to open stream: No such file or directory in /home/m/y/mysite/public_html/cms/news/index.php on line 38 Warning: main(): Failed opening '/cms/templates/footer.php' for inclusion (include_path='.:/lib/php') in /home/m/y/mysite/public_html/cms/news/index.php on line 38 The file is definitely there, the script just doesn't seem to be picking it up, has anyone else had this problem? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include file to global scope
Claudio schrieb: I'm using PHP 5. I have a class operation that includes php files. Is there a way to include this files to global scope? So that difined vars and functions are global accesseble? I know this problem from my early PHP days. If your problem is that you want to include some class or function libraries then the simple solution is: Do not include inside the function or class but let the class or function just return the path name! So instead of function include_lib($name) { $path='functions/'.$name.'.php'; // or more werid stuff include($path); } include_lib('test'); do function lib_path($name) { $path='functions/'.$name.'.php'; // or more werid stuff return $path; } include(lib_path('test')); Perhaps your problem is exactly of this type or similar. AllOLLi Inara: It sounds like the sort of thing this crew can handle. I can't guarantee they'll handle it particularly well, but... Nandi: If they got guns, and brains at all... Inara: They've got guns. [firefly 113] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include file to global scope
cc wrote: yes, its possible, consider this: /** * @param $file_to_include path to php file you want to get its content * @return included contents */ function get_output($file_to_include){ ob_start(); include $file_to_include; return ob_get_clean(); } this will break if the included file assumes its being included in the global scope (and/or has functions that assume certain globals exists - which they would do if the file wasn't included within a function) ... which brings the OP back to his original problem :-) of course, you may extend this function to better fit into your situation. Good luck. On 10/12/05, Claudio [EMAIL PROTECTED] wrote: Is it possible to process the file in second php instance? An only get its output? Claudio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include file to global scope
the answer cc wrote: yes, its possible, consider this: /** * @param $file_to_include path to php file you want to get its content * @return included contents */ function get_output($file_to_include){ ob_start(); include $file_to_include; return ob_get_clean(); } is to the question On 10/12/05, Claudio [EMAIL PROTECTED] wrote: Is it possible to process the file in second php instance? An only get its output? Claudio to ``Is there a way to include this files to global scope? So that difined vars and functions are global accesseble?'', there is another answer, consider these code, ?php $ov=1; function o(){ $iv=1; function i(){ echo i\n; var_dump(get_defined_vars()); } echo o\n; var_dump(get_defined_vars()); i(); } o(); i(); var_dump(get_defined_vars()); On 10/13/05, Jochem Maas [EMAIL PROTECTED] wrote: cc wrote: yes, its possible, consider this: /** * @param $file_to_include path to php file you want to get its content * @return included contents */ function get_output($file_to_include){ ob_start(); include $file_to_include; return ob_get_clean(); } this will break if the included file assumes its being included in the global scope (and/or has functions that assume certain globals exists - which they would do if the file wasn't included within a function) ... which brings the OP back to his original problem :-) of course, you may extend this function to better fit into your situation. Good luck. On 10/12/05, Claudio [EMAIL PROTECTED] wrote: Is it possible to process the file in second php instance? An only get its output? Claudio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include file to global scope
yes, its possible, consider this: /** * @param $file_to_include path to php file you want to get its content * @return included contents */ function get_output($file_to_include){ ob_start(); include $file_to_include; return ob_get_clean(); } of course, you may extend this function to better fit into your situation. Good luck. On 10/12/05, Claudio [EMAIL PROTECTED] wrote: Is it possible to process the file in second php instance? An only get its output? Claudio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Include path quirks
Ethilien wrote: Actually, I think I might have found a solution, although its not a very good one. include realpath(dirname(__FILE__) . / . ../include/global.php); Ethilien wrote: I've been attempting to write an application with a bit more ordered directory structure than I normally use, and I ran into the rather annoying problem with include() where relative paths are only based off of the current working directory, and not that of the included script. This makes it impossible to include script correctly, because the path from the working directory is different than that of the included file. The problem is I'm trying to include /include/global.php from /elements/nav.php but topnav is included by /index.php Which results in a failed top open stream error. Is there any way around this annoying idiosyncrasy? What I do, and a lot of other folks I borrowed the idea from, is to set a variable or constant, something like define('INCLUDE_DIR', include/) in your index, or init file. Then when you need to do an include from another included file you just do include INCLUDE_DIR.somefile.php and the path is set for you. All file paths are going to be relevant to the first script hit, so you can change the actual path to your include directory relative to that script. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Include path quirks
Ethilien wrote: Actually, I think I might have found a solution, although its not a very good one. include realpath(dirname(__FILE__) . / . ../include/global.php); alot of people do something _like_: define('GLOBAL_BASE_DIR', dirname(__FILE__)); somewhere near the beginning of their startup code... so you can subsequently do: require_once GLOBAL_BASE_DIR . '/include/xyz.php'; but maybe you should also look at the ini setting 'include_path' Ethilien wrote: I've been attempting to write an application with a bit more ordered directory structure than I normally use, and I ran into the rather annoying problem with include() where relative paths are only based off of the current working directory, and not that of the included script. This makes it impossible to include script correctly, because the path from the working directory is different than that of the included file. The problem is I'm trying to include /include/global.php from /elements/nav.php but topnav is included by /index.php Which results in a failed top open stream error. Is there any way around this annoying idiosyncrasy? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include path quirks
Actually, I think I might have found a solution, although its not a very good one. include realpath(dirname(__FILE__) . / . ../include/global.php); Ethilien wrote: I've been attempting to write an application with a bit more ordered directory structure than I normally use, and I ran into the rather annoying problem with include() where relative paths are only based off of the current working directory, and not that of the included script. This makes it impossible to include script correctly, because the path from the working directory is different than that of the included file. The problem is I'm trying to include /include/global.php from /elements/nav.php but topnav is included by /index.php Which results in a failed top open stream error. Is there any way around this annoying idiosyncrasy? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include and extending classes
Mike Smith wrote: I'm trying to consolidate code in a new project. My dirs are: / /inc core.class.php /mods /mods/system system.class.php //extends core.class.php user.class.php //extends system.class.php In core.class.php I have my generic special html methods and my db connection. I'm having trouble accessing $this-db (initialized in core.class.php) from user.class.php. Am I wrong in thinking user.class.php should be able to access methods/attributes of core.class.php? http://php.net/manual/en/function.include.php So if user.class.php include()'s core.class.php then you should have the class definition (for methods) as well as any objects that were created. in core.class.php. In other words all variables get imported into the current scope in the calling file. I'm running PHP 5.0.4 on Windows //core.class.php class core { var $db; Is this actually var? Did you possibly call this private / protected? Var == Public, so the db property of any core class should be available. function core(){ //initialize db connection (works from here) } //Other methods } //system.class.php include ../../inc/core.class.php; Note that relative paths can cause problems when you switch the current working directory. This likely isn't a problem for this particular issue you're having, but it's a gotcha for future work. What I do for relative includes is something like: include dirname(__FILE__) . ../../inc/core.class.php; class system extends core { function system(){ /** See note below */ $this-core(); } } //user.class.php include system.class.php; class user extends system{ function user(){ //$this-db cannot be used here What exactly do you mean by cannot be used... do you mean that you don't have access to db? Or perhaps you expect cascading __constructor calls which PHP does not do by default. Instead you need to call the parent constructor *explicitly*. $this-system(); } } TIA, Mike There are no stupid questions. --my professors until I came into class. -- NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-generalw=2 STFM | http://php.net/manual/en/index.php STFW | http://www.google.com/search?q=php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include()
* I. Gray [EMAIL PROTECTED]: Is there a big difference between me including a file by putting the url in the include() such as include(http://www.examplesite.com/examplefile.php) and putting the server path such as include(number/www.examplesite.com/public_html/examplefile.php) ? I want to get into good habits you see. I assume I have to use the first example when the file is on a different server. From a security standpoint, you usually only want to include and/or require files that are on your local system (your second example), unless under unusual circumstances (content sharing agreements with other sites, etc). Ideally, unless you want access to those scripts directly (i.e., http://www.examplesite.com/examplefile.php), you should place them somewhere in your include_path, which should be _outside_ the web server's document root. This prevents idle hacking attempts, and is generally considered a best practice. Additionally, using a network stream (which is what you're using when you specify 'http://') means that you've got additional performance overhead. Network streams are often more costly, resource wise, than file streams, and if the file truly is on a remote network, you then have to wait for that transaction to finish before continuing with your own processing. If you need to pull content off another server, but that content does not change often, you would be wise to have a background process running that pulls this content and caches it for use in your scripts. -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:[EMAIL PROTECTED] | http://vermontbotanical.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include (evaluate) PHP/HTML code stored in a variable
eval('? '.$code.' ?php'); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include Remote Content as REMOTE_ADDR of Browser
Ryan Grange wrote: Gary C. New wrote: Is there a quick and dirty way to include, file, or fsockopen content from a remote server and make it appear as though the request was straight from the browser's remote address? Thank you for your assistance. Respectfully, Gary I believe you would in effect by spoofing the source of the request. The problem is that the server you request from would respond to the wrong IP and the browser at the client wouldn't be accepting any data from the remote server for display. I figured that might be the case. I guess half a solution is better than no solution at all. Would it be possible to engineer a man-in-the-middle situation between the browser, server, and remote server? I have been looking at Phpcap as a possible solution. It seems possible to engineer the non-returnable package (half solution) situation. But I wouldn't know where to begin to attempt the man-in-the-middle situation or if it is even possible. Thank you for your response. Respectfully, Gary -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include literal
Jeremy Reynolds wrote: What if I want to include some literal test into a PHP document that I don't want it to interpret as it loads. In particular, I am working with XML but for the example's sake I will say PHP. Example: FYI, when you have -- on a line by itself most newsreaders think that the text that follows is your signature. So, please don't put that into a message unless your signature will follow. Now to answer your question: ?php /** DocumentB.php */ $text = file_get_contents('DocumentA.php'); echo $text; ? -- Teach a man to fish... NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-generalw=2 STFM | http://php.net/manual/en/index.php STFW | http://www.google.com/search?q=php LAZY | http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins signature.asc Description: OpenPGP digital signature
[PHP] Re: Include wierdness.
One correction. The include('lib/test2.php') is actually a require_once('lib/test2.php'). That's why it quits and I don't get the third include. -- Rob Rob Adams [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] From the manual on 'include': Files for including are first looked in include_path relative to the current working directory and then in include_path relative to the directory of current script. E.g. if your include_path is ., current working directory is /www/, you included include/a.php and there is include b.php in that file, b.php is first looked in /www/ and then in /www/include/. I have a file in my root dir (we'll call it /www) that includes the file /www/lib/test.php as follows: include('lib/test.php'); test.php looks like this: ? echo 'Inside first included file.'; if (file_exists('lib/test2.php')) echo 'This file exists.'; include('lib/test2.php'); echo 'Ending first included file.'; ? /www/lib/test2.php exists. Whenever I run this, I get the first two echo statements, without getting the third one. The error log reports that it couldn't find lib/test2.php. If I take out the 'lib/' in the include statement, it works. According to the description from the manual, either way should work. Has anyone ever come across this problem before, and is there a config setting that causes it? I'm stumped here, and I refuse to go change all the code when from what I've read it should already be working. -- Rob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Include wierdness.
Rob Adams wrote: One correction. The include('lib/test2.php') is actually a require_once('lib/test2.php'). That's why it quits and I don't get the third include. you 100% sure your include_path is '.' ? just asking. also you mention a /www/lib and a /www/include dir - maybe thats the problem? maybe you can make the problem go away by setting include_path to '.:/www/include' or '.:/www/lib' I must say I think its overkill to use file_exists() on files you are going to require_once() - although no doubt there is a good reason to do it sometimes :-) it is odd though, file_exists() returns true yet the file cannot be included. -- any chocolate chips in this cookie jar care to enlighten the crumbs? -- Rob Rob Adams [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] From the manual on 'include': Files for including are first looked in include_path relative to the current working directory and then in include_path relative to the directory of current script. E.g. if your include_path is ., current working directory is /www/, you included include/a.php and there is include b.php in that file, b.php is first looked in /www/ and then in /www/include/. I have a file in my root dir (we'll call it /www) that includes the file /www/lib/test.php as follows: include('lib/test.php'); test.php looks like this: ? echo 'Inside first included file.'; if (file_exists('lib/test2.php')) echo 'This file exists.'; include('lib/test2.php'); echo 'Ending first included file.'; ? /www/lib/test2.php exists. Whenever I run this, I get the first two echo statements, without getting the third one. The error log reports that it couldn't find lib/test2.php. If I take out the 'lib/' in the include statement, it works. According to the description from the manual, either way should work. Has anyone ever come across this problem before, and is there a config setting that causes it? I'm stumped here, and I refuse to go change all the code when from what I've read it should already be working. -- Rob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Include wierdness.
The scenario I gave is very simplified. I'm actually trying to get tikiwiki working on a server, and the reason it won't run the install is because of this problem I've mentioned. It works as expected on my development server (WinXP), but on my production (FreeBSD) it fails. I don't have a /www/include dir. The reference to that is just from the manual that I quoted. -- Rob Jochem Maas [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Rob Adams wrote: One correction. The include('lib/test2.php') is actually a require_once('lib/test2.php'). That's why it quits and I don't get the third include. you 100% sure your include_path is '.' ? just asking. also you mention a /www/lib and a /www/include dir - maybe thats the problem? maybe you can make the problem go away by setting include_path to '.:/www/include' or '.:/www/lib' I must say I think its overkill to use file_exists() on files you are going to require_once() - although no doubt there is a good reason to do it sometimes :-) it is odd though, file_exists() returns true yet the file cannot be included. -- any chocolate chips in this cookie jar care to enlighten the crumbs? -- Rob Rob Adams [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] From the manual on 'include': Files for including are first looked in include_path relative to the current working directory and then in include_path relative to the directory of current script. E.g. if your include_path is ., current working directory is /www/, you included include/a.php and there is include b.php in that file, b.php is first looked in /www/ and then in /www/include/. I have a file in my root dir (we'll call it /www) that includes the file /www/lib/test.php as follows: include('lib/test.php'); test.php looks like this: ? echo 'Inside first included file.'; if (file_exists('lib/test2.php')) echo 'This file exists.'; include('lib/test2.php'); echo 'Ending first included file.'; ? /www/lib/test2.php exists. Whenever I run this, I get the first two echo statements, without getting the third one. The error log reports that it couldn't find lib/test2.php. If I take out the 'lib/' in the include statement, it works. According to the description from the manual, either way should work. Has anyone ever come across this problem before, and is there a config setting that causes it? I'm stumped here, and I refuse to go change all the code when from what I've read it should already be working. -- Rob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Include wierdness.
Jochem Maas wrote: Rob Adams wrote: ... you 100% sure your include_path is '.' ? just asking. also you mention a /www/lib and a /www/include dir - maybe thats the problem? maybe you can make the problem go away by setting include_path to '.:/www/include' or '.:/www/lib' This still sounds like the best place to start... check your include_path and see if it includes '.' and/or whatever is the root directory for your tikiwiki installation. ?php var_dump(ini_get('include_path')); ? I must say I think its overkill to use file_exists() on files you are going to require_once() - although no doubt there is a good reason to do it sometimes :-) Well... I seem to recall there is an optional argument for require_once that searches the include path. You can try using that parameter if you don't know the current working directory (why?). ?php require_once('some/relative/include.php', true); ? it is odd though, file_exists() returns true yet the file cannot be included. My guess is the file *is* in the include path, but the current working directory when require_once() executes is not what the OP thinks it is... -- Teach a man to fish... NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-generalw=2 STFM | http://php.net/manual/en/index.php STFW | http://www.google.com/search?q=php LAZY | http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins signature.asc Description: OpenPGP digital signature
Re: [PHP] Re: Include wierdness.
Jason Barnett [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] My guess is the file *is* in the include path, but the current working directory when require_once() executes is not what the OP thinks it is... I was hoping this was the case, but just checked it with: echo `pwd`; and it gave what I thought should be the correct directory. (The directory where the initial php file is.) I also checked my include path, and it does have a '.' at the end of it. I'm using a host called iPowerWeb. Overall I've liked them a lot, but there have been a few glitches like this that drive me nuts. One is a tendancy for the server to rewrite configuration files to turn open_basedir on. I've checked that though, and that hasn't happened in this case (yet.) -- Rob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Include wierdness.
Jason Barnett wrote: Jochem Maas wrote: Rob Adams wrote: ... you 100% sure your include_path is '.' ? just asking. also you mention a /www/lib and a /www/include dir - maybe thats the problem? maybe you can make the problem go away by setting include_path to '.:/www/include' or '.:/www/lib' This still sounds like the best place to start... check your include_path and see if it includes '.' and/or whatever is the root directory for your tikiwiki installation. ?php var_dump(ini_get('include_path')); ? I must say I think its overkill to use file_exists() on files you are going to require_once() - although no doubt there is a good reason to do it sometimes :-) Well... I seem to recall there is an optional argument for require_once that searches the include path. You can try using that parameter if you don't know the current working directory (why?). manual doesn't confirm that - besides most of my code wouldn't work if require_once didn't use the include path... actually some of my code really doesn't work :-) but when a require fails its often obvious because there is NO output and NO error logged - but thats just me. anyway I'm sure require_once uses the include_path. ?php require_once('some/relative/include.php', true); ? it is odd though, file_exists() returns true yet the file cannot be included. My guess is the file *is* in the include path, but the current working directory when require_once() executes is not what the OP thinks it is... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Include wierdness.
Jochem Maas [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Jason Barnett wrote: Jochem Maas wrote: Rob Adams wrote: ... you 100% sure your include_path is '.' ? just asking. also you mention a /www/lib and a /www/include dir - maybe thats the problem? maybe you can make the problem go away by setting include_path to '.:/www/include' or '.:/www/lib' This still sounds like the best place to start... check your include_path and see if it includes '.' and/or whatever is the root directory for your tikiwiki installation. ?php var_dump(ini_get('include_path')); ? I must say I think its overkill to use file_exists() on files you are going to require_once() - although no doubt there is a good reason to do it sometimes :-) Well... I seem to recall there is an optional argument for require_once that searches the include path. You can try using that parameter if you don't know the current working directory (why?). manual doesn't confirm that - besides most of my code wouldn't work if require_once didn't use the include path... actually some of my code really doesn't work :-) but when a require fails :) I know the feeling... its often obvious because there is NO output and NO error logged - but thats just me. anyway I'm sure require_once uses the include_path. I figured out what the problem was. Learn something new every ... month or so. In unix, the include_path is separated by a colon (:), not a semi-colon (;). My include_path was set to '.;/path/to/smarty/'. I changed it to '.:/path/to/smarty/' and the error went away. Guess I should've read the manual on the configuration file as well. :) Thanks for the help. -- Rob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include Issues
Stephen Craton wrote: I have a script that calls a function called conbox. This function creates the HTML to a content box and you also pass a file to be included into the content area of the box. The function echos out some of the HTML, then does a simple include(), and then echos out the rest of the HTML. I'm trying to do this with another file containing PHP code and HTML together, it's a file that fetches and displays information from a database. The file is fine by itself, but once I include it into the actual content box, it does a die(). I have it set to do that if there's a MySQL error, but it doesn't output any error at all, and the file works by itself. Here is the code that fetches from the database: ?php mysql_select_db($database_default, $default); $query_headlines = SELECT id, headline, short, datetime FROM snews ORDER BY datetime DESC; $headlines = mysql_query($query_headlines, $default) or die(mysql_error()); $row_headlines = mysql_fetch_assoc($headlines); $totalRows_headlines = mysql_num_rows($headlines); ? And here's where it displays: table width=98% border=0 cellspacing=0 cellpadding=2 bordercolor=#616161 align=center style=border-collapse:collapse tr bgcolor=#E0EBF1 td align=left style=padding:3px 3px 3px 3px;a href=snews.php?id=?php echo $row_headlines['id']; ? class=headline?php echo $row_headlines['headline']; ?/a/td /tr /table This is fine, completely fine, by itself (if I include the database credentials of course, but if I leave that include in there, it still won't work). I've already included that file into the file it's being included into anyway so it should work, but it simply isn't. Here's the conbox function with less of the echo: function conbox($title, $contentfile, $content, $width, $height) { echo 'Stuff...'; if($content == '') { if([EMAIL PROTECTED]($contentfile)) { echo 'content unavailable'; } } if($content != '') { echo 'p align=left'.$content.'/p'; } echo'stuff'; } Like I said, all the database credentials and everything is included into the final file, but it simply won't work. Any ideas here? Thanks, Stephen Craton http://www.melchior.us http://www.melchior.us/ You're probably running into a namespace issue here. The global variables that you're trying to use for mysql_select_db aren't in the namespace of the function that's including the file. I would suggest using a better (OOP) system to get around this. Barring that, the best way IMHO is to use $GLOBALS['database_default'], etc. for the vars in the include that are created globally. -- paperCrane Justin Patrin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Include Issues
Thank you for the suggestion, worked like a charm. I was using GLOBALS earlier in the script because of the same issue, just wasn't thinking about it for these variables. :-) Thanks, Stephen Craton http://www.melchior.us -Original Message- From: Justin Patrin [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 16, 2004 5:53 PM To: [EMAIL PROTECTED] Subject: [PHP] Re: Include Issues Stephen Craton wrote: I have a script that calls a function called conbox. This function creates the HTML to a content box and you also pass a file to be included into the content area of the box. The function echos out some of the HTML, then does a simple include(), and then echos out the rest of the HTML. I'm trying to do this with another file containing PHP code and HTML together, it's a file that fetches and displays information from a database. The file is fine by itself, but once I include it into the actual content box, it does a die(). I have it set to do that if there's a MySQL error, but it doesn't output any error at all, and the file works by itself. Here is the code that fetches from the database: ?php mysql_select_db($database_default, $default); $query_headlines = SELECT id, headline, short, datetime FROM snews ORDER BY datetime DESC; $headlines = mysql_query($query_headlines, $default) or die(mysql_error()); $row_headlines = mysql_fetch_assoc($headlines); $totalRows_headlines = mysql_num_rows($headlines); ? And here's where it displays: table width=98% border=0 cellspacing=0 cellpadding=2 bordercolor=#616161 align=center style=border-collapse:collapse tr bgcolor=#E0EBF1 td align=left style=padding:3px 3px 3px 3px;a href=snews.php?id=?php echo $row_headlines['id']; ? class=headline?php echo $row_headlines['headline']; ?/a/td /tr /table This is fine, completely fine, by itself (if I include the database credentials of course, but if I leave that include in there, it still won't work). I've already included that file into the file it's being included into anyway so it should work, but it simply isn't. Here's the conbox function with less of the echo: function conbox($title, $contentfile, $content, $width, $height) { echo 'Stuff...'; if($content == '') { if([EMAIL PROTECTED]($contentfile)) { echo 'content unavailable'; } } if($content != '') { echo 'p align=left'.$content.'/p'; } echo'stuff'; } Like I said, all the database credentials and everything is included into the final file, but it simply won't work. Any ideas here? Thanks, Stephen Craton http://www.melchior.us http://www.melchior.us/ You're probably running into a namespace issue here. The global variables that you're trying to use for mysql_select_db aren't in the namespace of the function that's including the file. I would suggest using a better (OOP) system to get around this. Barring that, the best way IMHO is to use $GLOBALS['database_default'], etc. for the vars in the include that are created globally. -- paperCrane Justin Patrin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include $var
Try it? (Yes, it works) Bob Lockie [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Should 'include $var;' work? I need go to an HTML page after the form has been submitted. page A - program B (no output) - page A -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include (or require) doesn't seem to work
Thanks Torsten! Using the file-system relative path made it work (I had tried only with the absolute path, which ddidn't work). However, I checked again and I did have 'allow_url_fopen = On' in /etc/php.ini. I'll take a closer look later and report the problem if I find it. Thanks again, Daniel Torsten Roehr [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Try including it as a local file: require_once library.php'; // if it is in the same directory as the file you Forgot a quote here, sorry: require_once 'library.php'; Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include from another URL
Nik wrote: Hi there, I'm new to these groups so forgive me if I'm asking at the wrong place (tell me where then :) Ok, I'm not PHP guru but I need to create a simple script that would do this: Include a content from another URL into the current output. I have done something like this: -- code start ?php include 'http://myotherurl.com:8080'; ? -- code end and it seems to work with one exception: it produces a warning message saying something like Warning: main(): stream does not support seeking in .../web-root/index.php on line 9 where line #9 is: include 'http://myotherurl.com:8080'; from above code. It then shows a message from 'http://myotherurl.com:8080' Thanks!!! Nik Nik, try fopen instead of include.. http://br.php.net/manual/en/function.fopen.php look at comments... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include (or require) doesn't seem to work
Daniel Barbar [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Thanks Torsten! Using the file-system relative path made it work (I had tried only with the absolute path, which ddidn't work). However, I checked again and I did have 'allow_url_fopen = On' in /etc/php.ini. I'll take a closer look later and report the problem if I find it. Thanks again, Daniel Using the absolute path works as well - but you have to use the full LOCAL file path, e.g. /htdocs/www/your-domain etc. You can get this value from $_SERVER['DOCUMENT_ROOT']. Regards, Torsten Torsten Roehr [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Try including it as a local file: require_once library.php'; // if it is in the same directory as the file you Forgot a quote here, sorry: require_once 'library.php'; Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include (or require) doesn't seem to work
Daniel Barbar [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, I'm almost ashamed to ask this question as surely enough the problem is something very basic but, nonetheless, I can't put my finger on it. I'm trying to implement the concept of a library (library.php) on PHP where I define (once) all auxiliary functions and then use them in a file (for instance index.php) via the 'require' or 'include' constructs. Here's a reduced version of what I'm doing: index.php: ?php $lang = (isset($_REQUEST['lang']) ? $_REQUEST['lang'] : es); echo index.php: include_path is . (ini_get('include_path')).br; require(http://tristan/library.php?lang=$lang;); my_function(en); ? library.php: ?php echo library.php: Called with $_SERVER[HTTP_HOST]:/$_SERVER[REQUEST_URI] br; function my_function($lang = es) { echo my_function() says $lang; } echo library.php: loadedbr; ? When I load index.php I get the following: index.php: include_path is .:/usr/local/php/4.3.6/lib/php library.php: Called with tristan://library.php?lang=es library.php: loaded Fatal error: Call to undefined function: my_function() in /www/htdocs/index.php on line 5 It seems that the name space on index.php never gets updated with the function definitions made on library.php. What am I doing wrong? Thanks! Cheers, Daniel Hi Daniel, take a look at this section of the manual about including remote files: If URL fopen wrappers are enabled in PHP (which they are in the default configuration), you can specify the file to be included using a URL (via HTTP or other supported wrapper - see Appendix J for a list of protocols) instead of a local pathname. If the target server interprets the target file as PHP code, variables may be passed to the included file using a URL request string as used with HTTP GET. This is not strictly speaking the same thing as including the file and having it inherit the parent file's variable scope; the script is actually being run on the remote server and the result is then being included into the local script. Try including it as a local file: require_once library.php'; // if it is in the same directory as the file you have this line in Also you don't have to pass $lang via Get to the file as the included code will have access to $lang as it is then in the scope of the script. Regards, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include (or require) doesn't seem to work
Try including it as a local file: require_once library.php'; // if it is in the same directory as the file you Forgot a quote here, sorry: require_once 'library.php'; Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include from another URL?
You could always use this : $text = ; $fd=fopen($url,r); while ($line=fgets($fd,1000)) { $text.=$line; } fclose ($fd); echo $text; -- -- Kim Steinhaug -- There are 10 types of people when it comes to binary numbers: those who understand them, and those who don't. -- www.steinhaug.com - www.easywebshop.no - www.webkitpro.com -- Nik [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi there, I'm new to these groups so forgive me if I'm asking at the wrong place (tell me where then :) Ok, I'm not PHP guru but I need to create a simple script that would do this: Include a content from another URL into the current output. I have done something like this: -- code start ?php include 'http://myotherurl.com:8080'; ? -- code end and it seems to work with one exception: it produces a warning message saying something like Warning: main(): stream does not support seeking in .../web-root/index.php on line 9 where line #9 is: include 'http://myotherurl.com:8080'; from above code. It then shows a message from 'http://myotherurl.com:8080' Thanks!!! Nik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include all functions and performance
PHP will load the entire file and consume memory. It will also check the sintax of the entire file. If your file grows to much it would affect the speed of showing your pages and if it is very big, you could find the limit of memory of PHP (8Mb by default). The Zend engine makes an on the fly compilation before executing the functions (see Zend engine in the manual) so it consumes time. My recomendation should be to have a set of a few files with the functions grouped by category or by frecuency of use. Another inconvenient is that if you make a change in one function and by mistake have a syntax error, all the scripts that use that included file will crash until you fix it. I think it's not a nice solution :( Sorry, Gabriel. Terence [EMAIL PROTECTED] escribió en el mensaje news:[EMAIL PROTECTED] Dear List, I have a library of functions which I was thinking of including all from one file, in a kind of heirarchy. That way I can just include the one file in each php page and have all the functions available to me. (a kind of lazy approach I know) What I was wondering, if using the apache server, will this kind of approach affect the performance of my pages, since obviously all functions won't be used for every page (perhaps just a couple). I know from Java that only the functions that are used in the code are included when compiling, but with php there's no compilation (i think). Good, bad or ugly? Thanks Terence -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include() problems
Gustave Bernier [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi everyone, I'm new to PHP and I'm trying to use the include function but with no success... My server's ini file is set as (allow_url_fopen, 0) so I'm having some trouble to pass different values for the php file I'm calling. The address is: http://mydomain.com/forums/ssi.php?a=active The code I'm trying now is: $_GET['a'] = 'active'; include('forums/ssi.php'); When I use this code I have no error, ssi.php is loaded but nothing is done (I believe the a value isn't passed to ssi.php) and the page where the include is stops loading just after the include(). You don't pass the value to that file, you simply tell the preprocessor of PHP to copy the contents of forums/ssi.php file into the source code before executing the script. You do NOT call the ssi.php by that! As you are stating you want to call http://mydomain.com/forums/ssi.php?a=active why are you including the file in there? The statement about allow_url_fopen, 0 setting controls access to remote-resources, so if you are allowed to do something like fopen(http://...;) or include(http://..;). Thus it doesn't have anything to do with your include. -- Dennis Sterzenbach www.darknoise.de -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include() problems
Thanks for answering. I'm trying to include that file because in my index page because it has many functions I need to use in other pages... I'm on ADDR.com servers and I can't set allow_url_fopen to 1 (it sucks!). In ssi.php functions are called by accessing this address: http://mydomain.com/forums/ssi.php?a=active So how can I possibly include that page (ssi.php?a=active) on any of my pages??? From: Dennis Sterzenbach [EMAIL PROTECTED] Reply-To: Dennis Sterzenbach [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: [PHP] Re: include() problems Date: Thu, 2 Oct 2003 15:34:26 +0200 Gustave Bernier [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi everyone, I'm new to PHP and I'm trying to use the include function but with no success... My server's ini file is set as (allow_url_fopen, 0) so I'm having some trouble to pass different values for the php file I'm calling. The address is: http://mydomain.com/forums/ssi.php?a=active The code I'm trying now is: $_GET['a'] = 'active'; include('forums/ssi.php'); When I use this code I have no error, ssi.php is loaded but nothing is done (I believe the a value isn't passed to ssi.php) and the page where the include is stops loading just after the include(). You don't pass the value to that file, you simply tell the preprocessor of PHP to copy the contents of forums/ssi.php file into the source code before executing the script. You do NOT call the ssi.php by that! As you are stating you want to call http://mydomain.com/forums/ssi.php?a=active why are you including the file in there? The statement about allow_url_fopen, 0 setting controls access to remote-resources, so if you are allowed to do something like fopen(http://...;) or include(http://..;). Thus it doesn't have anything to do with your include. -- Dennis Sterzenbach www.darknoise.de -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ MSN Messenger: instale grátis e converse com seus amigos. http://messenger.msn.com.br -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include() problems
I'm trying to include that file because in my index page because it has many functions I need to use in other pages... I'm on ADDR.com servers and I can't set allow_url_fopen to 1 (it sucks!). In ssi.php functions are called by accessing this address: http://mydomain.com/forums/ssi.php?a=active So how can I possibly include that page (ssi.php?a=active) on any of my pages??? In my oppinion, if these files you need the include for aren't on the same server as mydomain.com or even cannot access the root where mydomain.com got placed (like they cannot do an include by include '/home/web/com/mydomain/forums/ssi.php'), you will never have any chance of doing so. Due to allow_url_fopen being disabled, you cannot include files from remote. But just to be sure we're talking about the same problem: You try to get the SOURCE CODE of the script http://mydomain.com/forums/ssi.php?a=active to use it as part of another, say http://mydomain.co.uk/forum.php ? If you are talking about including it in http://mydomain.com/forum.php , simply adjust the forum.php code to have : ?php ... $a = $_GET['a']; include 'forums/ssi.php'; ... ? Regards Dennis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include help please
nope, it doesn't work. it'll only call up the variables that were specified in my files.inc.php...well so far at least Curt Zirzow [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] * Thus wrote LoonySalmon ([EMAIL PROTECTED]): i want to call up my contact page, but how do i do it? http://localhost/index.php?page=$contact I hope you cant use something like: http://localhost/index.php?page=%2Fetc%2Fpasswd Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: include help please
-Original Message- From: Jennifer Goodie [mailto:[EMAIL PROTECTED] Sent: 31 July 2003 22:42 if (isset($page)) { include $$_GET['page']; } else { $page = $home; include $page; } would that be right? or should i use if (isset($page)) { include $$_GET['page']; } else { include $home; } hopefully that's right. if so, pretty good for a n00b I don't think I'd let someone pass any page they wanted via a get and just include that page. If you have URL fopen wrappers on I can create a page on my server and include it to your page and pretty much execute any code I want on your server. example: http://www.yourdomain.com?yourscript.php?page=http://mydomain. com/myscript.p hp Take a closer look -- that's a double $$ in front of _GET['page'], not a single one -- that means he must have a variable defined with the name of whatever you put as the value of page=, and I think he's very unlikely to have a $http://mydomain.com/myscript.php...!! But, you're right, there should be some error checking for invalid page values, just in case someone (or something!) should try this -- something like (not tested!): if (isset($_GET['page'])) { if (isset($$_GET['page'])) include $$_GET['page']; else include('no_such_page.inc'); } else { include $home; } And, as a final BTW, I'd do this with an array: $pages = array('fred'='fred.php', 'barney'='barney.php', 'rubble'='quarry/mr_rubble.inc'); -- if (isset($_GET['page'])) { if (isset($pages[$_GET['page']])) include $pages[$_GET['page']]; else include('no_such_page.inc'); } else { include $home; } Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include() as last thing to execute on page
My apologies - I just double posted this question ... Dougd [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have a PHP included page that takes quite a time to load. I would like to have the entire main page loaded and displayed and then the final include page executed. Is this possible? Thanks for your help - appreciate it. -Doug -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include help please
thanks everybody now it works Loonysalmon [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] i am looking to use includes on my page, this is the code that i want to use to call my files with: INDEX.PHP ?php require 'files.inc.php'; $page = '$home'; include '$page'; ? FILES.INC.PHP ?php $home = 'home.html'; $forum = 'forum/index.php'; $contact = 'contact.html'; ? I try to load up index.php and this is what i get Warning: main($page) [function.main]: failed to create stream: No such file or directory in C:\swamp\www\site\index.php on line 109 Warning: main() [function.main]: Failed opening '$page' for inclusion (include_path='.;c:\swamp\php\includes;C:\swamp\www') in C:\swamp\www\site\index.php on line 109 the problem must be when i am trying to include the $page variable could somebody please help me? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include help please
I think you want ?php $home = 'home.html'; $forum = 'forum/index.php'; $contact = 'contact.html'; include $contact; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include help please
lol, yet again i need some more help as you guys can see from the scripts before, i am including a file into a page. now my only problem is trying to include a different file. what i have INDEX.PHP ?php require 'files.inc.php'; $page = $home; include $page; ? FILES.INC.PHP ?php $home = 'home.html'; $forum = 'forum/index.php'; $contact = 'contact.html'; ? i want to call up my contact page, but how do i do it? http://localhost/index.php?page=$contact or how would i do that? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include help please
--- LoonySalmon [EMAIL PROTECTED] wrote: INDEX.PHP ?php require 'files.inc.php'; $page = $home; include $page; ? FILES.INC.PHP ?php $home = 'home.html'; $forum = 'forum/index.php'; $contact = 'contact.html'; ? http://localhost/index.php?page=$contact http://localhost/index.php?page=contact.html And get rid of your hard-coded set for $contact, and use $_GET['contact'] instead. Hope that helps. Chris = Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include help please
http://localhost/index.php?page=contact.html And get rid of your hard-coded set for $contact, and use $_GET['contact'] instead. My apologies. I meant $_GET['page']. Chris = Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include help please
that isn't really what i want i want to have a seperate file where i declare the variables. what i'm getting at here is this, well, take a look at this page: http://l33trus.servebeer.com/site/index.php i just want to include a page into the table where it says that it's included what i'm going for here is to choose the page i want in that space by defining it in the url, such as http://l33trus.servebeer.com/site/index.php?page=contact but how would i do that? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include help please
LoonySalmon wrote: that isn't really what i want i want to have a seperate file where i declare the variables. what i'm getting at here is this, well, take a look at this page: http://l33trus.servebeer.com/site/index.php i just want to include a page into the table where it says that it's included what i'm going for here is to choose the page i want in that space by defining it in the url, such as http://l33trus.servebeer.com/site/index.php?page=contact but how would i do that? Based on the code posted before I think you should be able to do: include $$_GET['page']; - Brad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include help please
ok i have that done, but now i can't just have index.php because i get an error is there anyway where i can check if page is defined in the url? if so, could somebody make me a simple script? this is my first time with php i'm guessing that it would be something like this, but summed up if page is defined in url, include page defined else include home that's what i'm thinking, but i'm not sure how to do it -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include help please
LoonySalmon wrote: if page is defined in url, include page defined else include home You are on the right track. Take a look at the manual. http://us4.php.net/manual/en/index.php http://us4.php.net/isset - Brad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include help please
if (isset($page)) { include $$_GET['page']; } else { $page = $home; include $page; } would that be right? or should i use if (isset($page)) { include $$_GET['page']; } else { include $home; } hopefully that's right. if so, pretty good for a n00b -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include help please
snip is there anyway where i can check if page is defined in the url? /snip not sure I know exactly what you mean but I think you could use something like this $foo = @include(index.php); if ($foo) { //index.php was valid } else { //index.php was not valid } there also might be a better way to do this. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include help please
for some odd reason, $home wasn't working, so i changed home to main and now it works thanks for all the good support guys/gals? L00NY54LM0N - 16 year old coder in the makin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: include help please
if (isset($page)) { include $$_GET['page']; } else { $page = $home; include $page; } would that be right? or should i use if (isset($page)) { include $$_GET['page']; } else { include $home; } hopefully that's right. if so, pretty good for a n00b I don't think I'd let someone pass any page they wanted via a get and just include that page. If you have URL fopen wrappers on I can create a page on my server and include it to your page and pretty much execute any code I want on your server. example: http://www.yourdomain.com?yourscript.php?page=http://mydomain.com/myscript.p hp Now my code is included in your page and executed. Do you really trust me to only have nice code in my page? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include help please
Jennifer Goodie wrote: I don't think I'd let someone pass any page they wanted via a get and just include that page. If you have URL fopen wrappers on I can create a page on my server and include it to your page and pretty much execute any code I want on your server. example: http://www.yourdomain.com?yourscript.php?page=http://mydomain.com/myscript.p hp Now my code is included in your page and executed. Do you really trust me to only have nice code in my page? This is a very good point. Definitely make sure you know what you are including. If you are predefining the names of the files to be included and then using $_GET['page'] to pass the name of the variable (which was being done in files.inc.php), you have control over the files that are included. Nevertheless, be careful. If you have register_globals on I am not sure what would happen if you had: http://yousite.com/index.php?page=homehome=http://othersite.com/bad.php Although I think you would still be ok. - Brad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include help please
well crap, it turns out that i'm back to step 1, but with more code it won't load up the other files now when defined through the url. i guess that there is something wrong, but what could it be? Loonysalmon [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] if (isset($page)) { include $$_GET['page']; } else { $page = $home; include $page; } would that be right? or should i use if (isset($page)) { include $$_GET['page']; } else { include $home; } hopefully that's right. if so, pretty good for a n00b -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include help please
and btw, this is my code now: ?php require 'files.inc.php'; if (isset($page)) { include $$_GET['page']; } else { $page = $main; include $page; } ? Loonysalmon [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] well crap, it turns out that i'm back to step 1, but with more code it won't load up the other files now when defined through the url. i guess that there is something wrong, but what could it be? Loonysalmon [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] if (isset($page)) { include $$_GET['page']; } else { $page = $home; include $page; } would that be right? or should i use if (isset($page)) { include $$_GET['page']; } else { include $home; } hopefully that's right. if so, pretty good for a n00b -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include help please
On Aug 1, 2003, LoonySalmon claimed that: |and btw, this is my code now: | |?php |require 'files.inc.php'; | |if (isset($page)) { |include $$_GET['page']; |} else { |$page = $main; |include $page; |} |? -- Is $main being set inside a function? http://www.php.net/language.variables.scope Also, for future compatability, you should probably change the 3rd line to if (isset($_GET['page'])) { That will also help incase files.inc.php is inadvertently setting varables incorrectly. Jeff -- Registered Linux user #304026. lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import Key fingerprint = 52FC 20BD 025A 8C13 5FC6 68C6 9CF9 46C2 B089 0FED Responses to this message should conform to RFC 1855. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include help please
thanks jeff harris, that is exactly what my problem was, now it works good night all thank a million Jeff Harris [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Aug 1, 2003, LoonySalmon claimed that: |and btw, this is my code now: | |?php |require 'files.inc.php'; | |if (isset($page)) { |include $$_GET['page']; |} else { |$page = $main; |include $page; |} |? -- Is $main being set inside a function? http://www.php.net/language.variables.scope Also, for future compatability, you should probably change the 3rd line to if (isset($_GET['page'])) { That will also help incase files.inc.php is inadvertently setting varables incorrectly. Jeff -- Registered Linux user #304026. lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import Key fingerprint = 52FC 20BD 025A 8C13 5FC6 68C6 9CF9 46C2 B089 0FED Responses to this message should conform to RFC 1855. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include help please
* Thus wrote LoonySalmon ([EMAIL PROTECTED]): i want to call up my contact page, but how do i do it? http://localhost/index.php?page=$contact I hope you cant use something like: http://localhost/index.php?page=%2Fetc%2Fpasswd Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include and imagejpg() weird behavior - maybe header?
Nobe, the image.php script starts with ? as the absolute first characters. Also if I comment out the header function I don't get the header error but I get the gobbledygook (the picture data I guess). Combine the code in one script and all is fine, with or without the header function. Oli Rob Adams [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Oli [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have a function that resizes images. If I put it in the same php file that calles it it workes fine. Gives a nice thumbnail or whatever size I choose to display. If I however put it in a seperate file and include it and call it I get garbage and the following error: Warning: Cannot modify header information - headers already sent by (output started at /home/edal/public_html/album/image.php Here is the resize function (in file image.php): ? function resize($filepath,$nw = 50,$string = '') { header(Content-type: image/jpeg); The above line is causing your error. According to the error, it's something in your image.php file. Is there a space or carriage return before your opening php tag in image.php? -- Rob $im = imagecreatefromjpeg($filepath); $w = imagesx ($im); $h = imagesy ($im); $nh = round($h*$nw/$w,0); $newim = imagecreatetruecolor($nw,$nh); $black = imagecolorallocate($newim, 0, 0, 0); imagecopyresampled($newim,$im,0,0,0,0,$nw,$nh,$w,$h); imagestring($newim, 2, 5, 5, $string, $black); imagedestroy($im); return $newim; } ? and the calling script: ?php include 'image.php'; $image = resize('Capri.jpg',200,'Capri'); imagejpeg($image); imagedestroy($image); ? Any ideas? Oli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include and imagejpg() weird behavior - maybe header?
I copied and pasted your code into two different files, changed the image name (of course) and it worked just fine on the first try for me. You must have something being output before your header() call. If you can't find it, send me your two files and I'll try running them on my server. -- Rob Oli [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Nobe, the image.php script starts with ? as the absolute first characters. Also if I comment out the header function I don't get the header error but I get the gobbledygook (the picture data I guess). Combine the code in one script and all is fine, with or without the header function. Oli Rob Adams [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Oli [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have a function that resizes images. If I put it in the same php file that calles it it workes fine. Gives a nice thumbnail or whatever size I choose to display. If I however put it in a seperate file and include it and call it I get garbage and the following error: Warning: Cannot modify header information - headers already sent by (output started at /home/edal/public_html/album/image.php Here is the resize function (in file image.php): ? function resize($filepath,$nw = 50,$string = '') { header(Content-type: image/jpeg); The above line is causing your error. According to the error, it's something in your image.php file. Is there a space or carriage return before your opening php tag in image.php? -- Rob $im = imagecreatefromjpeg($filepath); $w = imagesx ($im); $h = imagesy ($im); $nh = round($h*$nw/$w,0); $newim = imagecreatetruecolor($nw,$nh); $black = imagecolorallocate($newim, 0, 0, 0); imagecopyresampled($newim,$im,0,0,0,0,$nw,$nh,$w,$h); imagestring($newim, 2, 5, 5, $string, $black); imagedestroy($im); return $newim; } ? and the calling script: ?php include 'image.php'; $image = resize('Capri.jpg',200,'Capri'); imagejpeg($image); imagedestroy($image); ? Any ideas? Oli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include and imagejpg() weird behavior - maybe header?
Oli [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have a function that resizes images. If I put it in the same php file that calles it it workes fine. Gives a nice thumbnail or whatever size I choose to display. If I however put it in a seperate file and include it and call it I get garbage and the following error: Warning: Cannot modify header information - headers already sent by (output started at /home/edal/public_html/album/image.php Here is the resize function (in file image.php): ? function resize($filepath,$nw = 50,$string = '') { header(Content-type: image/jpeg); The above line is causing your error. According to the error, it's something in your image.php file. Is there a space or carriage return before your opening php tag in image.php? -- Rob $im = imagecreatefromjpeg($filepath); $w = imagesx ($im); $h = imagesy ($im); $nh = round($h*$nw/$w,0); $newim = imagecreatetruecolor($nw,$nh); $black = imagecolorallocate($newim, 0, 0, 0); imagecopyresampled($newim,$im,0,0,0,0,$nw,$nh,$w,$h); imagestring($newim, 2, 5, 5, $string, $black); imagedestroy($im); return $newim; } ? and the calling script: ?php include 'image.php'; $image = resize('Capri.jpg',200,'Capri'); imagejpeg($image); imagedestroy($image); ? Any ideas? Oli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include statement giving me hives! - help
On Thursday 17 July 2003 06:25, DougD wrote: when you call your script, is $point defined somewhere ? if $point is empty, you'll get an empty string for $links_include and include $links_include will not work. yes, I should have mentioned: $point is defined in the URL string http://something.com/index.html?point=12 That's not the point (pun intended). Is $point empty (YES/NO)? Or does it contain what you expect it to contain? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* But you shall not escape my iambics. -- Gaius Valerius Catullus */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include statement giving me hives! - help
Hi, when you call your script, is $point defined somewhere ? if $point is empty, you'll get an empty string for $links_include and include $links_include will not work. Regards, P.E. Baroiller Dougd [EMAIL PROTECTED] a écrit dans le message de news:[EMAIL PROTECTED] I am new to all this, but here is the basic code: $link_titles = file('links/master.txt'); $links_include = $link_titles[$point]; // path to directory include $links_include; If I echo the value of $links_include just prior to the include() function it contains what I would expect it to contain and the file does exist. But I get an error: Warning: main(./main/links/topsites.php ) [function.main]: failed to create stream: No such file or directory in . on line 23 Warning: main() [function.main]: Failed opening './main/links/topsites.php ' for inclusion (include_path='.:/usr/local/lib/php') in on line 23 If I add the line: $links_include = path to intended include file; just prior to the include statement it works fine. Am I missing something? I've tried a variety of renditions of the include() statement and can't get it to react unless I 'hard code' the value of $links_include. Appreciate your help!! -Doug -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include statement giving me hives! - help
yes, I should have mentioned: $point is defined in the URL string http://something.com/index.html?point=12 Baroiller Pierre-Emmanuel [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, when you call your script, is $point defined somewhere ? if $point is empty, you'll get an empty string for $links_include and include $links_include will not work. Regards, P.E. Baroiller Dougd [EMAIL PROTECTED] a écrit dans le message de news:[EMAIL PROTECTED] I am new to all this, but here is the basic code: $link_titles = file('links/master.txt'); $links_include = $link_titles[$point]; // path to directory include $links_include; If I echo the value of $links_include just prior to the include() function it contains what I would expect it to contain and the file does exist. But I get an error: Warning: main(./main/links/topsites.php ) [function.main]: failed to create stream: No such file or directory in . on line 23 Warning: main() [function.main]: Failed opening './main/links/topsites.php ' for inclusion (include_path='.:/usr/local/lib/php') in on line 23 If I add the line: $links_include = path to intended include file; just prior to the include statement it works fine. Am I missing something? I've tried a variety of renditions of the include() statement and can't get it to react unless I 'hard code' the value of $links_include. Appreciate your help!! -Doug -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include Question
You could try this instead: Checklogin.php if (!$name || !password) { $message = $enter_info; } if ($message){ include (login.php); echo $message; exit; } But the way you had it should work, you might just need to global $message; right before the echo in login.php in case it is inside a function - Original Message - From: Beauford.2002 [EMAIL PROTECTED] Newsgroups: php.general To: PHP General [EMAIL PROTECTED] Sent: Thursday, March 27, 2003 3:47 PM Subject: Include Question Hi, First, I fixed my other problem of the stack overflow by moving the files back to the root directory (although I would rather have them in a login directory). Anyway, I have a question regarding the include function. I have a login script in a file called login.php - in this file it includes checklogin.php and loginerrors.php. If the user inputs an incorrect login I assign $messages the appropriate error from loginerrors, then I re-include login.php where I want to show the error message, but no matter what I do the error message will not show up. Example. Login.php Enter your Name: Enter Your Password: if ($message) { echo $message; } Checklogin.php if (!$name || !password) { $message = $enter_info; include (login.php); exit; } Any help is appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Include Question
Guys I would say looping include()'s is just a bad idea all together. It can get you into some gritty situations. For example it would be very easy to end in an infinte loop, or overwrite variables, or just confuse the heck out of the PHP parser. I recommend you do a header() redirect rather than include() at the end of the script. Just my opinion. - Kevin - Original Message - From: Tim Burden [EMAIL PROTECTED] To: Beauford.2002 [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, March 28, 2003 1:36 PM Subject: [PHP] Re: Include Question You could try this instead: Checklogin.php if (!$name || !password) { $message = $enter_info; } if ($message){ include (login.php); echo $message; exit; } But the way you had it should work, you might just need to global $message; right before the echo in login.php in case it is inside a function - Original Message - From: Beauford.2002 [EMAIL PROTECTED] Newsgroups: php.general To: PHP General [EMAIL PROTECTED] Sent: Thursday, March 27, 2003 3:47 PM Subject: Include Question Hi, First, I fixed my other problem of the stack overflow by moving the files back to the root directory (although I would rather have them in a login directory). Anyway, I have a question regarding the include function. I have a login script in a file called login.php - in this file it includes checklogin.php and loginerrors.php. If the user inputs an incorrect login I assign $messages the appropriate error from loginerrors, then I re-include login.php where I want to show the error message, but no matter what I do the error message will not show up. Example. Login.php Enter your Name: Enter Your Password: if ($message) { echo $message; } Checklogin.php if (!$name || !password) { $message = $enter_info; include (login.php); exit; } Any help is appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include directoive on PHP.
Edit php.ini and add the pear directory to your include_path or use ini_set to set your include_path in your script: http://www.php.net/manual/en/function.ini-set.php Justin Garrett Harring Figueiredo [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I would like to include some of the files ( tabel.php, etc ) from PEAR on my scripts - Do I have to hardcode the installation path ? or is there a directive that tells the preprocessor to look on the right place (Like in c)? Thanks in advance. HArring __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include/require vs performance
Radek Zajkowski [EMAIL PROTECTED] schreef in bericht news:[EMAIL PROTECTED]... Is there, was there ever issue around including a lot files via include(). I am running things on a local server so it's hard to gauge. I think that the only source that could cause any problems with too many files included will be your operating system (since that thing has certain limitations on a max number of locked files for example) . Other than that, I don't think so. I myself include about 15 files on certain pages. But it is easy to make a test or anything... Just make a PHP script that generates like 1000 php scripts called include.test.x.php , where x is is a number, then the contents of those scripts should by ? include(include.test. . (x+1) . .php);? or something like that... Then you are for sure, and you immediately also know how much performance is lost for including 1000 files :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include/require vs performance
I guess that PHP will close file 1 before it opens file 2 and so on.. For example : include 'foo'; include 'bar'; When bar is being opened foo is already closed. Leon Mergen wrote: Radek Zajkowski [EMAIL PROTECTED] schreef in bericht news:[EMAIL PROTECTED]... Is there, was there ever issue around including a lot files via include(). I am running things on a local server so it's hard to gauge. I think that the only source that could cause any problems with too many files included will be your operating system (since that thing has certain limitations on a max number of locked files for example) . Other than that, I don't think so. I myself include about 15 files on certain pages. But it is easy to make a test or anything... Just make a PHP script that generates like 1000 php scripts called include.test.x.php , where x is is a number, then the contents of those scripts should by ? include(include.test. . (x+1) . .php);? or something like that... Then you are for sure, and you immediately also know how much performance is lost for including 1000 files :) -- I won't pay Bills' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include/require vs performance
Stephan Seidt [EMAIL PROTECTED] schreef in bericht [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I guess that PHP will close file 1 before it opens file 2 and so on.. For example : include 'foo'; include 'bar'; When bar is being opened foo is already closed. Hmmm, i think the parser is built recursive, so at the moment it sees an include 'foo'; , it will look in foo, parse that one, and after it has finished foo, it will continue with the main script... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: include/require vs performance
well ok, if it's : main.php : include 'foo'; foo : include 'bar'; bar : include 'whatever'; ... there will be lots of used file descriptors at once Leon Mergen wrote: Stephan Seidt [EMAIL PROTECTED] schreef in bericht [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I guess that PHP will close file 1 before it opens file 2 and so on.. For example : include 'foo'; include 'bar'; When bar is being opened foo is already closed. Hmmm, i think the parser is built recursive, so at the moment it sees an include 'foo'; , it will look in foo, parse that one, and after it has finished foo, it will continue with the main script... -- I won't pay Bills' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include
To my knowledge you can include as many files as you want. If by commenting out the clean() function, I'd say you have a syntax error in that function and you're just not seeing the error message. Turn on full error reporting and see what happens. -philip On Thu, 3 Oct 2002, Matias Silva wrote: This might sound like a dumb question but I just need verification so that I can convince myself that I'm going insane! I have this error in which I include 3 files (common_html.inc, common_db.inc, common_functions.inc) well I have a clean() function in the common_functions.inc file. But it seems that it is not getting called and then my script crashes. If I comment out the clean() function then it works. The clean() function is just for added security. Is there a maximum number of times you can include different files? -Matias -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE : include interpreted php file
hi, thanks for your help again. i've noticed that file function have two different behaviors. i tested file function with the url and it seems that the file is interpreted. But i tried the code u give me and without the http://myurl.com/; at the beginning, a warning is raised : Warning: file(test.php?foo=test) - Invalid argument in c:\program files\easyphp\www\un.php on line 10 otherwise, without the http string, it reads the file as text file and print exactly his content. You Timo Stamm [EMAIL PROTECTED] a écrit dans le message de news: [EMAIL PROTECTED] @all: I just noticed that I was not replying to the list, but to the posting email adresses. I just switched to another email client and was not aware of this. My apologies :-( --- You, could it be that you want to do the following?: ?php // primary php $foo = $_REQUEST[foo] // I guess you want to do something with $foo here. $outputfromsecondaryphp = file(secondary.php?foo=.$foo) echo implode('', $outputfromsecondaryphp); ? Am Dienstag den, 3. September 2002, um 00:15, schrieb you: Thanks for ur help and i'm sorry to have a so bad english I guess my french is worse than your english :-) Timo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE : include interpreted php file
all: I just noticed that I was not replying to the list, but to the posting email adresses. I just switched to another email client and was not aware of this. My apologies :-( --- You, could it be that you want to do the following?: ?php // primary php $foo = $_REQUEST[foo] // I guess you want to do something with $foo here. $outputfromsecondaryphp = file(secondary.php?foo=.$foo) echo implode('', $outputfromsecondaryphp); ? Am Dienstag den, 3. September 2002, um 00:15, schrieb you: Thanks for ur help and i'm sorry to have a so bad english I guess my french is worse than your english :-) Timo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RE : [PHP] RE : include interpreted php file
nope sorry... -Message d'origine- De : Chris Knipe [mailto:[EMAIL PROTECTED]] Envoyé : samedi 31 août 2002 20:10 À : you; 'Richard Lynch' Cc : [EMAIL PROTECTED] Objet : Re: [PHP] RE : include interpreted php file fopen() Regards, Chris Knipe Cell: (072) 434-7582 MegaLAN Corporate Networking Services /--- | This email is confidential and may contain legally privileged information. | If you are not the intended recipient, you must not disclose or use | the information contained in it. If you have received this email in error, | please notify us immediately by return email and delete the document. \--- - Original Message - From: you [EMAIL PROTECTED] To: 'Richard Lynch' [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Saturday, August 31, 2002 7:44 PM Subject: [PHP] RE : include interpreted php file Hi, Thanks for u help. But i just wanna include a php file in an other. But the included file must be interpreted before including it. Thx kciop -Message d'origine- De : Richard Lynch [mailto:[EMAIL PROTECTED]] Envoyé : samedi 31 août 2002 02:12 À : you Cc : [EMAIL PROTECTED] Objet : Re: include interpreted php file pb : include a php file in an other php file contraints : the php file must be interpreted before being included solution known : fsock then get the html code from the server and include it... Is there an other solution (easier) to include that file? Not real sure if you *want* the PHP file interpreted or not, but if not, try this: ?php $html = file(http://example.com/whatever.htm;) or die(Could not load remote HTML); echo implode('', $html); ? You may (or may not) also want to use http://php.net/htmlentities to show the actual HTML source instead of making it a part of your web design layout HTML... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RE : include interpreted php file
Hi, Thanks for u help. But i just wanna include a php file in an other. But the included file must be interpreted before including it. Thx kciop -Message d'origine- De : Richard Lynch [mailto:[EMAIL PROTECTED]] Envoyé : samedi 31 août 2002 02:12 À : you Cc : [EMAIL PROTECTED] Objet : Re: include interpreted php file pb : include a php file in an other php file contraints : the php file must be interpreted before being included solution known : fsock then get the html code from the server and include it... Is there an other solution (easier) to include that file? Not real sure if you *want* the PHP file interpreted or not, but if not, try this: ?php $html = file(http://example.com/whatever.htm;) or die(Could not load remote HTML); echo implode('', $html); ? You may (or may not) also want to use http://php.net/htmlentities to show the actual HTML source instead of making it a part of your web design layout HTML... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE : include interpreted php file
fopen() Regards, Chris Knipe Cell: (072) 434-7582 MegaLAN Corporate Networking Services /--- | This email is confidential and may contain legally privileged information. | If you are not the intended recipient, you must not disclose or use | the information contained in it. If you have received this email in error, | please notify us immediately by return email and delete the document. \--- - Original Message - From: you [EMAIL PROTECTED] To: 'Richard Lynch' [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Saturday, August 31, 2002 7:44 PM Subject: [PHP] RE : include interpreted php file Hi, Thanks for u help. But i just wanna include a php file in an other. But the included file must be interpreted before including it. Thx kciop -Message d'origine- De : Richard Lynch [mailto:[EMAIL PROTECTED]] Envoyé : samedi 31 août 2002 02:12 À : you Cc : [EMAIL PROTECTED] Objet : Re: include interpreted php file pb : include a php file in an other php file contraints : the php file must be interpreted before being included solution known : fsock then get the html code from the server and include it... Is there an other solution (easier) to include that file? Not real sure if you *want* the PHP file interpreted or not, but if not, try this: ?php $html = file(http://example.com/whatever.htm;) or die(Could not load remote HTML); echo implode('', $html); ? You may (or may not) also want to use http://php.net/htmlentities to show the actual HTML source instead of making it a part of your web design layout HTML... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include interpreted php file
pb : include a php file in an other php file contraints : the php file must be interpreted before being included solution known : fsock then get the html code from the server and include it... Is there an other solution (easier) to include that file? Not real sure if you *want* the PHP file interpreted or not, but if not, try this: ?php $html = file(http://example.com/whatever.htm;) or die(Could not load remote HTML); echo implode('', $html); ? You may (or may not) also want to use http://php.net/htmlentities to show the actual HTML source instead of making it a part of your web design layout HTML... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include php code as variable
In article 00d501c23ada$87050590$3404a8c0@alawi, [EMAIL PROTECTED] (Alawi) wrote: How can I Include my php code code as variable and excute it ? include() can return a value, assignable to a variable. Some other ways to get the content of a file (I assume that's why you're saying include) into a variable: file(), fread(). eval() can execute the value of a variable as PHP code. http://php.net/include http://php.net/file http://php.net/fread http://php.net/eval -- CC -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include problems
try using the absolute path to the file e.g. include(C:/windows/webserver/httproot/inc/test.inc); Scott [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I have PHP4 on both a windows IIS server and a windows apache server. The include function only works in the same directory of the file I wish to access. ex. www.include.com/default.php all files in same directory (i guess the root)? ?php include 'test.inc' ? everything works fine. Here's where I have the problem. Now I want to store all my includes in one directory www.include.com/inc ?php include 'inc/test.inc' ? that doesn't work Warning: Failed opening 'test.inc' for inclusion (include_path='') Can anyone help me with this??? Thanks scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include()
How ever can ant of the apache restrictions stop any one from including the script by giving the whole path. ie /home/htdocs/include.inc or /home/abc/include.inc Yes or No ? I use win 2000 so it is not possible for me to experiment! but I have hostings on servers like www.f2s.net and a project on www.sourceforge.net If you are familiar with these systems, what do you comment? Lord Loh. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include files and global variables
Hmm. Here's how you can make it load EVERYtime the file is included, plain and simply. In the include file, create the function.and the call it after you've made it. To get the other function to work, you might want to try placing the function ABOVE checkMaster(); (you should probably simply put that in the same file, but above it). functions.php ? function myfunction () {} myfunction(); ? I have the feeling that the problem with the session variable is that you're calling it before anything has been done to define it in the main page, so it is null when you check it. Try debugging it with echo statements here and there that call out variables so that you know they're defined correctly. Also, turn on error_reporting(E_ALL); (you can simply call it at the top of the page--first thing). That will tell you when variables are used if they're null and other errors that aren't fatal, but might cause problems. Jon Wyatt [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I have some pages which include a number of files. In one of the include files I have a function which I wish to be executed everytime the include file is loaded. Therefore I place the function name in the include file at the top. However, this function uses a session variable to decide whether to call another function and it appears that this variable is not being carried across. For example, the start of the include file might look like this:- ?php checkMaster(); function checkMaster() { global $master_session; if ($master_session[db_host]) { connectToDB(); } } function connectToDB() { ... The master_session variable is not set and hence connectToDB is never called. If I place the checkMaster code in each page that includes this file then it all works fine. How do I get round this? Thanks. jon. Better than having your body rubbed vigorously with a cheese grater. http://www.samuri.co.uk. _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php