|
Posted by R. Ros on 10/04/33 11:07
include this on top of your function:
global $dbLink;
Hugo Westermann Castanho schreef:
> When i run this function , i get this error
> Warning: mysql_query(): supplied argument is not a valid MySQL-Link
> resource in e:\webserver\virtualnovo\test.php on line 8
> Warning: mysql_result(): supplied argument is not a valid MySQL result
> resource in e:\webserver\virtualnovo\test.php on line 9
>
>
> <?PHP
> $dbLink = mysql_connect( "host", "login", "password" ) or
> trigger_error (mysql_error (), E_USER_ERROR );
> $dataBase = "database";
> mysql_select_db ($dataBase, $dbLink);
>
> function fctSelect() {
> $varSQL = "select * from persons";
> $varQuery = mysql_query($varSQL, $dbLink);
> $testeOutPut = mysql_result($varQuery, 0, 'personName');
> return $testeOutPut;
> }
>
> echo fctSelect();
>
> ?>
>
>
> But if i include the conn settings inside the function everything
> works great. What am i missing here?
>
> Thanks in advance;
> HC
[Back to original message]
|