Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Function Not Running Right From Another Folder


i have my php files in folders, in the top directory, "patterns" I have a file "index.php" that needs access to a file in the sub folder "model".
so structure is patterns/model

so from the file in patterns i use
include_once("model/preview_post.php");

which should access the file and it does, i can write an simple echo at the top, and it pops out, however when i call a function it stops half way through and doesn't echo anything out after a certain point.
Now you might think this is just a bug in the function but calling the function from inside this file results in the correct output and even moving "index.php" model folder results in the function completing. but moving it out of the folder stops the function running correctly.

so to clarify when the function is called from inside itself it runs, when its called from another file which is in the same folder it runs, but when its called from another file in another folder it doesn't run the whole way through.

Any ideas? i do realize this has been very generalized.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Determine Folder A Script Is Running In.
What is the most reliable method to determine the folder a script is running in? I was looking at the globals in $_SERVER but all the variables also listed the actual file the script was running in.

Running Php Function AFTER Page Is Delivered
One of my websites is composed of all static pages.

I've got a php include that I have inserted at the end of the pages to do tracking and other housekeeping, but it doesn't output anything to the page itself.

Unfortunately this still forces me to put all the pages through the php interpretor.

Is there any clever way I can use apache (possibly a module in htaccess?) to simply execute the php script AFTER any html page is delivered to a user, therefore keeping their access speedy and a side benefit of truly keeping the pages static, complete with etags, content-length and "last modified"?

What Function To Use To Create A Folder ?
What function to use to create a folder ?

Folder Contents Function?
I'm looking for a function that puts the contents of a folder (the file names) into an array. Is there such a beast? For instance, if there is a folder off of my root called /tips/, and I want to list the files that are in it, such as tip1.txt, tip2.txt, etc.

Mail() Function Sends To Junk Folder On Hotmail
The following mail is sent in a PHP script via the mail() function whenever the user changes their password on our site. the following mail headers were taken from the recipients hotmail account...the mail is delivered to the account but is placed in the 'junk' folder even though it is not a spam email.

The mail works and is placed in the user's inbox in aol/yahoo/outlook express. I understand that this is a common problem with hotmail. How can i get around this problem so that we can send mail and it will be delivered to the users inbox in hotmail? Code:

Drag Files From One Folder To Another Folder (copy) .. Possible?
Is it possible to write codings PHP or Javascript.. GUI representation
of File handling (ie. Drag files from one folder to another folder (copy)
like our windows).. pls give me some reference codings like this..

Remove From $name (folder)/(folder)/[x]/ <-- If Exists To Just Get [x].
I'll be quite honest. I don't have the faintest idea
how to do this, while I can do other php without a problem. Once I
know how to go about it I'll be okay.
It's two things I think?
1. see if there's a trailing slash and delete it.
2. Remove the preceding path to /x, the folders and slashes, and
delete them.
and then I have x.

X by the way is the final folder in a website and this grabs it for
me.

<?
$name = $REQUEST_URI;
?>

Php Is Not Running
I am using CentOS 4. When requesting /blah.php from a browser, I always get blank page "<html><body></body></html>". What's wrong?

#rpm -qa php
php-4.3.9-3.8

# /usr/sbin/httpd -V
Server version: Apache/2.0.52
Server built: Jul 25 2005 05:37:19
Server's Module Magic Number: 20020903:9
Architecture: 32-bit
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"

How Do I Know That PHP Is Running
I'm having a problem running a simple printer friendly script written in
PHP. I'm not sure whether the problem is with apache 1.3 or with the
scripts. I updated apache's config file httpd.conf to include the
directives for running PHP as a loaded module and as CGI as noted in the
documentation at php.net

# Add to the end of the LoadModule section
LoadModule php4_module "c:/php/sapi/php4apache.dll"

# Add to the end of the AddModule section
AddModule mod_php4.c

I did both and Apache doesn't like it. It can't compile it. It says that
the php4apache.dll cannot be loaded because it cannot be found.

I have adjusted the windows directory conventions to include forward
slashes and such but no luck.

I'm running XP with IIS off (naturally of course) and apache 1.3. Apache
works nicely on the XP. But I can't seem to get a simple php file to
work. Where do you think is the problem?

Running PGP
Hi, I'm trying to run the PGP thourgh the PHP, I'm useing this:
passthru("/usr/pgp-6.5.8/pgp -kv");

what it displays is that it can't find the key files. And it is because pgp sets up the keys per user but PHP runs as Nobody (I think).

Running PHP Via CLI
I made a php script with a HTML form (POST) which takes many options
and based on the options, it connects to a database file and create
some files from the results. This works fine when using a browser.
Now, I am being asked if it can run via CLI. My first reaction was
"no", but that was before I even had looked into the matter....

Running Background Job...
Is it possible to get a php3 script to check what day it is, and then do some stuff, If it’s let’s say Monday?
This without you doing anything. Like a background - or cronjob…
I guess you would use perl or something to do this, but that is not an option I have.

Running PHP As CGI On Apache
I'm having what you could call a bad day, now I'm not an experienced user of PHP but I know enough to install scripts and get them looking how i want them to.

I'm trying to install Gallery 1.2.5, unfortunatly my new virtual host runs PHP in safe mode which renders the script useless, after reading their FAQ I found that i can run PHP as CGI and place the script in there.

Now I have a problem I cannot compile this on the server as i don't have the permissions or access to do so, is there anywher i can get a pre-compiled version of php.cgi with newbie type instructions?

Cron Running PHP
what would a cron command look like that runs a specific PHP script every hour?

Running PHP On A Pocket PC?
I have a long, boring train ride in the morning to work.

Is there anyway to get PHP to run on my Pocket PC without being connected to the internet?

I wasn't sure if there was a mini webserver type app out there. I haven't been able to find anything. I'd like to mess around and code during that time.

Advice On Running PHP As A DSO, CGI, Or Both...
I am currently running Apache 1.3.27 under darwin (Mac OSX 10.2.6 BSD kernal), with PHP 4.30 as a DSO module.

I recently discovered I need to run some PHP scripts outside of the Web server as batch jobs by utilizing CRON since their execution time would typically time-out a Web session.

My question is three part:

1) Is there any difference in PHP running as a DSO vs. a CGI under Apache? Meaning, is there any difference in performance, features, access to databases, etc.
2) Should I run PHP as a CGI instead of DSO? Would this allow me to run my scripts under Apache without modification AND allow me to run PHP as a stand-alone language for command-line and CRON scheduled execution, etc.
3) If there is a performance difference with PHP as a DSO versus CGI can both be run on the same machine without conflict?

Running SCP Command
Is it possible for me to use PHP to run SCP? I know that I can use exec() or system() or shell_exec() to run a command, but when running SCP you have to run the command, and then enter a password, so is it possible to do that? If so, how would I do it?

Running PHP From A Different Server.
Hopefully my question can be easily resolved. I need to design an
autoresponder script in PHP for a organization that I am leading. My
issue is that the server where my page must reside on uses Lotus and I
am completely unfamiliar with that system. Is it possible for me to
execute a PHP script from another server? I could use server access
that I have on a PHP-friendly server to run this script if that is the
case.

Problems Running PHP As CGI
I have PHP Version 4.3.9 on my local machine I have till date no problems running many different application Today I was trying to run net2ftp from www.net2ftp.com
This errors out stating:
---
Security Alert! The PHP CGI cannot be accessed directly.
This PHP CGI binary was compiled with force-cgi-redirect enabled. This means
that a page will only be served up if the REDIRECT_STATUS CGI variable is
set, e.g. via an Apache Action directive
----
I did try to set the redirect_status cgi variable and now I get this the page gets redirected to http://localhost/php4/php.exe And I can see the whole .exe in binary format in the FF browser with heading with errors as This program cannot be run in DOS mode.
...and at the bottom of the page...same errror again...

This PHP CGI binary was compiled with force-cgi-redirect enabled. This means that a page will only be served up if the REDIRECT_STATUS CGI variable is set, e.g. via an Apache Action directive Can there be any workaround apart from installing PHP 5+?

PHP Running With ASP - Any Problems?
My site currently uses PHP on an Apache Web server (running LINUX) and works beautifully.
I am interested in installing PHP with Microsoft IIS on another site which I understand you can do with PHP4 - 2 questions:

1) Are there any bugs/performance issues with running PHP on this type of (Microsoft) configuration?

2) If this site is currently utilising ASP as a scripting language - is there any problem with installing and running PHP concurrently?

Running PHP On A Client Only...
I was wondering if it is possible to run a PHP program on a web browser
on a local PC without having a server, such as Apache, installed
locally? I am thinking about creating an application the will configure
Linux config files based on input from webpages.

I have seen this done on the CUPS setup/admin pages: http://localhost:631/

....do these pages use php, perl or what?

Running PL/SQL Scripts From PHP
Is there a way to execute PL/SQL scripts from PHP? I have PL/SQL scripts
that utilizes the DBMS_xxx packages. Is it possible to shell out a command
that will run the PL/SQL?

Running PHP 4 & PHP 5 Together As Modules
We would like to upgrade our servers to PHP 5 and PHP 4
together as modules on the same server (not as cgi, not passing
requests to another server). I did some extensive searching on
this and we ran some tests over a year ago and did not find a
solution (other than proxy forwarding to a PHP 5 configured server).

When PHP went to version 4 from version 3, it was possible
to run both at the same time, and have users select by file
extension, i.e. .php4,.php5. It seems a naming conflict within
the code itself prevents that from working with PHP 5. Has anyone
discovered a way to do this?

We are running apache 1.3.x on RHEL 4.

Running Php On Apache
I just installed apache 1.3.11 and php3 on my linux (red hat) system. Both files were rpm. My server works but when I load a php3 file netscape displays the source of the
file in stead of the results. Whats wrong with my server? How can I configure my server so php3 files are interpreted correctly? I don't know very much about linux.

Running Php Script In Different Dir
I am on a Linux system, currently php script executes normally on this dir: /var/www/html but if I place my php scripts (the same script which executes cleanly in /var/www/html) on a different dir structure, I get an error. Does any one have any idea how to get this working?

Php Running In The Background?
In order to run a php script - do I need to access it via a browser? Is there a way to write a php script and let it run from the shell in the background?

Running Php In The Background
I am trying to run a php executable (GTK) from a browser... now exec() does the job, but the browser hangs waiting for the .exe I have just called to finish, I assume so it can 'report back' to exec(),

any ideas how I can get around this ? - I have tried backticks,passthru,system,exec - all with the same results, i.e. they all expect a returned value and sit around waiting for it. This is a windows app so /dev/null wont help & it is not a CGI with output I can dump anyway.

Variable Running When It Shouldn't
I have my site 'news-and-press.php' page with this code:

<?php 
$page_name = 'News & Press';
$page_ID = 'newsandpress';
$heading = 'News & Press';
$content = include("news-and-press2.php");
include ('template.php');
?>

When I run 'news-and-press.php' the code runs through the list of variables then it runs the include ('template.php'); (this is the page that runs the site template, it asks for the variables above).

My problem is when 'news-and-press.php' is run the $content variables' output displays before the include ('template.php'); is displayed but it is meant to run the include ('template.php'); and then call $content into the template. Code:

Running Scheldued Script
When users register on my site they must confirm their account by checking their email and clicking the link sent to them in the email, this will verify their account and then they will be able to login and start using their account. What I want to do is make a script that will delete any account in my database that is at least 7 days old, and hasn't been confirmed, no problem there, but now how can I get this script on my web host's server to run like, every hour? what are the different options I have and what is the best way?

Check To See If A Program Is Running
Is there any specific way to check to see if a certain program is up and running? Like I want something to pop up only if program ****.exe is running.

Running Scripts Without Session
When I run my scripts on a http server I can use the $_SESSION['Document_Root'] to get the dir of the scripts and stuff(I have my
local file system laid out exactly as the one on my server.

The issue is that when I run the script without using session_start I have
to set the document root manually. Now every time I switch from running
locally to a web server I have to comment out the line. Its not a big deal
but I'm wonder if I could somehow tell php to use a default document root if
a session isn't started?

Running Scripts Under User Uid
Is there a way to wrap php scripts so that they run under the uid of the user who owns the file, or the the user as defined by the "User" directive in Apache? Basically im looking to replicate the features that suexec provides for CGI apps.

Running PHP From A Remote Server
My ISP provides me with 2 servers: one for normal web hosting
(non-PHP) and a CGI server (with PHP). I create my website using
fusion 7 and upload this in its entirity to the web hosting server. If
I want to run CGI scripts, I can do so with an external link to a page
on the CGI server. The problem however is that I have to maintain two
sites and all associated links.

Ideally, I'd like everything to be in one place, but I'm not allowed
to upload my entire site to the CGI server. Alternatively then, is
there a way of calling PHP scripts on the CGI server from a non-CGI
server, without resorting to a clickable link. I can include HTML such
as <A HREF="http://cgiserver/......>php script link<A>, however this
requires the user to click on some text to run my script. I'd like to
run the script from the remote server without them clicking.

How Can I Check If A Server Is Up And Running?
Is there any way to check if a server is running and then refresh to it?
maybe something like this:

<?php
$url = "http://www.mysite.com";
if(server_status($url) == true){
header('location : $url');
}
else{
echo "Server down -- TRY AGAIN LATER";
}
?>

I was looking at php.net and i found Memcache::getStats(), but i don't know what that does...

Running PHP Code Within Another PHP Session
Is there a way you can run PHP code within another PHP session? I have a form that has some PHP code in it that I would like to protect with authentication. I have the following at the top of my code:

Running Shell Command Within Php
According to the manual for PHP, I should be able to run a shell command
within php.

I'm trying to copy some php files from one location to another one using
exec() but fail.

Code: ( text )

When Does A PHP Script Stop Running?
Suppose I create dynamic web pages with 3 functions (which call other
functions to make everything happen, but these 3 you might think of as
being the top layer):

registerSessions();
sendHtmlToBrowsers();
incrementPageViews();

Is there any chance that incrementPageViews() will be executed? Or, to
turn that question around, does anyone know a reason why it wouldn't?
Does PHP stop executing when the last of the HTML is sent to the
webbrowser (I've heard both yes and no on this newsgroup and I'm
hoping for a definitive answer).

Okay, now lets suppose that I do this (this is closer to what I
actually do):

$actionsToBeDone[] = "registerSessions";
$actionsToBeDone[] = "sendHtmlToBrowsers";
$actionsToBeDone[] = "incrementPageViews";

for ($i=0; $i < count($actionsToBeDone); $i++) {
$function = $actionsToBeDone[$i];
if ($allowed = isFunctionAllowed($function)) {
$function();
} else {
echo "<h1> Someone tried to commit a function called $function
which is not allowed";
}
}.....

Running Perl-script
i created a perl-script that returns a string and i want to run that script from php to get the value of that string for further processing.

Running As Different User And Group
It's a common problem when trying to install apps like this on hosted (virtual
host) sites, that the app wants to run as the Apache user/group. Inlcuding wrx
permissions on various directories.

The problem the web directory are normal user home directories, so the user/group
are the same as the userid.

Which leads the directories bye given "world" read/write/exicute prev. Which
seem to me a major secruity issue.

</Rant>

My question is where and how can I change the userid/group that TikiWiki expect,
starting with the inital DB conncect string.

Problem Running Curl
I'm working on a box that allegedly has curl support, but when I run a
script that access curl, I get this error:

Fatal error: Call to undefined function: curl_init() in
/usr/local/apache/htdocs/CHECK.php on line 6.


Line 6 is:
$ch = curl_init();

Now this script works fine on my development box, but not the
production environment. At first I thought PHP was not compiled with
curl support, but looking at a phpinfo shows me:

'--with-curl=shared,/usr/local'

on the box. The "box" is also a virtual "server" at a hosting
company, so I may not have a lot of lattitude in recompiling php,
etc.. Does this look like curl support is compiled in but somehow
not working, or needs a parameter in the php.ini or something?

Running A PHP Script In The Background
I'm currently working on a PHP script which is run from the bash prompt to perform various tasks. How can I get it to load itself into the background? (i.e. so the program runs, and continues to run "invisibly", but after executing the program you are returned to the bash prompt).

Running PHP From Command Line
I just installed the latest version of PHP as an Apache Module. I'm wondering, how can I now run PHP from the command line? I heard there was a way without having to reinstall PHP to do this.

Automatically Running A Script
Can anyone tell me how to run a set script which will be a mysql query at a certain time each day?

Running Php4 As Cgi Binary?
i'm experiencing problems in calling php4 functions (session management functions...) on my web host... they have compiled php3 into apache, and they provide php4 support through cgi-bin.

i thought all i had to do to use php4 was just "use it". but apparently it dint' work. it says "calling unsupported functions session_start() ....". my web host said php4.0.3pl1 is installed in /usr/bin/php4

No Mysql When Running Phpinfo.PHP?
I am a newbie and was just getting started working on a guestbook
tutorial when I got an error message upon running my PHP code:

Fatal error: Call to undefined function mysql_connect() in C:Program
FilesApache GroupApache2htdocsadd.php on line 6

So I searched the web for hours trying stuff to no avail. I think
something needs to be copied/pasted from a directory to another or
something needs to be enabled in php.INI. But what?

When I run localhost/phpinfo.PHP there is no mention of Mysql, I know
it should be in there.

I am running Windows XP pro/Apache server/PHP 5/Mysql.
Mysql works fine at the prompt, I create, delete tables and databases
at will.

One more point I do have the libMySQL.dll in C:WINDOWSSYSTEM32.

Running PHP 4 And PHP 5 Together In Vhost Environment.
We are running PHP 4 right now on our servers and would like
to give people the option of experimenting/using PHP 5 if they desire.
Our system are RedHat Linux running Apache 1.3.x -- would have really
like to run both PHP 4 and PHP 5 together as modules, but that seems
to be impossible due to name conflicts.

The only other solutions we saw were to run PHP5 as CGI (which
had drawbacks), or try running a proxy server (below). Our requirements
were that it had to support multiple virtual hosts, allow people to try
out PHP5 by just giving a file a .php5 extension, support putting an
entire site on php5 and also work regardless of relative/absolute URLs
that might be used in their code.

Here is the solution we came up with, any feedback is welcome:

We decided to run a 'back' server built with PHP 5 and
responding at a unique IP address. The vhost info on this server
would be almost identical to the main servers, except for their
virtual host names,e.g.
Main Server - www.alpha.com
Back Server - php5.alpha.com

The php5.alpha.com is also added to their dns info and
resolves to the IP address of the 'back' server. All the vhosts
on that server are NameVirtualHosts.

The DocumentRoot, etc.. would be identical.

Our main servers would have a Reverse Proxy setup so that
any request for a file ending in .php5 would be sent to the Back
server for processing. (If someone wanted their whole site to switch
to PHP 5 we would just alter the rewrite conditions to accept all php
files in their vhost block). If they wanted to experiment with
seeing what their site looks like under php 5, they could go to
http://php5.alpha.com/ -- IF they used relative URL's in all their
code, they would be consistent on 5.

On our main web servers (we do virtual hosting), we added
the following in the main area of the config file:

========================
<IfModule mod_proxy.c>
RewriteEngine On
# this condition should only match on files ending in php5 (any case)
RewriteCond %{REQUEST_FILENAME} ^(.*).php5$ [NC]
# this condition picks apart the host part of the URL, we need
# to change www.alpha.com -> php5.alpha.com
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
# this rule modifies the request and submits as proxy
RewriteRule (.*)(.php5) http://php5.%1/$1$2 [P,NC]
ProxyRequests Off

</IfModule>
=====================

In each of the vhost blocks on the main server we allow
them to inherit the rule with the following. We do have some concerns
about performance and using mod_rewrite to scan all requests, but
we will just turn on 'inherit' for the domains that want to test.

Running A Script Every Hour?
I have the value, $money which are variating depending on who the user is, but that doesn't matter now. And every hour I want it to add the value $money into a database, even if the user are logged out, the script should be runned.

(mysql_query("UPDATE users SET money='$answer'"));

Like that, but how should I do to make it run that command every hour? I use Apache / PHP
Hope you understand what I mean, if not please ask me and I'll try to explain again, cause.

Running Php On Netscape Browser
for some reason, I have a difficult time running my php script on netscape 4.7 browser. it works well on i.e but netscape for some reason messed up part of my code. anyone know why?

Running Scripts UNIX Or NT.
I have been trying to figure out why this particular script isnt working for me. I uploaded the script to my ISP provider and it works fine there. He is running Redhat/Apache/PHP4/Mysql

I am running on my test box NT4.0/Apache/PHP4/Mysql

I get the error messages below when I run the script at my test box, The script still works, but I dont get the messages when I run it from my ISP. Could my OS be the only problem?

Warning: Undefined variable: array in db/Db.php on line 49
Warning: Undefined variable: array in db/Db.php on line 49


Copyright © 2005-08 www.BigResource.com, All rights reserved