access denied www-data

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!

Moderator: General Moderators

Post Reply
Rapster
Forum Newbie
Posts: 5
Joined: Mon Nov 02, 2009 7:45 am

access denied www-data

Post 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
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: access denied www-data

Post by cpetercarter »

OK, which is line 12? It helps if you put code between 'code' or 'php' tags.
Rapster
Forum Newbie
Posts: 5
Joined: Mon Nov 02, 2009 7:45 am

Re: access denied www-data

Post 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
Rapster
Forum Newbie
Posts: 5
Joined: Mon Nov 02, 2009 7:45 am

Re: access denied www-data

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: access denied www-data

Post by John Cartwright »

MySQL functions are prefixed with mysql

MySQLI functions (or objects) are prefixed with mysqli
Rapster
Forum Newbie
Posts: 5
Joined: Mon Nov 02, 2009 7:45 am

Re: access denied www-data

Post 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
Rapster
Forum Newbie
Posts: 5
Joined: Mon Nov 02, 2009 7:45 am

Re: access denied www-data

Post 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
Post Reply