PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat Aug 08, 2020 6:37 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sun Dec 10, 2006 8:41 am 
Offline
Forum Commoner
User avatar

Joined: Sun Dec 10, 2006 8:35 am
Posts: 80
Location: Salt Lake City, Utah
feyd | Please use
Syntax: [ Download ] [ Hide ]
,
[syntax=php]and
Syntax: [ Download ] [ Hide ]
  1. tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: to learn how to do it too. 
  2.  
  3.  
  4.  
  5.  
  6.  
  7. I have a scope problem: 
  8.  
  9.  
  10.  
  11. my function is: 
Syntax: [ Download ] [ Hide ]
function getRelative($_PRIDN) {

        global $table;

        if ($_PRIDN != "") {

        $rel_sql = "SELECT first_name,mname1,last_name FROM $table WHERE PRIDN='$_PRIDN'";

        $rel_query = mysql_query($rel_sql)

                or die(mysql_error());

        $rel_row = mysql_fetch_array($rel_query)

                or die(mysql_error());

        }

}


My question is: How do I get the $rel_row array to be global so i can access the data outside of the function?
$rel_row = mysql_fetch_array($rel_query)

I've tried this: global $rel_row = mysql_fetch_array($rel_query) and it doesn't work.
I've tried this: global $rel_row; and it doesn't work.

I'll keep at it and hopefully find a way. Any help would be appreciated.
Grassious Mucho...in advance.

Swiftouch


feyd | Please use
Syntax: [ Download ] [ Hide ]
,
[syntax=php]and
Syntax: [ Download ] [ Hide ]
  1. tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: to learn how to do it too. 


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 10, 2006 9:05 am 
Offline
DevNet Resident
User avatar

Joined: Tue Jan 20, 2004 5:58 pm
Posts: 1537
Location: Minnesota
The function needs to return a value.

Syntax: [ Download ] [ Hide ]
function getRelative($_PRIDN)

{

  global $table;

  if ($_PRIDN != "") {

       $rel_sql = "SELECT first_name,mname1,last_name FROM $table WHERE PRIDN='$_PRIDN'";

       $rel_query = mysql_query($rel_sql) or die(mysql_error());

       $rel_row = mysql_fetch_array($rel_query) or die(mysql_error());

      return $rel_row;

  }

}

$rel_row = getRelative($_PRIDN);

print_r($rel_row);


I think that'll do it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 37 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group