Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


PHP require_once()

Posted on 2011-10-24
Medium Priority
Last Modified: 2012-05-12
I have a flow of forms like this:
Form A to form B to form C to form D.

Each of these forms has this at the beginning:

in form D, I call a function (subcc) which is in the ds-common.php file.  But in the error log, I get this:
Call to undefined function subcc() in form D

Can someone please explain what I'm missing?

Thanks in advance!
form D:
$error1 = subcc($_SESSION["PartnerId"],$_SESSION["PartnerName"]);
echo $error1;

function subcc(iPt, iPName) {
   echo "made it";
   return "Y";

Open in new window

Question by:kkbenj
LVL 18

Expert Comment

by:Andrej Pirman
ID: 37021878
Maybe some blank space or empty line BEFORE <?php tag is causing problems?
Or an empty line in ds-common.php in top row, which is outputed as HTML?

Is D.php in the same folder?

Do you have any PHP redirects using header() function?

Double-check your "subcc" spelling...you might have some $ in fornt or something else.

Author Comment

ID: 37021881
Labsy -

I do have one PHP redirect using header to call HTTPS.

Author Comment

ID: 37021887
     header("Location:  https://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF']);

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

LVL 11

Accepted Solution

kelvinwkw earned 1000 total points
ID: 37022170
try replacing the script to this one

function subcc(iPt, iPName) {
   echo "made it";
   return "Y";
LVL 19

Assisted Solution

xterm earned 1000 total points
ID: 37022387
I don't understand your ds-common.php.  What are the <script></script> tags for?  Are you wanting a javascript or a PHP function?

A php function would not work with:

function subcc(iPt, iPName) {

It needs to be:

function subcc($iPt, $iPName) {

And the <script></script> tags aren't necessary... if they are not present already, do what kelvinwkw suggested and surround the function with <?php and ?> tags.

Also, if you aren't using $iPt and $iPName in the function (and don't plan to) then declare the function like this:

function subcc() {

Just remember, you have to call that function with the same number of arguments that you defined it with.


Author Closing Comment

ID: 37023509
But of course!

xterm - thank you for the explanations.  I am planning to use the variables in the script but stripped it down for testing to eliminate other possible errors.

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question