p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Beginning PHP (http://p2p.wrox.com/forumdisplay.php?f=95)
-   -   Undefined Varriable (http://p2p.wrox.com/showthread.php?t=64805)

syedferhat December 26th, 2007 03:51 AM

Undefined Varriable

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

/* 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);

harpua December 26th, 2007 04:41 PM

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='') {


All times are GMT -4. The time now is 10:42 AM.

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