Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 26th, 2007, 03:51 AM
Registered User
 
Join Date: Apr 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to syedferhat
Default Undefined Varriable

Hi

I do turned on register_globals=On in php.ini but still got same error
"[26-Dec-2007 12:37:20] PHP Notice: Undefined variable: uname in E:\Inetpub\wwwroot\Intranet\DataAccess.php on line 96"

Although i checked again all the variable name on both page. Can u plz let me know whats the problem and how to resolve the codes
Please also answer me on my this email id too [email protected]

following are the codes to retrieve the value on action ( Form target)page

/* Calling a function
Enter_New_Entry($uname,$pwd,$dept);


/* Function to retrive value and put into the database
function Enter_New_Entry($uname,$pwd,$dept) {

    /*
        First, we create a connection to our ODBC source. This is done by creating
        a connection. Once this is done, we are returned an ODBC connection number.
        We use this number to use the ODBC functions within PHP.
    */

    $cnx = odbc_connect('intranet','','');
    if (!$cnx) {
        Error_handler( "Error in odbc_connect" , $cnx );
    }
    $SQL_Exec_String = "Insert Into Users2 (uname, pwd, dept)
            Values ('$uname', '$pwd', '$dept')";
    $cur= odbc_exec( $cnx, $SQL_Exec_String );
    if (!$cur) {
        Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
    }

    odbc_close( $cnx);
}


 
Old December 26th, 2007, 04:41 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is a Notice, you can ask your hosting company to adjust the error_reporting to turn off the notices, then you will not get this message. I personally like to leave them on during development to help in the debugging. This lets you know if you have typos in the variables name and that variables are defined, as this is a good practice to get into.

I am not sure how you are defining $uname in your application but you could do something like this before calling your function.

if (!isset($uname)) { $uname = '' };

or while calling your function
function Enter_New_Entry($uname='',$pwd='',$dept='') {

http://us3.php.net/error_reporting





Similar Threads
Thread Thread Starter Forum Replies Last Post
Undefined index junemo Pro PHP 8 October 31st, 2007 05:45 PM
undefined Adam H-W Javascript 5 September 26th, 2007 01:31 AM
How to know a variable is undefined? Edward King Javascript How-To 3 June 14th, 2005 10:14 AM
Undefined Variable fpolan Beginning PHP 9 July 15th, 2004 06:24 AM
Undefined function dhborchardt Classic ASP Databases 0 June 7th, 2004 03:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.