Page 1 of 1

access denied www-data

Posted: Mon Nov 02, 2009 7:52 am
by Rapster
Hi Everyone!

I'm new to linux-php-mysql (though I'm not new to programming/developing)... so bear with me!

I installed Ubuntu 9.04, then installed Apache, PHP and MySQL using...

sudo tasksel install lamp-server

I created a php page, and saved in /var/www/. But when I opened the page in firefox, i get the following error message...

Access denied for user 'www'@'localhost'(using password: no) in /var/www/index.php on line 12.

The code for the php page is as follows:

<?php
ini_set("display_errors", 1);

$mysqli = new mysqli("localhost", "root", "mysql1234", "TonyTestDB");
if (mysqli_connect_errno())
die ("Error connecting MySQL: ".mysqli_connect_error());

$sql1 = "call GetUsers()"; //GetUsers is a stored proc in MySQL

$query1 = $mysqli->query($sql1);

$rt = mysql_query($query);

echo "$rt[FName], $rt[SName], $rt[UName], $rt[PWord]<br />";

?>


Any ideas, because I've looked through countless forums to no avail, and this is driving me crazy!

Many thanks in advance,
Tony

Re: access denied www-data

Posted: Mon Nov 02, 2009 11:58 am
by cpetercarter
OK, which is line 12? It helps if you put code between 'code' or 'php' tags.

Re: access denied www-data

Posted: Mon Nov 02, 2009 12:01 pm
by Rapster
Hi!

Thanks for your reply.

Well, I thought that this may have been the problem. I've changed the permissions on the /var/www/ folder over and over, but still with no success. As I said previously, I'm new to Linux, and I may not have set the correct permissions for the correct user/group. Could you advise me at all?

Cheers,
Tony

Re: access denied www-data

Posted: Tue Nov 03, 2009 2:17 am
by Rapster
Hi!

Cheers for the reply.

Can you tell me where I'm mixing MySQL and MySQLi, please?

Many thanks in advance.

Cheers,
Tony

Re: access denied www-data

Posted: Tue Nov 03, 2009 2:19 am
by John Cartwright
MySQL functions are prefixed with mysql

MySQLI functions (or objects) are prefixed with mysqli

Re: access denied www-data

Posted: Tue Nov 03, 2009 4:23 am
by Rapster
Hi!

Thanks for the reply!

Sarcasm is usually the lowest form of wit... however, I finally noticed where I was using a mysql function instead of a mysqli function. Sometimes you just can't see the wood for the trees!

Cheers,
Tony

Re: access denied www-data

Posted: Tue Nov 03, 2009 7:03 am
by Rapster
Hi all!

A big thanks to McInfo for your help. I am new to php and the error message really had me running down the wrong path. Because of this I just wasn't looking at the code straight. However, I've now had a good look at the mysql and mysqli pages on the PHP website and all is well and good!!!

many thanks,
Tony