How do I access a local variable?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi guys,

I have a function inside which I set alocal variable to store a result. Can I access this variable in another function? if yes then how?

function tbl1($entrytitle, $entrytext)

{

global $conn;

$result= mysql_query("INSERT INTO tbl1(tbl1_id, title, text)

     VALUES('NULL', '$entrytitle', '$entrytext')", $conn);

     $tbl_id=mysql_insert_id($conn);// this is the local variable I'm setting to get the last auto increment id

} 

 

Now I wish to access that variable in another function thus:

function tbl2($name, $entrytitle, $entrytext)

{

global $conn;

$result =mysql_query("INSERT INTO tbl2(tbl1_id, name, title, text)

                               VALUES('$tbl1_id', '$name', '$entrytitle', '$entrytext' )", $Conn); 

}

 

Or is there a better way to store the variable?

Thanks in advance.

 

Alugo Abdulazeez

www.frangeovic.com

_________________________________________________________________
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux