Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 26th, 2007, 03:51 AM
Registered User
 
Join Date: Apr 2004
Location: Karachi, , Pakistan.
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 ferhat.naqvi@gacworld.com

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);
}


Reply With Quote
  #2 (permalink)  
Old December 26th, 2007, 04:41 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Oklahoma City, Oklahoma, USA.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:36 AM.


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