You are here:  » Problems getting feed into database


Problems getting feed into database

Submitted by tonyw on Tue, 2005-12-20 04:49 in

Hi,
Have been playing around with this today.
Can successfully get feed to print into HTML, but am getting access to the database denied.
Tony

Submitted by support on Tue, 2005-12-20 08:21

Hi Tony,

Please note that if you're using the affiliate datafeed example code then you would receive an access denied error if you have not already setup an appropriate database and table on your local installation of MySQL.

That example uses the litteral text "username" and "password" in place of where you would need to insert your own credentials, setup by you within MySQL or by your webhost / system administrator.

I am putting together an affiliate datafeed to database tutorial that will describe all the steps required which i'm hoping to get online shortly - that will help take you through all the steps required.

I'll let you know as soon as it's online...

Submitted by tonyw on Tue, 2005-12-20 09:33

Thanks David,
That's what I'm doing. OK will set up the database table and try it then,
Tony

Submitted by tonyw on Tue, 2005-12-20 12:02

Unfortunately still having problems despite setting up the table. Any thoughts? I'm trying to add the data to an existing Drupal database. Is this a problem?

Submitted by tonyw on Wed, 2005-12-21 15:38

David,
Any thoughts on this? Am getting the error message of denied access the database despite using the right words: localhost, my user name, password and then logging into the right database. I've set up a new table in the database with data types for all the fields. Where to from here?
Thanks
Tony

Submitted by support on Wed, 2005-12-21 15:39

Hi Tony,

Could you perhaps post some code snippets; this might help. I should be able to suggest what debug breakpoints to put in which will help us see what is going on...

Submitted by tonyw on Wed, 2005-12-21 18:37

David,
Here's the code:

<?php
  
require("MagicParser.php");
  
mysql_connect ("localhost""...my username here...""...my password here...");
  
mysql_select_db ("...the database name here...");
  function 
myRecordHandler($villa)
  {
    
$sql "
      INSERT INTO villas SET
        prop_ref = '"
.mysql_real_escape_string$villa["prop_ref"] )."',
        owner_ref = '"
.mysql_real_escape_string$villa["owner_ref"] )."',
        Title = '"
.mysql_real_escape_string$villa["Title"] )."',
        Summary = '"
.mysql_real_escape_string$villa["Summary"] )."',
        ImageLocation = '"
.mysql_real_escape_string$villa["ImageLocation"] )."',
        Filename = '"
.mysql_real_escape_string$villa["Filename"] )."'
      "
;
    
mysql_query($sql);
  }
  
mysql_query("DELETE FROM villas");
  
MagicParser_parse("files/xml/italian_villas.xml","myRecordHandler","xml|VILLARESULTS/VILLAS/VILLA/");
?>

The error messages are as follows:

Warning: mysql_connect(): Access denied for user '...my user name here...'@'localhost' (using password: YES) in /home/phuk3089/public_html/....the folder name here.../MagicParserVillas.php on line 4

Warning: mysql_select_db(): Access denied for user '....my username here....'@'localhost' (using password: NO) in /home/phuk3089/public_html/....the folder name here..../MagicParserVillas.php on line 6

Warning: mysql_select_db(): A link to the server could not be established in /home/phuk3089/public_html/...the folder name here.../MagicParserVillas.php on line 6

I have a mySQL table setup called villas with the various fields set up.

Submitted by support on Thu, 2005-12-22 06:45

Are you running phpMyAdmin on your server? If not, what tool have you used to create the table?

Most tools have a user administration section, so you could use this to double check the credentials that you are using to connect to the database - access denied implies that the MySQL library has been able to connect to the server; so it is all down to your username and password.

Another thing I would recommend would be to work outside Drupal; whilst I don't think Drupal would be getting in the way at all it is an unknown quantity that would not be helping if this is the first time you have written PHP code to accesss a database.

Submitted by tonyw on Thu, 2005-12-22 10:35

David,
Thanks. I'm using phpAdmin and used this to set up the table. I've emailed you the appearance of the table config in phpAdmin. I did try accessing the table outisde of Drupal but no improvement. I'm just looking at some of the phpAdmin documentation and see that underscores in usernames may cause problems with access. They talk about needing a backslash before the underscore. Is that right?

My user name for example is tonyw_drpl1 for this database and the database is tonyw_drpl1.

What should the php code contain to access such a database?

Submitted by tonyw on Thu, 2005-12-22 15:32

No longer getting the access error codes, it's now just not putting any data into the database!!