Hi All,
I am geting the following error while running the code
<?php
//set some connection attributes
$username = "root";
$password = "";
$hostname = "localhost";
$database = "taskforward";
//specify which database flavor to use
$dbms = "mysql";
require_once("DB.php");
//create a database link
//$link_id = mysql_connect($hostname, $username, $password) or die(mysql_error());
//connect to the database according to the connect string
$db = DB::connect("$dbms://$username:$password@$hostname/$database");
//select database
//mysql_select_db($database, $link_id);
//assign a sql statement to a variable
$sql = "select fname, password from tf_user";
//return result set to php
//$result = mysql_query($sql, $link_id) or die(mysql_error());
$result = $db->query($sql);
if(!$result) echo "wait no result set";
while($row = $result->fetchRow())
{
echo "fname is $row[1] <br> password is $row[3] <br><br>";
}
//free the resources available with the result set
//mysql_close();
$db->disconnect();
?>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
</BODY>
</HTML>
Error
Warning: main(DB.php): failed to open stream: No such file or directory in g:\web\php\php and database\db\ch02\test1.php on line 11
Fatal error: main(): Failed opening required 'DB.php' (include_path='.;c:\php4\pear') in g:\web\php\php and database\db\ch02\test1.php on line 11
But I can run the same code with out using PEAR :: DB like
<?php
//set some connection attributes
$username = "root";
$password = "";
$hostname = "localhost";
$database = "taskforward";
//create a database link
$link_id = mysql_connect($hostname, $username, $password) or
die(mysql_error());
//select database
mysql_select_db($database, $link_id);
//assign a sql statement to a variable
$sql = "select fname, password from tf_user";
//return result set to php
$result = mysql_query($sql, $link_id) or
die(mysql_error());
if(!$result) echo "wait no result set";
while(list($fname, $password) = mysql_fetch_row($result))
{
echo "fname is $fname <br> password is $password <br><br>";
}
//free the resources available with the result set
mysql_close();
?>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
</BODY>
</HTML>
can some one please tell me where I am going wrong?
Thanks in advance
Regards
Johnson