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:


Require_once, Undefined Function?

Jul 17, 2005

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 View Related

Redirect With Variable From Require_once?

Sep 15, 2009

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 View Related

Get Undefined Variable And Undefined Index Notices?

Sep 29, 2010

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 View Related

Undefined Constant And Undefined Variable Options?

Jan 27, 2011

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 View Related

Get Undefined Variable And Undefined Index?

May 3, 2010

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 View Related

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

Aug 18, 2010

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 View Related

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

Aug 4, 2010

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 View Related

Undefined Variable When Checking If Variable Is Defined In Kohana View

Jun 18, 2011

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 View Related

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

Jun 23, 2011

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 View Related

PHP Saying I Have An Undefined Variable?

Jul 17, 2005

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 View Related

Undefined Variable:

Mar 25, 2007

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 View Related

Variable Undefined

Jan 26, 2006

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 View Related

Undefined Variable.

Feb 6, 2005

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 View Related

Undefined Variable

Mar 4, 2007

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 View Related

Undefined Variable That I'm Sure I Defined.

Jul 13, 2002


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 View Related

Notice: Undefined Variable

Aug 12, 2007

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 View Related

Keep Getting Undefined Variable Errors -

Jul 17, 2005


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 View Related

Undefined Variable Accepted

Jun 24, 2005

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 View Related

Undefined Variable: Counter

Jan 2, 2007

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 View Related

Undefined Variable: Createthumb();

Jun 6, 2006

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 View Related

Notice: Undefined Variable:

Feb 5, 2006

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 View Related

Variable Undefined Error

Mar 7, 2006

<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 View Related

CodeIgniter 'Undefined Variable'?

Apr 19, 2010

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 View Related

Get Data From URL - Undefined Variable

Mar 16, 2011

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 View Related

Get An Undefined Variable Code?

Jul 19, 2009

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 View Related

Undefined Variable( Isset($var) && $var ){?

Dec 21, 2009

Lets say I have a variable $var that has not been defined.Why don't I get errors with this statement:

if ( isset($var) && $var ){
// something
} else {


How can you check whether something is true or not "&& $var" if it is not set yet?Does isset()do something to the if statement.Surely this should return, Notice:Undefined variable:$var.

View 8 Replies View Related

Undefined Variable With Function?

May 19, 2011

I'm a PHP newbie, so I have a minor problem functions. I have this line of code:


Anyway, when I try this code I always get an error message saying that there's a error on on line 11 (the bold part of the code) and no variable is echoed. I'm guessing that it gives me that error because my variable isn't defined inside of that function, but I need to define it outside of the function so is there a way to do this?

View 4 Replies View Related

PHP 5 Undefined Variable Error

Jul 26, 2007

Well I just upgraded to PHP 5 but now no variables will pass page to page like I use to have them do and im getting error messages that say undefined variable bla bla bla. I think this is a quick fix by changeing something in php.ini. I just dont know what to change any ideas?

View 2 Replies View Related

Functions :: Undefined Variable

Sep 26, 2007

I've never really used functions but now I find myself needing to. I understand the basics but I can't seem to get the variable from within the function to echo outside of it. Code:

View 13 Replies View Related

Undefined Variable In Function

Apr 14, 2007

I have a script with those good ol checkboxes and those good ol undefined variable errors when a checkbox is not checked. I have managed to fix this problem in all but one of my scripts where I use a function to update the database through an include. Here is the script:

View 4 Replies View Related

Undefined Index/variable

Sep 25, 2007

Although I have been programming with php for a little while I am still failing to understand what causes errors such as Undefined index:user_id or Undefined variable: ven:
I thought that variables did not have to be predefined and where defined when you created them.

View 6 Replies View Related

Undefined Variable Message

Aug 27, 2007

when I turned errors on in one of my php pages I got this error..

but the page still works fine..

I never had to declare a variable in php... why is it telling me I have an undefined?

I thought they were defined when you define them?

View 6 Replies View Related

Undefined Variable: Form_token?

Mar 19, 2011

I'm new to forums so I apologise if I don't explain myself properly. I am following a tutorial to make a blog system. I got to the log i portion and have encountered an error.
The error reads:Notice: Undefined variable: form_token in C:wampwwwBloglogin.php on line 17 Call Stack #TimeMemoryFunctionLocation 10.0009367584{main}( )..login.php:0 " />

The code is as follows:
Code: [Select]<?php 
/*** start the session ***/


View 5 Replies View Related

Getting An Undefined Variable When The Url Is Define?

Mar 24, 2011

I don't know why I am getting an undefined variable when the url is define. look at the deleteid=6 it means it is defined and in the code it is written as below


View 4 Replies View Related

Notice: Undefined Variable: REMOTE_ADDR ...

Jul 17, 2005

Just set up PHP (PHP Version 4.3.3) as a CGI on a WIN2k server and tried



print "This is PHP...";


And I get this error:

Notice: Undefined variable: REMOTE_ADDR ...

Is there some module I may be missing?

View 2 Replies View Related

Getting Undefined Index/variable Errors?

Apr 8, 2003

I have no idea why my variables are not being sent to the server. With php 4.3.1, Apache 2.0.44 and MySQL, the following script PHP Code:

View 14 Replies View Related

Undefined Variable _SERVER Error

Aug 15, 2005


echo('<p>' . $_SERVER['PHP_SELF'] . '</p>');


this is my code. Whenever I try to view it in the Browser I am getting the following error:

Warning: Undefined variable: _SERVER in c:inetpubwwwrootphpincludesincludessimpleParagraph.php on line 3 ...

View 1 Replies View Related

Notice: Undefined Variable: XXID

Aug 6, 2005

With this on a page:

PHP Code:

ini_set(display_errors, "1");

I'm now getting an error message:

"Notice: Undefined variable: XXID
in http/vhosts/mysite.com/httpdocs/folder/submit/main on line 140"

View 1 Replies View Related

Variable 'page' Coming Up Undefined

Sep 5, 2007

i've came up with the following script for an 'easy' write to file from form page. i've done it a few times before with success, but for some strange reason this time i'm having a bit of trouble with the variable 'page' coming up undefined. It's probably something really simple but i can't seem to be able to spot it.

if (isset($_POST['update'])){

$file = fopen('db/pages/home.php', 'a', 1);
fwrite($file, $page);

else {
$lines = file('db/pages/home.php');
$l_count = count($lines);
for($x = 0; $x< $l_count; $x++)

View 4 Replies View Related

Undefined Index/Variable Error

Dec 24, 2005

I keep getting errors like: Code:

Undefined index: mail in C:Program FilesApache GroupApache2htdocs est.php on line 3

and Code:

Undefined variable: _session in C:Program FilesApache GroupApache2htdocsindex.php on line 198

What does Undefined Variable and Undefined Index mean?

View 7 Replies View Related

Undefined Index, Variable, Constant

Oct 11, 2006

just noticed that recently all my php pages and my mambo is full of errors.
undefined index, undefined constant, undefined variables...

I have not changed any of the templates, mambo or in the database recently and have absolutely no idea why this happens?

View 2 Replies View Related

Undefined Variable Error Change In The .ini

Feb 26, 2007

I looked at my Apache Error Log today and saw thousands of lines with something like: Undefined variable: var_name Why is it complaining about variables I don't define? Is there a setting I have to change in the .ini I'm unaware of.

View 8 Replies View Related

Set Assigned Variable To Undefined - It Stays The Same?

Mar 22, 2011

I have question about some behavior I was just debugging, specifically what happens if a variable which is already set is assigned to an undefined value. I just want to check that I'm understanding what happened correctly. If a variable has a value set already, and you try to set it to something undefined, it stays at its old value?

Specifically, I had some PHP code that looked approximately like this - assume that $string is some string of 1's and 2's.


Now, my code was supposed to set $string to be something like "12212", but an error on my part was sending it something with extra spaces at the end - "12212 ". This caused some aberrant behavior, and I think what happened was this - when $count=5, $string[5] is undefined, so $array[$string[5]] is undefined, and $newvar stays as 2. Thus my if(!empty statement doesn't do its job and case 'bar' happens more times than it should have. Does that all seem like what would happen?

Of course, trimming $string solved my problem, but I want to make sure I understand what was going wrong. Apologies if this is a stupid question - I'm just an amateur here....

Edit: Here's the actual code. $upstr is supposed to be a string of digits.


What happened when $upstr had some extra spaces at the end was I would see a mysql error, that it couldn't find the column "up" in $result2 . So it was trying to run that block of code in the if() statement with $name being empty or NULL or something. And if I intentionally added 3 or 4 extra spaces, I would see that many mysql errors.

View 3 Replies View Related

Zend: Undefined Variable In Page

Jul 11, 2011

I have an error.php file which can be grossly simplified to:

if (!isset($error))
$error = "Unspecified Error";
echo "Error: $error";

It is not "normal usage" to just navigate to error.php. Rather, I would do something like:

$dbh = mysql_connect($host, $user, $pass);

if (!$dbh)
$error = "Can't connect to MySQL: " . mysql_error();

That said, if the user does navigate to error.php then they will just get "Error: Unspecified Error" as expected. All my code is working, and the error page shows up and works exactly as expected, however Zend is complaining that $error is undefined on the line: if (!isset($error)).

View 3 Replies View Related