FAQ Database Discussion Community


Using require() doesn't load php file

php,require
//index.php if(isset($_GET["action"])){ if($_GET["action"]=="add_admin"){ require("../gbl_admin/admin_header.php"); require("../gbl_admin/admin_add.php"); } } //admin_header.php require("../gbl_admin/db/db_ini.php"); require("../gbl_admin/classes/dbmgmt.php"); require("../gbl_admin/configuration/passwordhash.php"); I have created a in dbmgmt to handle database but after calling it through index.php and submitting the form it gives me "Creating default object from empty value " error as well as "Call to undefined function create_hash()" error...

Requiring files in the Volt Framework

ruby,require,mixins,voltrb
I have a mixin I want to include in a few different classes in a Volt app. Pertinent structure as follows: Including file path: app/component_1/models/my_model.rb Included file path: app/component_2/mixins/my_mixin.rb Here's what I've tried: require "#{Volt.root}/app/component_2/mixins/my_mixin" yields this error in the server output when loading a page: SyntaxError: Cannot handle dynamic...

require() in node.js is not working and returns error?

node.js,module,require
I have looked through stackoverflow and read about require. However I cannot understand why my require function does not run. app.js code: var http = require('http'); var express = require("express"); var app = express(); //Twitter Search ------------------- app.get("/tweet, function(req,res){ var twiter = require('twiter.js'); }); app.listen(3000); twitter.js code: console.log("twitter.js ran"); ...

Porting Chrome extension using jQuery to Firefox SDK Add-on

jquery,google-chrome,firefox,require,commonjs
My Chrome extension makes use of jQuery in the background page, for things like jQuery.extend(), jQuery.ajax(), jQuery.deferred(), (not DOM manipulation stuff, which doesn't make sense in a background page). Migrating this code to a Firefox SDK Add-on, there's no background window object, which jQuery requires to work, so something like...

PHP Auto-execute script upon any page load

php,require,autoload
My Index.php namespace Toplist; require_once "Helper/Functions.php"; use Toplist\Helper\Functions; use Toplist\Controller\IndexController; use Toplist\Model\IndexModel; use Toplist\View\IndexView; My Functions.php function __construct() { spl_autoload_register('self::l'); } public static function l($c) { $n = $c . '.php'; $f = preg_replace('/Toplist\\\\/', '', $n); $f = preg_replace('/\\\\/', '/', $f); if(!file_exists($f)) { return false; } require_once $f; } This...

Requiring a LuaJIT module in a subdir is overwriting a module of the same name in the parent dir

lua,require,luajit
I have a file setup like this: main.lua (requires 'mydir.b' and then 'b') b.lua mydir/ b.so (LuaJIT C module) From main, I do this: function print_loaded() for k, v in pairs(package.loaded) do print(k, v) end end print_loaded() require 'mydir.b' print_loaded() -- This would now include 'mydir.b' instead of 'b': local...

Do directives that share a required ^parent share parent's $scope?

angularjs,scope,require,directive
I'm having an issue where I'm using require in both myDirectiveChild1 -- C1 myDirectiveChild2 -- C1 The children's directive require: ^myDirectiveParent -- P P defines $scope.myVar but C1 and C2 seem to be over-writing the value of parent P's $scope.myVar instead of each having their own copy. Is that normal?...

require(footer.php): failed to open stream: No such file or directory in example.php on line [closed]

php,require
Fatal error: require(): Failed opening required 'footer.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\extjskanala\registration.php ...

In Node, how do I require files inside eval?

javascript,node.js,eval,require
I have two files test.js and x.js, in the same directory: test.js: console.log(eval( "require('x.js')" )); x.js is empty. Expected: require returns undefined, so nothing is logged. Actual: node test.js gives me Error: Cannot find module 'x.js' (stack-trace omitted for brevity). The situation sounds similar to this other question, with the...

Can anyone help me to make require working?

php,file,require,require-once
So I have 2 php files, one is calling function other is implementing the functions. In the one that is implementing the functions I call require("shares.php") - shares.php is file that calls the functions The problem is that, it's not seeing the functions, so I made a check to see...

How to access data from other .php file in PHP?

php,include,require,data-access
I have login.php and mainpage.php files and I want to access login.php's user's data from mainpage.php. Should I use require or include? How to connect those files? require login.php; include login.php; ...

Using a class to include / require a file

php,function,class,require
I'm using the following code almost everytime that I require a file: $file = 'my_file.php'; if (!file_exists ($file)) { sessionLog(basename($_SERVER['PHP_SELF']).">Class NOT found: ".$file); }else{ require ($file); sessionLog(basename($_SERVER['PHP_SELF']).">Class Loaded: ".$file); } Is there a practical way to create a class or function to avoid re-writing the code every time I require...

Node and Require import error in Mocha?

javascript,node.js,require
I have a working Node application and I'm trying to add Mocha tests, but getting some odd import errors. This is my file structure: package.json index.js src/ chart.js highcharts-options.js test/ test_chart.js This is what my chart.js file looks like: var chartOptions = require('./highcharts-options'); var analyseChart = { doSomething: function() {...

A require statement is overwriting global variables in lua

lua,include,variable-scope,require
Consider the following two files: a.lua function x() return 1 end -- return x b.lua function x() return 2 end print( x() ) local y = require "a" print( _G.x(), y ) print( x(), y() ) When I execute my b.lua I receive the following output: 2 1 function: 0024B710...

define is not defined Javascript Node

javascript,jquery,node.js,requirejs,require
I am trying to run a Javascript file with Node to post blog updates to Tumblr. So far in my main.js file I have this: // Tumblr Information var tumblr = require('./vendor/tumblr'); tumblr.request(require('request')); var Blog; var jq = require('./vendor/jquery-1.11.1.min'); var reqq = require('./vendor/require'); var inher = require('./vendor/inheritance'); var grammars =...

require_once and include are having php.ini issues

php,require
Hi I am getting this error, when I run the index.php file which includes require_once("system/config.php"); I am wondering what does this message mean, and how do I go about fixing such an issue. As this site worked fine when I ran it directly on my Mac. require_once(): Failed opening required...

inconsistent need for global keyword when referencing variables in other PHP scripts

php,global,require
I've hunted for an answer to this, but still can't explain the inconsistency i'm experiencing. Heregoes... I'm writing a simple CMS in PHP and cannot understand how I can directly reference external variables from one require call but not another 1. Here's my Db_Conn.php script. <?php if(!class_exists('Db_Conn')){ class Db_Conn{ var...

Javascript, require var

javascript,node.js,require,var
helper.js I usually program in Ruby. I want to get this info: var shopInfo = { "shopName": "The Coffee Connection", "address": "123 Lakeside Way", "phone": "16503600708", "prices": { "Cafe Latte": 4.75, "Flat White": 4.75, "Cappucino": 3.85, "Single Espresso": 2.05, "Double Espresso": 3.75, "Americano": 3.75, "Cortado": 4.55, "Tea": 3.65, "Choc...

cannot load such file

ruby,gem,require
I am building my own first Gem. After I created some functionality I ordered all the files like to the best practice of gem building. I moved all the files to right folders. The executable is in bin/boss-mailer, the rest is put all in the lib folder like: The executable...

foreach loop that include php files multiple times - acceptable?

php,if-statement,require
I have this function "processMessage($msg)" that processes string based on the first few words in it (prefixes). I pull lots of rows from the database and pass each $msg string through said function... The caveat here is that, the function doesn't have the "if($prefix=='blah')" conditions, but rather it includes a...

TypeScript require with type checking

typescript,require
I am using TypeScript v1.4.1 and would like to require an external module (in this case "chai") and have it be type checked. However, I am running into some sort of naming conflict with this code: /// <reference path="../typings/node/node.d.ts" /> /// <reference path="../typings/chai/chai.d.ts" /> /// <reference path="../typings/mocha/mocha.d.ts" /> var chai...

Cannot call require('fs') with PhantomJS runner

require,scala.js
I've been trying to use the FS API in PhantomJS, but I get an error I'm not able to understand when I run the following code private[scalajssupport] object PhantomFile { val fs: PhantomFS = js.Dynamic.global.require("fs").asInstanceOf[PhantomFS] } The error I get is: TypeError: undefined is not a constructor (evaluating '$g["require"]("fs")') However,...

Include, Require a syntax error file

php,include,syntax-error,require
I would like to ask can I require/include a file that has syntax errors and if I cant, the require/include returns a value so that I know that the required/included file has syntax errors and cannot be required/included ? file.php has syntax error include('file.php') if (not file.php included because of...

Require PHP doesn't work

php,require
I am writing a code in PHP which is not fully completed. When I open this register.php script in my browser there is only a blank page, because I can't get over require('config.php'). When I delete require('config.php') everything will appear in my browser. Could you please help me and tell...

NodeJS using a module from different files

node.js,module,require
Lets say that I would like to configure and use the passport module. In my app.js, I have minimal module configuration like the following: passport = require('passport'); // load module app.use(passport.initialize()); // initialize passport app.use(passport.session()); // use session Now, I would like to configure routes for my app. However, I...

Basic Integration angular js and require js not working

angularjs,require,angular-bootstrap,angular-require
It's seem to be easy but trust me i wasted almost my 4 hours on it still didn't find out what is wrong in it. Very simple setup install everything with bower like require angular domReady bootstrap fontawesome..etc. Sorry if I forgot to add something this is my first setup...

Using the shell provided with NodeJS

javascript,node.js,shell,require,node-modules
Once you've installed NodeJS, you'll have a executable in your computer named NodeJS which is a shell. I was wondering what can I do with that... here you're able to run JS code as, for example, in the browser's console, great. Now, is it possible to require modules in that...

issue while kendo UI with angularjs and require.js

angularjs,require
I am using kendo UI with angularjs and require.js I have not added "kendo.all.min.js" to my project. I am downloading js as per requirements. Everything was working fine while using version * Kendo UI v2014.2.903 Then I upgraded to new version Kendo UI v2015.1.429 Then I found following issues pie...

When is RequireJS' require call asynchronous? When is it synchronous?

javascript,asynchronous,requirejs,require
I use RequireJS to load my modules in one of my projects. I see around the web different ways to require modules using the require call (and not define). Lets assume I have a module named "JQuery" and I would like to require it. Two ways are possible as I...

nodejs require statement issue

node.js,require
I'm new to nodejs. I have the following files and code: // file: myfunc.js function myfunc() { return "myfunc()"; } exports = myfunc; and // file: index.js var mf = require("./myfunc"); var mfunc = mf(); console.log(mfunc); When I run node index.js from command line, I get the error var mfunc...

Require/Include in php [closed]

php,file,require,classnotfound
I need some help, I have 2 php files and when I am calling some functions it tells me that Fatal error: Call to undefined function get_contents() in /home/f77inq/public_html/php/shares.php on line 13 eventhough in the files from where I call the functions I have typed require("name ofmy file"); shares.php <!DOCTYPE...

How to know what path to specify in Node for require

node.js,require
All: When I use Express.js(but I believe this is more of a Node question), if I want to import some modules, I need to use require(module path). But I am a little confused what root path should be used for each require, are they all same to the path we...

How can I get the minimum/recommended system requirements for my game?

unity3d,system,game-center,require
is there a service where I can upload my game in to and they give me the info ? I want something like • 2.0 GHz intel core i3 processor • 1 GB RAM • 128 MB Video Card with support for Pixel Shader 2. • The latest version of...

Prestashop custom php file with query

php,include,connection,prestashop,require
I am new to prestashop and I have made a custom php file which is called by ajax and has SQL queries. The problem is that this file doesn't have a connection. What should I include or require in it to achieve it?

Is there any way that prevent lua from translating 'a.b' to 'a/b' when I require 'a.b'?

lua,require
For example: require('a.b.c/foo.lua') Lua engine will translate 'a.b.c/...' to 'a/b/c/...' to search file in the pattern list, right? Will there be any problem when 'a.b.c' are real folder name? If so, how to solve that?...

How require() works in JavaScript and how its usage affects console.log?

javascript,node.js,require,console.log
Could someone explain how require() and console.log work in javascript? I have a code snipped saying something close to this one: var somevar = require('C:/Users/Me/Folder/SomeFolder/somefile.js'); console.log(somevar); In the console I see the following: { _maxListeners: 0, reset: [Function], verify: [Function], report: [Function], getSource: [Function], getSourceLines: [Function], getAllComments: [Function], getComments: [Function],...

Callbacks with Require JS

javascript,require
So i'm trying to make two functions that allow a user to move an item from their cart to the "saved cart" and vise versa. These functions depend on the "cart group item" module which also contains the events for the button clicks. My question is, i'm unsure how to...

Pros & Cons of using requirejs (-m amd) for typescript+angular projects

javascript,angularjs,typescript,require,amd
For an angular 1.x project that uses typescript, what are the Pros and Cons of using AMD? Meaning, running tsc with the params -m amd and using requirejs, versus simply using the /// <reference path="..." /> for internal modules as well and wrapping in module(s). Which- Makes more sense for...

require() not working in Laravel 5

php,laravel,require,directory-structure
I am using the basic Laravel 5 file structure. I basically have some .php files inside of the app directory. I am trying to call them from a controller within the app/Http/Controllers directory. require ('../../PlaylistRetrieval.php'); require ('../../Playlist.php'); These are the two lines that are failing from within my controller. My...

node can't find modules that exists in parent node_modules folder

javascript,node.js,npm,docker,require
I am using node 0.12.0 with express and created a Docker image. This is my directory structure: -server/ -config/ -config.js -app.js -package.json -node-modules/ -deep-extend/ -... -... -... My package.json looks like: { "name": "test", "version": "2.0.0", "private": true, "dependencies": { ... ... "deep-extend": "^0.3.2", ... ... } } and config/config.js...

Titanium (Node.js) require() vs Global

javascript,node.js,titanium,require,commonjs
I'm unsure if any of the following is considered a better practice. Environment: Appcelerator Titanium/Alloy, which is a framework to make native apps. It uses javascript as source, comparable to node.js (more like CommonJS). Case 1: Many files where i use: var localInstance = require('main/module/sub/foobar')({ initialize: true}); Case 2: A...

nodejs: Is calling functions from require's cache as fast as functions in global scope?

javascript,node.js,performance,caching,require
Suppose I have a file called external.js: // external.js //define a print function and make it public module.exports.print = function(text) { console.log(text) } And then I have a file called main.js: // main.js // call require('./external.js').print so that it'll be in the require's cache require('./external.js').print('I am now in the cache')...

Not able to access variables in required file

javascript,gulp,require,browserify
I'm using browserify on a project and am running in to the following: I have a file test.js. In test.js there is nothing but the following: var test = 'test'; Now, in the same directory I have my main file 'app.js'. I require test.js and try to access the 'test'...

PHP require_once Absolute Path vs Relative Path (Not Working)

php,require
Well, I am still very confused how this is possible. Look at the following two lines of code: Code on Connection.php in class folder: require_once '../config/constants.php'; require_once dirname(__DIR__).'/config/constants.php'; The second works totally fine, but the first throws the error of: No such file in ...... on line... in Connection.php It's...

Is it more resource intensive to include/require a php file than an html file?

php,include,require
I was wondering about this. I have the habit of naming my files *.php when including them, even though I don't require any PHP executions. Does this have any negative consequences on server load? I.e. does the server need more time to parse a PHP file than an HTML file?...

Redirect is not working on Laravel 4

laravel,redirect,laravel-4,require
In my controller function I am using a require statement to include a file, like, require app_path().'/plivo/plivo.php'; After this statement, when I try to redirect from this controller using the statement, return Redirect::back()->with('success', 'Note added successfully'); It gives me an error Call to undefined method Redirect::back() How can I redirect...

Is it required to include any files from gomoob:php-pushwooshto to run a PHP program to send push notifications to iPhone?

php,push-notification,require,pushwoosh,php-include
I want to send push notifications to iPhone devices by writing PHP code for it. gomoob:php-pushwoosh is a PHP Library that easily work with the pushwoosh REST Web Services. This is the URL for gomoob:php-pushwoosh As per the instructions I've installed gomoob:php-pushwoosh on my local machine using Composer at location...

ReactJS errors with rendering basic html component via variable

reactjs,require,fs
I am trying to pass a string for the jsx template name to a component that will be responsible for just rendering basic html only components with no interaction (we have a lot). 'use strict'; import React from 'react'; export default class TemplateLoader extends React.Component { displayName = 'TemplateLoader' constructor(props)...

“require” DDO option of Angular directive does not throw an error when it should

javascript,angularjs,angularjs-directive,require
Forgive me if this is obvious, but I am just learning the ropes. I've been following this article, trying to understand directives in AngularJS. The docs specify that the require option of a directive's DDO should throw an error if the referred-to directive is not found. I cannot seem to...

node.js require() weird behavior

node.js,require
UPDATE - I added more information. The issue seems to be dependant on the order of the require statements. Unfortunately, fixing one breaks the other, please help!!! I cannot figure out what is going on here. I have 5 files shown below, and am using index.js simply to demonstrate the...

how to use array by included file in php?

php,arrays,include,return,require
I have a init.php file with the following code: $engines = [ "id" => [ 'A', 'B', 'C' ], "url" => [ 'D', 'E', 'F' ] ]; return $engines; as you can see in this file there is only an array that need for initialize the site that is included...

Scala: elegant way to use require to validate multiple options?

scala,functional-programming,coding-style,pattern-matching,require
I have two solutions for this problem. I do not like both of them so I was wondering if there's a more elegant solution. import java.util.Date import scala.math.Ordered.orderingToOrdered // Solution # 1: case class A(startDate: Option[Date] = None, endDate: Option[Date] = None) { require(if (startDate.isEmpty && endDate.isEmpty) false else true,...