I had a file info.php with class named xyz and functions within it, I am trying to fetch data from data base from another file show.php..but it is not working and shows "Notice: Undefined variable $info"....is there any help wht am i doing wrong...
my code is..

in dblink() // i make mysql conn and chose my database
in realescapestring() // perform stripslash and mysql_real_escape_string
class name is xyz

function showingdta($cuid)                                  /*user info*/
    { 
	$table2="member_info";
      if($this->dblink()==TRUE)
         { 
 $query='SELECT * FROM '. $table2 .' WHERE EMAIL= "'.$this->realescapestring($cuid).'"';
 $result=mysql_query($query,$this->conn_link) or die("prob");
 $info=mysql_fetch_array($result);
 
   	if (mysql_error())
	    { print "Database ERROR: " . mysql_error(); }

			header("Content-type: $info");
            echo $info;

		 }
	  else 
	     {return FALSE;} 
	}



in show.php file

<?php
session_start();
include_once("info.php");

$biglife= new xyz;
$cuid=100011;  

$biglife->showingdta($cuid);
echo "<table>";
echo "<tr>";
echo "<td>Name:</td>";
echo "<td> " . $info['FIRST_NAME']. " </td>";
echo "</tr>";
echo "</table>";


?>
Member Avatar for diafol

Use [ CODE ] tags.

Variables within functions stay within functions. You have to return them to access them.

i didnt get you.....give me some code gere

Member Avatar for diafol

> give me some code gere

What's that mean?

i mean 'here'...i mistyped it..

Member Avatar for diafol

I won't 'give' you code. That's not what this forum is about. I'll explain further:

Variables inside functions (other than global and superglobal variables) only have scope within the function. That is the outside world (outside the function) will not be aware that they exist. So $info will not exist outside the function.

Also, your function code won't work. In short, it's a bit of a mess. Look up the php.net manual for how to run a query and access the data from the resultset.

@ardav: i also know a variable is limited within a function unless you declare it as global or superglobal....dont bother me again..

Member Avatar for diafol

No problem. I was trying to help you, believe it or not. You're obviously a noob at php as can be seen from your code. It just doesn't make any sense.
I have now put you on my ignore list, I suggest you do the same for me.
Good luck.

Member Avatar for diafol

Very mature. It seems my first impressions were correct. Your post is here for everybody to see. Well done, you've made yourself look like a complete idiot without any help from me.

Come back when you've matured and can conduct yourself in a suitable, acceptable manner.

i dont care who is seeing my post...<snipped personal attacks>

Member Avatar for diafol

Ha ha. Brilliant. Colloquial Londoner-speak too. I'm impressed. This is a public forum dear vivek, I may post wherever I wish as long as I am polite.

While you're at it, read the forum guidelines, I quote:

Keep It Pleasant
Do not post insults or personal attacks aimed at another member
Do not use offensive or obscene language

Keep it Clear
Do post in full-sentence English
Do not write in all uppercase or use "leet", "txt" or "chatroom" speak

Perhaps, you should go away and stop bothering the good people of Daniweb with your potty mouth.

Ha ha. Brilliant. Colloquial Londoner-speak too. I'm impressed. This is a public forum dear vivek, I may post wherever I wish as long as I am polite.

While you're at it, read the forum guidelines, I quote:

Keep It Pleasant
Do not post insults or personal attacks aimed at another member
Do not use offensive or obscene language

Keep it Clear
Do post in full-sentence English
Do not write in all uppercase or use "leet", "txt" or "chatroom" speak

Perhaps, you should go away and stop bothering the good people of Daniweb with your potty mouth.

****..its in pure english....if you understand this stay away from me and my post you, "***"....go away....i know what i have to do..mind your own business....

Member Avatar for diafol

Here's another one for you:

Keep It Pleasant
Do not try to bypass the DaniWeb inappropriate language filter

:)

Keep going buddy. Let's see if you can get some more under your belt.

Post removed, post snipped. Don't think you'll be here long. Shame. You're really entertaining. Made my day.

Ok, enough of this. If the thread can't get back on topic it will be closed.

Ok, enough of this. If the thread can't get back on topic it will be closed.

yeah close it....that *bleep* never gonna stop and u also...and also tell how to delete you a/c because if there are people like *bleep*, i dont wna waste my time here anymore...

yeah close it....

I think I'll go ahead and do that. This thread isn't likely to go anywhere except a downward spiral.

tell how to delete you a/c

Accounts aren't deleted so that Daniweb can conform to anti-spam laws. You can simulate the effect by removing all personal information and disabling contact options from your control panel. From there it's a simple matter of logging out and never returning. An admin can also reset your password if the temptation to log in in the future is too great.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.