Dear users,
I am new to PHP5. My LAMP is working just fine.I made small database connect scripts and they just worked as it should.Then I tried the following code and run the mysql.php but showing me following error:
Could not run query: Access denied for user 'www-data'@'localhost' (using password: NO)
My user name is root and password is root.Please check to help me.God bless you all.
<?php
/*database.inc.php
*
*/
define($server, "localhost");
define($conn_username, "root");
define($conn_password, "root");
define($database_name, "database_1.1");
?>
I think there is some mistake somewhere here:
<?php
class mysql
{
var $server;
var $conn_username;
var $conn_password;
var $database_name;
var $connection;
var $select;
var $query;
function connect()
{
require "database.inc.php";
$connection = mysql_connect($server,$conn_username,$conn_password);
$select = mysql_select_db($database_name,$connection);
}
function query($query)
{
$result = mysql_query($query);
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
}
function end()
{
mysql_free_result($connection);
}
}
$mysql = new mysql();
$mysql->connect();
$mysql->query("SELECT * FROM Employee");
$mysql->end();
?>
It will be really helpful if anyone can show me how to get the output in the browser.I want to see a row of the table.