Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7011387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:07:14+00:00 2026-05-27T22:07:14+00:00

Im getting an strange result with this particular code. Let me explain my self

  • 0

Im getting an strange result with this particular code. Let me explain my self in short way because is a long code. Basically the hole thing works like this:

In the beginning of my script I call my class fg_membersite and some constants:

require_once("registration/include/membersite_config.php");

After that, I check some POST variables, if the code detects something wrong immediately calls the function the_error() (located on the same script). If there is no error, there is no call to the function and the execution goes.

An example of checking:

$result=mysql_query("SELECT id FROM ".table_links." WHERE url = '".$fgmembersite->SanitizeForSQL($_POST['j_title'])."';");
if (mysql_num_rows($result)>0) {
the_error('The url '. siteurl .'/'. $_POST['j_title'].' is currently in use, please use another one.');
}

After a series of POST and SQL checks there is the final part when I save to the database and print the result message:

$fgmembersite->DBLogin();
mysql_query("INSERT INTO " . table_links . " (id, usr_code, visits, url, datetime, type, description, secu_type, password, phone, address, email, photo, id_number) VALUES (NULL, '".$_SESSION['user_code']."', '0', '".$fgmembersite->SanitizeForSQL($_POST['j_title'])."', NOW(), '0', '".$fgmembersite->SanitizeForSQL($_POST['j_desc'])."', '".$secutype."', '".$mod_pass."', '".$phone_check."', '".$address_check."', '".$email_check."', '".$photo_check."', '".$id_check."');");
echo '<!DOCTYPE html>
<html lang="en">
<head>';
include("parts/head.php");
echo '</head>
<body>
<div id="footerfix">';
include("parts/header.php");
echo '<div class="container">
      <center><br><br><br><img src="css/img/ok.png"/></center>
      <div class="hero-unit">
        <center>
        <h2>Your track URL <a href="'. siteurl . '/' . $_POST['j_title'].'">'.siteurl . '/' . $_POST['j_title'].'</a> have been created.</h2>';
        if ($secutype==0){echo '<p>This url is public. Click <a href="profile.php">here</a> to return to your dashboard.</p>';}
        if ($secutype==1){echo '<p>This is a password protected url. Click <a href="profile.php">here</a> to return to your dashboard.</p>';}
        if ($secutype==2){echo '<p style="font-size:16px">The visitors of this URL will need an special QR code. We offer you two options:</p>
        <p>1. Download the <a href="http://chart.googleapis.com/chart?chs=70x70&cht=qr&chf=bg,s,FFFFFF00&chl='.$mod_pass.'">QR code image</a> and add it to your personal design <br>2. Or Download a ready to print business card model</p><br><p>Click <a href="profile.php">here</a> to return to your dashboard.</p>';}
        echo '</center>
      </div>
    </div>';
    include("parts/footer.php");
    echo '
    </div>
  </body>
</html>';
}

Take in consideration that all the included files, like head.php and header.php need the fg_membersite loaded before you include them. Until now the code works fine, but if the function the_error is called, I get several errors telling me that the head.php and header.php don’t find the class loaded. This is the_error:

function the_error($error) {
    echo '<!DOCTYPE html>
          <html lang="en">
          <head>';
    include("parts/head.php");
    echo '</head>
          <body>
          <div id="footerfix">';
    include("parts/header.php");
    echo '<div class="container"><center><br><br><br><img src="css/img/notok.png"/></center><div class="hero-unit"><center><h2>Error</h2>';
    echo '<p>'.$error.'</p>';
    echo '</center></div></div>';
    include("parts/footer.php");
    echo '</div></body></html>';
    exit;
}

As you can see, the_error() is almost the same code I use to print the results. So, why the include works fine when I call them outside the function? Seems like when I use include in the PHP script outside a function it just copy the code from the external file into the original script (which is what I need) and when I use the include inside a function it first runs the remote script and then add the result (which will not work because the class is loaded on the script who use the include).

If I’m right and knowing the code flow, how do you suggest to solve this issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:07:15+00:00Added an answer on May 27, 2026 at 10:07 pm

    If I undertand your problem correctly, it could be that you are trying to access variables (the instance of your class) from the global scope inside your function. Since those included files are loaded from inside the function they will only have access to that scope.

    You can just use:

    global $fgmembersite;
    

    In the first line inside the_error() body;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting a strange result in the following C code. int main() {
I'm running testunit (with machinist) and getting this very strange result when I run
I'm getting strange results testing the return value from a function. This code is
I'm not sure why am I getting this strange result. Can someone please shed
I'm getting a strange NullPointerException, evidently thrown by the following line of code: Iterator<Note>
Possible Duplicates: Getting strange output when printing result of a string comparison Hi all,
I'm getting a very strange result when I try to use string.trim to remove
I'm trying to do something rather simple but I'm getting a strange result. I
I imagine that this is a simple question, but I'm getting some strange results
I have a strange problem with my script. I am getting a JSON result

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.