I got it to work My problem was I didn't put include in function. So the
class file should be like this

<?
class Connect {

var $link;
function Connect() {

include('config.php');

$this->link = mysql_pconnect($sqlhost,$sqluser,$sqlpasswd);

if (!$this->link) {
printf("Could not connect to sql server");

}

mysql_select_db($sqldatabase);


}//end of function connect

}//end of class


?>
 than to call the link I just did.
$class = new Connect;
$class->link;

So anybody want more info on how to use this class I made email me at
[EMAIL PROTECTED]
cheers :)






"Frank Mancuso" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi I made this.
>
> <?
> //config.php
> $sqlhost = "localhost";
> $sqluser = "root";
> $sqlpasswd = "password";
> $sqldatabase = "project";
> ?>
>
> <?
> //sqlclass.php
> require('config.php');
> class Connect {
>
> var $link;
>
>
> function Connect() {
>
> $this->link = mysql_connect($sqlhost,$sqluser,$sqlpasswd);
> $select = mysql_select_db($sqldatabase,$this->link);
>
> }
>
> }
>
> ?>
>
>
> <?
> //index.php
> require('config.php');
> require('sql.php');
>
>
> $class = new Connect;
>
>
> $query = "SELECT * from houses WHERE city='toronto'";
>
> $result = mysql_query($query,$class->link);
>
> $row = mysql_fetch_array($result);
>
> echo "$row[title]"
>      ."$row[firstname]";
>
> ?>
>
>
>
> What I'm trying to do is make a function or class that I can call up when
> ever I want to connect to mysql.
> If anyone can explain if I've done something wrong or if I'm not calling
the
> function up.
>
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to