|
Posted by Toby A Inkster on 06/14/07 12:26
vinnie wrote:
> <?php
> function connect()
> {
> // SERVER connection
> $con=mysql_connect('host', 'My_user_ID', 'My_Pwd');
> // DB selection
> $sql=mysql_select_db('Database_name');
> }
> ?>
<?php
function connect()
{
// SERVER connection
$con=mysql_connect('host', 'My_user_ID', 'My_Pwd');
// DB selection
$sql=mysql_select_db('Database_name');
return $con;
}
$con = connect();
?>
If you don't understand this, please read the PHP manual -- the part which
explains what a function is and how they work. Read the bits on variable
scope too.
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 110 days, 20:10.]
URLs in demiblog
http://tobyinkster.co.uk/blog/2007/05/31/demiblog-urls/
Navigation:
[Reply to this message]
|