Either add
global $db;
as the first line of the function or change your function call to:
$db = db_conn("$host","$user","$pass","$dab");
I assume that $host, $user, $pass and $dab actually contain some correct
values.
Marco
--
------------
php|architect - The magazine for PHP Professionals
The first monthly worldwide magazine dedicated to PHP programmers
Check us out on the web at http://www.phparch.com
On Sun, 2002-11-10 at 01:58, conbud wrote:
> Hey
> Im trying to create a fucntion in an include file
> function db_conn($host,$user,$pass,$dab)
> {
> $db = mysql_connect("$host", "$user","$pass")mysql_select_db("$dab",$db);
> }
> ....
> ....
> In the page ide use:
> require('func.inc.php');
> db_conn("$host","$user","$pass","$dab");
> $result = mysql_query("select * FROM $page",$db);
> $myrow = mysql_fetch_array($result);
>
> echo $myrow['general_info'];
>
> ...
> ...
> however when I use the db_conn on the webpage I just get a mysql error
> saying not a valid resource, so how do I get the db_conn to actually return
> the data, ive tried using
>
> function db_conn($host,$user,$pass,$db)
> {
> $db = mysql_connect("$host", "$user","$pass")mysql_select_db("$db",$db);
>
> return $db
> }
>
> and various other thing but still nothing, I have to actually put the echo
> statements in the function too to get it to work properlly, any ideas?
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php