Undefined Variable With Require_once

Jul 28, 2007

I get the following notice whenever I try to call a function from my file :
Notice: Undefined variable: database_mainsqldb in F:mysiteSite Templateincludesmyfunc.php on line 7

this variable "$database_mainsqldb" is defined in this file "../Connections/mainsqldb.php" and I include this file like that:
<?php require_once('../Connections/mainsqldb.php'); ?>

I tried to use the same function in the same calling page and it work fine without the previous notice!! the error appear only when I try to call it from myfunc.php Code:

View 3 Replies


Require_once, Undefined Function?

I have a script:


That looks like this:
$baseDir = "http://" . $_SERVER[ "SERVER_NAME" ] . "/test";

require_once( $baseDir . '/helpers/helper.php' );


something() is a function in helper.php.

I get:
Call to undefined function: something() in
/home/mydomain/public_html/test/admin/foo.php on line 6

The require_once doesn't fail (well, I don't get an error message), so I'm
assuming that it finds helper.php OK. something() definitely exists in

If I put foo.php and helper.php in the same folder, lose all the $baseDir
crap and use require instead of require_once it works fine (not sure if it's
the $baseDir part or the require_once that is tripping it up), however I
need them to be in seperate folders and I'd rather use require_once than
require in case I end up including something twice by accident, it's so much
easier not to have to worry about it.

I've been fiddling with this for about an hour now and it's starting to get
really annoying.

View 6 Replies

Redirect With Variable From Require_once?

I have two php pages...


PHP Code:



I cannot seem to get this to work. If i have the page in the header redirect like this...

header("Location: http://www.ebay.com/");

But when i try to use the variable - there is no redirect, it just stays on the page1.php.

View 3 Replies

Get Undefined Variable And Undefined Index Notices?

I have just upgraded my wampserver and with it MySQL, PHP and PhpMyAdmin versions. And my scripts, which ran normally before, not burst hundreds of undefined variable and undefined index notices. I realize it's "notices", not "errors" but this is quite irritating. I believe it might be due to some upgrade in PHP scripting rules or something but I don't know what.The first type of notice is "undefined variable". This function will return the notice if I remove the bold red line, where I define the variable as empty before I use it in the loop. I didn't need to do this before.
function statistics($array) {

[color=red][b]$list = '';[/b][/color]
if(is_array($array)) {
foreach($array as $name

View 10 Replies

Undefined Constant And Undefined Variable Options?

I am pretty sure I defined these, by making it something like$blah="blah" and `blah` = ' {$blah}'So why am I getting these errors = Notice: Use of undefined constant petid - assumed 'petid' in /home/vhosts/foggyjungle.6te.net/viewpet_forum.php on line 38Notice: Use of undefed constant adopter - assumed 'adopter' in /home/vhosts/foggyjungle.6te.net/viewpet_forum.php on line 41Notice: Undefined variable: fulldate in /home/vhosts/foggyjungle.6te.net/viewpet_forum.php on line 44Fatal error: Call to undefined function showpet_forum() in /home/vhosts/foggyjungle.6te.net/viewpet_forum.php on line 45

$time = mysql_query("SELECT * FROM `pets_adopted`");
$date = mysql_fetch_array($time);
$fulldate = "$date[fulldate]";

View 2 Replies

Get Undefined Variable And Undefined Index?

I have been following a tutorial, the watchmaker project for a shopping cart.I had downloaded one of the codes which is as follows:

PHP Code:
<?php $cart = $_SESSION['cart'];if ($cart) { $cart .= ','.$_GET['id'];} else { $cart = $_GET['id'];}$_SESSION['cart'] = $cart; ?>

View 3 Replies

Postcard Notice: Undefined Index: Notice: Undefined Variable Errors?

I am having serious trouble with my PHP Postcard script. The error message i get is: Notice: Undefined index: Notice: Undefined variableBasically it does not send out the scripts at all. It is hosted on Awardspace.

<?php session_start();
//check error log
ini_set('display_errors', 1);
ini_set('log_errors', 1);

View 2 Replies

Run Page On WAMP Server Which Include Session Variable But It Is Giving An Error : Undefined _SESSION Variable?

I am trying to run my live page on WAMP server which include session variable but it is giving a Error:undefined _SESSION variable

View 2 Replies

Undefined Variable When Checking If Variable Is Defined In Kohana View

I'm running into this error when loading up my view:

ErrorException [ Notice ]: Undefined variable: errors
APPPATHviewsadmincategoryadd.php [ 2 ]
1 <h3>Add</h3>
2 <?php if( $errors ): ?>
3 <p><?=$errors?></p>
4 <?php endif; ?>

How is my checking not valid?

View 4 Replies

Error While Executing In 5.3.6 "Undefined Variable","Undefined Offset"?

The code that executed in php 5.2.6 is not executing in php 5.3.6.I am getting an error "Undefined variable","Undefined offset".

View 2 Replies

PHP Saying I Have An Undefined Variable?

I get the following error:

Notice: Undefined variable: end_while in C:Program
FilesApacheApache2htdocscspincxmlmenu.php on line 102

This is a script that works on the server at work but it has difficulty
with me running on my home desktop. The variable, $end_while, is just a
basic variable. Is this a configuration problem where you can allow
undefined variables? Ive never had to define variables in the past.

View 3 Replies

Undefined Variable:

I'm getting the following error in my server error log: Quote:

[Sat Mar 24 23:12:06 2007] [error] [client] PHP Notice: Undefined variable: username in C:ServerApache2.2htdocsJumploaderuploadHandler.php on line 3

Line 3: Code:

$_SESSION['usuario'] = $username;

I don't understand why this session is undefined. One page previous, in the same session, 'usuario' is used to:

if (file_exists("c:Serverupload".$_SESSION['usuario'])) {
} else {
mkdir ("c:Serverupload".$_SESSION['usuario']);

Can I not use the same session multiple times?

View 5 Replies

Variable Undefined

Can someone please tell me why this code returns an error saying the variable $rounds is undefined (returns the error on the last line where the $sql variable is): Code:

View 2 Replies

Undefined Variable.

Notice: Undefined variable: username in c:program fileseasyphp1-7wwwfav.php on line 7

Notice: Undefined variable: colour in c:program fileseasyphp1-7wwwfav.php on line 11

what does this mean please. cant seem to get my ...html file to work with my .php file.

View 1 Replies

Undefined Variable

I have the following php code:

if ($sortm == '' ){
  $sortm = 'ibn';

which gave me the undefined variable error. I can't seemed to find what's wrong.

View 3 Replies

Undefined Variable That I'm Sure I Defined.


mysql_connect('localhost', $user, $password);
@mysql_select_db($database) or die ('Unable to connect to database.');

$post="INSERT INTO rentap VALUES ('$name1', $phnumber1', '$email1', '$typerental1', '$br1', '$bth1', '$sqft1', '$description1', 'date','')";

I get an undefined variable on line 23 for each of the variables in that line, on the line, $post="INSERT INTO...
On the page before I carried the variables over with a hidden form
echo "<form method=post action='post.php'>";
echo "<input type='hidden' name='name1' value='$name'>";
echo "<input type='hidden' name='phnumber1' value='$phnumber'>";
echo "<input type='hidden' name='email1' value='$email'>";
echo "<input type='hidden' name='typerental1' value='$typerental'>";
echo "<input type='hidden' name='br1' value='$br'>";
echo "<input type='hidden' name='bth1' value='$bth'>";
echo "<input type='hidden' name='sqft1' value='$sqft'>";
echo "<input type='hidden' name='description1' value='$description'>";
echo "<input type=submit value='Submit'>";
echo "</form>";
Why are the variables undefined?

View 2 Replies

Notice: Undefined Variable

am trying to create a a upload file.am uploading files ok but i
recieve this message.

Notice: Undefined variable: uploaded_size in /home/fhlinux169/c/
clashoff.co.uk/user/htdocs/upload.php on line 7.....

View 2 Replies

Keep Getting Undefined Variable Errors -


I am using the examples in the book:
PHP: Your Visual Blueprint For Creating Open Source, Server Side Content

In the section where they talk about getting values from a form
submission, the book says:

"PHP makes it easy to process data from a form. When a PHP
page receives form information, the page automatically converts
the names of form elements to PHP variables, and assigns
the data entered in the elements to the variables"

So I try to display what was submitted, but I get an undefined
variable error.

For example,

<? php
print "the ID you entered was: ";
print $userid;

This returns an error. But, if I use the following it works:

<? php
print "the ID you entered was: ";
print $HTTP_POST_VARS['userid'];

Can someone explain this?

One more example:

I'm trying to simply display a session ID (using the example in the book):


<title>PHP Session Test</title>

print "The session ID is: ";


When I access this page I get:

The session ID is:
Notice: Undefined variable: PHPSESSID in c:inetpubwwwrootsessiontest.php
on line 13

View 3 Replies

Undefined Variable Accepted

I have a script which is working however,I do not receive any errors when I use a variable which has not been declared or initialized. For example I can write echo $kjhkj;

and while nothing appears in the resulting page neither do I get an error to say that the variable is undefined. register_globals are set to "off" by the way.

View 3 Replies

Undefined Variable: Counter

I have a piece of code I am trying to resolve and I believe it has something to do with using a newer version of PHP or MySQL than the code was developed on. The function that this code is doing works fine, I just get the error message. Here is the error and the code:

Notice: Undefined variable: counter in c:inetpubwwwrootassetsservers.php on line 95

*** CODE - I typed the line numbers to the left for reference ***
94: while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
95:if($counter++ % 2 == 0){
96: $td = "even";
97: }else{
98: $td = "odd";
101: <td class='$td'><a href='editserver.php?id=$row[id]'>Edit</a></td>

View 3 Replies

Undefined Variable: Createthumb();

I got a source code for a gallery and the whole script is working fine and all, and it's all clean, but having problems with understanding the Undefined Variables: on line 347 and in the source code it says:


Sorry for the convience, it was a thing my programmer buddy tried to show me and he was buzy so didnt wanna ask him what it was, but we took it away and the script worked perfectly. so it was just to test something.

View 2 Replies

Notice: Undefined Variable:

hi forum my problem is this message Notice: Undefined variable: i need finish it i do change in php.ini (" report error") but message appear again i use easy php.

View 1 Replies

Variable Undefined Error

<form enctype="multipart/form-data" action="loadmeup.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="300000">
<input name="userfile[]" type="file" /><br />
<input name="userfile[]" type="file" /><br />
<input type="submit" />

View 1 Replies

CodeIgniter 'Undefined Variable'?

This is probably an easy one but I barely got any sleep last night and am struggling to comprehend anything.I've got a CodeIgniter library I've made called Points.php. Here's the contents of Points:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Points

As you can see, I'm building it up slowly and it's being kept simple.In one of my views, I want it to display the number of 'points' (which for the time being is simply the third segment of the URI). I call it like this:

<p>Points: <?php $params['user_id']=$this->uri->segment(3,1); echo $this->points->getpoints($params); ?></p>

The warning I get back in the view is this:

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: userid

Filename: libraries/Points.php

Yes I know it's such a simple problem but I've tried lots of things. Some variations include echoing in Points.php $params['userid']; etc. But I don't see what I'm doing wrong?

View 2 Replies

Get Data From URL - Undefined Variable

I am just learning php and I am trying to figure out some good tips and tricks so I don't get into a bad habit and waste time. I am passing in values into a php script. I am using $_GET so the URL looks like this:


Now I know how to accept those values and place them into variables like so:

$sports = $_GET['Sports'];
$cat = $_GET['cat'];
$question = $_GET['question'];

yet if I am passing 5 - 6 things it can get bothersome and I don't like typing things out for every single variable, that's the only reason. I know there is a better way of doing this. I have tried list($var, $var, $var) = $_GET but that doesn't work with an associative array just indexed ones (i think). I also tried variable variables like so:

foreach($_GET as $value) {
$$values = $value;
echo $$values;

Undefined variable: values in poll_results.php on line 14. Line 14 is the $$values = $value. I don't know if that's a big deal or not. but I'm not turning off error reporting as I am still in the process of building the script. It does do what I want it to do though.

View 5 Replies

Get An Undefined Variable Code?

I am getting an undefined variable code:Notice: Undefined variable: prod_optionsNotice: Undefined variable: color_optionswith this error it won't make my drop down option box show the list of colors or product.What am I missing? Am I coding something wrong?

// manage colors
// pull associated color/products and display them
// give ability to delete associations and add

View 2 Replies

Copyrights 2005-15 www.BigResource.com, All rights reserved