Jump to content

Mysql connection getting denied for Apache, but i'm sending MY username?


Alex-Grim

Recommended Posts

As you can see from the code, i've declared all the variables in the class already, becasue they'll not change, but for some reason, when i try to connect and execute a query,  i get :

Access denied for user 'apache'@'localhost' (using password: NO)

 

But i've sent the password and the user name in my script?

<?php
echo "<h1>MySql.php is now included</h1>";
class MySql{
var $d="AlexGrim";
var $h="127.0.0.1";
var $u="webuser";
var $p="666";
var $connection;
var $query;
var $num;
var $array;
var $rows;


//	function MySql($h,$u,$p,$d){
//		$this->d = $d;
//		$this->h = $h;
//		$this->u = $u;
//		$this->p = $p;
//	}


function Connect(){
	$connection = mysql_connect("$h","$u","$p");
	mysql_select_db("$d", $connection);
}


function Close(){
	mysql_close($this->connection);
}


function Query($sql){
	$query = mysql_query($sql) or die(mysql_error());
	return $query;
}


function FetchRow($query){
	$rows = mysql_fetch_row($query);
	return $rows;
}

function FetchArray($query){
	$array = mysql_fetch_array($query);
	return $array;
}

function FetchNum($query){
	$num = mysql_num_rows($query);
	return $num;
}
}
?>

And here's the calling page, ignore the testing crap:

<?php
$br = "<br/><br/>";
$e = "<h1>ErRoR</h1>";
$myfile = "includes/classes/MySql.php";
if (file_exists($myfile)){
	echo "The file DOES exist. $br";
	include_once($myfile);
	echo "Page Loaded, and MySql.php included. $br";
}else{
   echo ($e."<h1>ErRoR! Content not available!</h1>");
}

$db = new MySql();
$con = $db->Connect();
$q = $db->Query("Select * from Comments");

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.