"Access Denied" to database when using fetchEntrie

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
goodevilgenius
Posts: 4
Joined: Wed Nov 14, 2007 11:25 pm
Location: Austin, TX
Contact:

"Access Denied" to database when using fetchEntrie

Post by goodevilgenius »

On my website, I'd like one of my main pages to be able to grab blog entries from a specific category, and process them. The script that fetches the entries is located in the parent directory of s9y. s9y is locate in a directory called .serendipity.
Here's the part of my code that's giving me problems:

Code: Select all

function getAllVideos() {
  chdir('.serendipity');
  include 'serendipity_config.inc.php';
  $serendipity['GET']['category'] = 'videos';
  $entries = serendipity_fetchEntries(null, true);
  chdir('..');
  return $entries;
}
When my page tries to call this function, I get the following error:

Code: Select all

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'goodevil'@'localhost' (using password: NO) in /home/goodevil/public_html/joestryker/.serendipity/include/db/mysql.inc.php on line 270
I don't get the same error when accessing the blog directly.

Has anyone seen this error before? How do I get around it?
goodevilgenius
Posts: 4
Joined: Wed Nov 14, 2007 11:25 pm
Location: Austin, TX
Contact:

Post by goodevilgenius »

The same problem occurs if it's in the same directory as serendipity (removing the chdir commands, of course), so it's not a problem with being in a different directory.
goodevilgenius
Posts: 4
Joined: Wed Nov 14, 2007 11:25 pm
Location: Austin, TX
Contact:

Post by goodevilgenius »

Ok, I figured out some more about the problem. After some digging around, I discovered that for some reason $serendipity is not visible in serendipity_db_connect() (which is where the problem occurs in mysql.inc.php), even though the first line in the function is "global $serendipity." It's also definitely visible at the top of mysql.inc.php.

The reason this is causing the problem is because the line where the error occurs reads "$serendipity['dbConn'] = $function($serendipity['dbHost'], $serendipity['dbUser'], $serendipity['dbPass']);" so it's calling mysql_connect(null,null,null).

Ok, so here's the really weird thing. I have two serendipity installations running on the same server. I tried to the same thing with the other installation, and had no problem. It ran exactly as expected, and $serendipity was visible where it should be.

So, I'm stuck. This sounds like a PHP bug, but I don't understand why it works in one place, but not in the other.

Has anybody got ANY ideas?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Try to add a "global $serendipity" to your getAllVideos() function?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
goodevilgenius
Posts: 4
Joined: Wed Nov 14, 2007 11:25 pm
Location: Austin, TX
Contact:

Post by goodevilgenius »

garvinhicking wrote:Hi!

Try to add a "global $serendipity" to your getAllVideos() function?

Regards,
Garvin
Thank you so much! That did it!
Post Reply