Re: One last kick at the cat
| From: | Kurt Lieber | Date: | Sun, 28 Oct 2001 22:25:55 +0000 |
| Subject: | Re: One last kick at the cat | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-72646@lists.php.net to get a copy of this message | ||
On Sunday 28 October 2001 12:57 pm, you wrote:
> It seems that when I try to connect to my database inside "function
> Table_Title()", my function cannot read the values of $server, $user,
> $pass, "$db or $table ???
you need to declare the variables as global. See below and also see the
manual to understand how global works.
> <?php
>
> $server = "localhost";
> $user = "MyAccount";
> $pass = "MyPassword";
> $db = "MyDatabase";
> $table = "bookmark_unit4";
>
> function Table_Title()
> {
global $server,$user,$pass,$db,$table;
> $myconnection = mysql_pconnect($server,$user,$pass);
> mysql_select_db($db,$myconnection);
>
> $news = mysql_query("SHOW TABLE STATUS FROM ".$db." LIKE
> '$table'");
> while ($news_story = mysql_fetch_array($news))
> {
> $table_comment = $news_story['Comment'];
> }
>
> echo $table_comment;
> //echo "Nothing";
> }
> ?>