PHP require_once()

Posted on 2011-10-24
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
    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" might have some $ in fornt or something else.

    Author Comment

    Labsy -

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

    Author Comment

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

    Accepted Solution

    try replacing the script to this one

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

    Assisted Solution

    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

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now