PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
//The database configuration file
//It connects the user to the DB
//Your SQL type
$dbase= 'MySQL';
//Your bduser string
$user = 'root';
//Your db pass
$pass = 'root';
//Your db host
$host = 'localhost';
//Your DB name
$db_name = 'zeuscms_02';
//This is the string that will be used for the connection
$dsn = '$dbase://$user:$pass@$host/$db_name';
//Require the Abstraction layer
require_once "dblayer/DB.php";
//Connect to the database
$db = DB::connect("$dbase://$user:$pass@$host/$db_name");
//If there is an error warn the user
if (DB::isError($db))
{
die ($db->getMessage());
}
$sql = "select * from news";
$demoResult = $db->query($sql);
while ($demoRow = $demoResult->fetchRow(DB_FETCHMODE_ASSOC)) {
echo $demoRow['headline'] . '<br>';
}
?>
Can someone please tell me why i get nothing??
Even if i change mysql string to mssql (mssql does not exist on my system) i don't get a message. I only get an error when i change mysql to smysql or something.
Can't see anything else obviously wrong.
Try putting error_reporting(E_ALL); as the first line of the script (after <?php) and see if there's any errors/warnings you're not seeing.