Questions tagged [require-once]

The PHP require_once function

The PHP require_once function.

In contrast to require this function only includes the referred file if it has not been included before.

Use this tag only for questions that directly ask about require_once usage. Do not use this tag if your code contains require_once but you have no reason to believe that require_once is directly related to the issue you are asking about.

409 questions
1
vote
1 answer

require_once not working in one file but working in the other

I've got this weird problem in getting an error Undefined variable: sqlConn And it can't be a connection to DB problem because it would yell another error, whats even stranger is that te require_once thats identical in a file thats in the same…
user2979816
  • 33
  • 1
  • 5
1
vote
0 answers

code below require_once does not execute

I have following code, however $email is not getting printed on page. I don't know why.
Kaustubh
  • 653
  • 6
  • 21
1
vote
3 answers

Get variables from included file

How do I use variables from an included file, and use it for other included files as well? index globals('index'); $logged_in = false; //works in all included files ?>
EasyBB
  • 6,176
  • 9
  • 47
  • 77
1
vote
2 answers

PHP file does exist but can't require_once()

So recently I decided to move my php code that was at the top of every page, and exactly the same to it's own php file. First thing I did before trying a require_once() on it was to make sure php could read the file so I did
MrRevolutionz
  • 11
  • 1
  • 2
1
vote
1 answer

Can mod_rewrite rules modify require_once instructions in PHP?

or I misunderstanding the use of mod_rewrite? I need several instances of a web application, the simple way could be copy all the files to another folder and modify a config file to make the connection to another database but I'm trying to change…
Leonardo
  • 119
  • 3
  • 10
1
vote
1 answer

PHP require_once ignored unless I error_log the return code?

Ok, most bizarre PHP error I've ever encountered. I have a Joomla module that has a startup.php which includes several files: ... require_once(SYS_PATH . 'json.php'); require_once(SYS_PATH . 'utf8.php'); ... On one deployment, this reveals an error…
dataless
  • 388
  • 4
  • 9
1
vote
2 answers

Yii: Design-By-Contract with PHPUnit

Why does the call of PHPUnit in the class CTestCase works: require_once('PHPUnit/Autoload.php'); .... PHPUnit_Framework_Assert::assertNotNull($object); But if I call it the same way in a file of components directory it shows…
EvilKarter
  • 267
  • 7
  • 22
1
vote
1 answer

Can't get require_once called by ajax on localhost to work

I'm almost going crazy here. I have a simple site locally with a contact form functionality that works perfect with just PHP. Now I want to call it via AJAX and I always get errors because of the relative paths. The problem is, that the php file…
Sebsemillia
  • 9,366
  • 2
  • 55
  • 70
1
vote
1 answer

php types of inclusion

I just read some articles about php's require / require_once respectively include / include_once and was just wondering when _once should be used? Is it just the performace aspect or can I run into any difficulties when including / requiring the…
Rico Ocepek
  • 767
  • 6
  • 20
1
vote
1 answer

Joomla - PHP error message

Latest: I've managed to download all files properly this time, but I get this message when I'm trying to import my sql file: The new host has a max limit of 51,200 KiB, my sql file is only 12.5MB and 3.0 MB when zipped. If I upload it as a zip…
Jonathan
  • 11
  • 1
  • 3
1
vote
1 answer

PHP: require_once for multiple files but coming out of order

I'm working on a startup that requires a website. I'm doing this by writing many separate php files and then having index.php for a page load them each with require_once('file.php') function(parameters), and that's been working just fine (and has…
1
vote
1 answer

PHP script unable to find a file when called by a flash program

I'm working on a program right now that calls the script mail.php located in /var/www/vhosts/company/httpdocs. mail.php is trying to execute require_once dirname(__FILE__).'/../pear/Mail.php' to do an smtp send and the require_once is failing. My…
Matthew
  • 474
  • 1
  • 6
  • 12
1
vote
2 answers

Issues while importing php files

I am developing a website on a local test environment. From time to time I need to import classes or functions into my php pages. At first I used relative paths to import files, but for some (unexplicable) reason the PHP couldn't find those files.…
haunted85
  • 1,601
  • 6
  • 24
  • 40
1
vote
1 answer

Execute alert only once after a link (expander) has been clicked

Hopefully someone can help with my next challenge. The following Script works in conjunction with my HTML in that when I click an expanded header it opens and closes. I also have an alert function being called which displays the text of the…
1
vote
1 answer

Google Plus PHP API conflict with other API files

I have a page that takes a string input from the user and uses it as a query string for a number of search APIs. My problem is that I have the Google+ API working ok on it's own. I can also get the YouTube Data API working on it's own. However when…
Liz Morray
  • 41
  • 5