Hi,
I am getting "No Database selected" eroor,Here's the code:
and here's the code for database.php:
When I don't use require 'database.php' and
use
it works!!.. But I have to use require database.php..Where am I going wrong?..
Any help would be appreciated.
Thank You
I am getting "No Database selected" eroor,Here's the code:
<?php
$Username = $_POST['username'];
$Password = $_POST['password'];
// 3020ta, 3020
if (($Username != '3020ta' AND $Password != '3020') && ($Username != 'asdf' AND $Password != '') &&
($Username != '1000' AND $Password != '2000') && ($Username != '1100' AND $Password != '1200')&&
($Username != '1111' AND $Password != '2222'))
{
//echo $error_message
echo '<a href = "Login.html"> Back To Login Page</a>';
}
else
{
require 'database.php';
$sql = "SELECT * FROM akkiran";
$result = mysql_query($sql) or die(mysql_error());
echo "<table border='1'>";
echo "<tr><th> Crt.no.</th> <th>Student id</th> <th>Password</th> </tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr><td>";
echo $row['Crt.no.'];
echo "</td><td>";
echo $row['student_id'];
echo "</td><td>";
echo $row['password'];
echo "</td></tr>";
}
}
echo "</table>";
?>
and here's the code for database.php:
<?php
$dsn = 'mysql:host=127.0.0.1;dbname=ITEC3020';
$username = 'hhhhhh';
$password = '123456';
try
{
$db= new PDO($dsn, $username, $password);
}
catch (PDOException $e)
{
$error_message = $e->getMessage();
include('database_error.php');
exit();
}
?>
When I don't use require 'database.php' and
use
$connect = mysql_connect("127.0.0.1", "hhhhhh", "123456");
mysql_select_db("ITEC3020");
it works!!.. But I have to use require database.php..Where am I going wrong?..
Any help would be appreciated.
Thank You