Now I have write 1 class in PHP 5
file db_connect.inc
<?
class db_connect {
var $host="localhost";
var $user="";
var $pass="";
var $dbname="test";
function db_connect() {
$conn = mysql_connect($host,$user,$pass);
if (!$conn) {
echo "Could connect to database".mysql_error();
return 0;
}
echo "Connected";
return $conn;
}
}
?>
file test.php
<?
require_once 'db_connect.inc';
$db = new db_connect();
echo $db->host;
echo $db;
?>
But error was output
Error was output at line mysql_connect($host,$user,$pass); . Can not connect. I don't know this error.
And have a different between PHP4 Class and PHP5 Class.
Thanks
Urgent, write Class with PHP
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
did you turn on mysql support in you php5 config? php5 doesn't come with mysql support by default. It does come with mysqli support, but it much be enabled, I believe..
a note to everyone else: placing urgent, help!, and the like does not make us rush in to see what the problem is any faster than posting like normal. So please, don't waste your time typing these things in your topic.
a note to everyone else: placing urgent, help!, and the like does not make us rush in to see what the problem is any faster than posting like normal. So please, don't waste your time typing these things in your topic.