Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Unable to connect to database server (postgreSQL)


Guest

Recommended Posts

Using the patch discussed on this thread,

 

http://www.oscommerce.com/forums/index.php?showtopic=56096

 

I am receiving the following error.

 

Warning: Unable to connect to PostgreSQL server: pqReadData() -- read() failed: errno=0 No error in G:\WebSites\vius\apps\store\catalog\includes\functions\database.php on line 21

Unable to connect to database server!

 

I don't know what this would mean, or what to do to fix it. This is my first experience with PHP so I'm not very good at debugging.

 

I did check the connection string and it looks alright. The offending code is:

$$link = pg_connect($conn_string);

I have tried a couple of PHP resources, but not being familiar with PHP...

 

Has anyone else tried this and pulled it off?

Link to comment
Share on other sites

Alright... if no one else can help me... I'll just help myself!

 

I managed to get it working (I don't know how well, but it is working :unsure: ).

 

The good news is: I MADE NOTES!!

Install:
1. Copy "extras/pgsql/database.php" -> "catalog/includes/functions/database.php"
2. Copy "extras/pgsql/database.php" -> "catalog/admin/includes/functions/database.php"
3. Create a new database
4. Run the sql script within that database (extras/pgsql/oscommerce.sql)
5. Edit "catalog/includes/configure.php"
  - lines 40-45
  - modify to point to created database
  
  - lines 16-24
  - modify other variables to point to correct paths
  - no links or images worked until this was fixed.


postgreSQL/PHP Issues:
1. postgreSQL not configured for tcp/IP
  - on boot: pg_ctl start
  - changed: pg_ctl start -o "-i"

2. postgreSQL not configured to allow logins over TCP/IP from anywere but local
  - editted pg_hba.conf
  - added line to allow webserver to login:
     host       store       <webserver IP>     255.255.255.255    password

3. dbFunction names have changed
  - I am running an old version of PHP
  - kept getting an error that certain functions were undefined
  - solution 1: update your PHP (better)
  - solution 2: search & replace in "catalog/includes/functions/database.php"
                - "pg_query" -> "pg_execute"
                - "pg_num_rows" -> "pg_numrows"
                - "if (++$pg_row[$db_query] >= pg_numrows($db_query))" -> "if (++$pg_row[$db_query] >= tep_db_num_rows($db_query))"
                the last one may be a change that should be made in the distrobution of the patch?

If you have questions feel free to post them, I will try to answer them if I can.

 

Hope someone finds this useful... Let me know if you do... (I like the warm fuzzy feeling).

Link to comment
Share on other sites

Found a bug (if running with postgreSQL):

 

* /catalog/admin/includes/boxes/configuration.php

Problem: The menu is not displaying in the admin area (for configuration).

Solution:

- Lines: 25-27 (ish)

- change all of the column names to lower case

configuration_groups_query = tep_db_query($strSQL);
while ($configuration_groups = tep_db_fetch_array($configuration_groups_query)){
 $cfg_groups .= '<a href="' . tep_href_link(FILENAME_CONFIGURATION, 'gID=' . $configuration_groups['cgid'], 'NONSSL') . '" class="menuBoxContentLink">' . $configuration_groups['cgtitle'] . '</a><br />';
}

Link to comment
Share on other sites

  • 5 months later...

In advance, I'm sorry to resurrect such an old topic.

 

I'm going to be installing osCommerce soon, and I want to back it with PostgreSQL.

 

Do you know of a place to mirror the patch posted in the original thread, since it seems to be down.

 

Also, I'm assuming you patched against 2.2 milestone 2?

 

Does this patch just do the 'main' functionality? or does it also store the cookies in the DB too?

 

I am a C++ coder by profession, and have done a lot of work with SQL databases, so I'm perfectly willing to take the patch, apply your corrections, and then, if the cookie support was not included, make the relevant changes there too, however I don't want to have to re-invent the wheel.

 

Everything on my system is PostgreSQL backed - I don't have MySQL even installed, I just prefer PostgreSQL, and osCommerce looks like a very good product.

 

I looked at the latest CVS source, browsing it online, it seems that the database functions still use mysql_* functions ;), rather than something like:

if (DB_TYPE == "mysql") { mysql_X(y); } else if (DB_TYPE == "pgsql") { pgsql_X(y); }

Which is pretty much all that is required, apart from ensuring the SQL is standard.

 

Once done, I'll submit a unified patch that will enable pgsql without disabling mysql back to the devs for inclusion - though I'm not a PHP coder, after C and C++ (and perl, and some python, and shell, etc) I can muddle my way through it.

 

Theres no reason for osCommerce to not support Postgres, since the pgsql_* functions are just as standard as mysql_* functions. And if someone submits a patch that 'just works, and does not break existing functionality', then its more likely to be accepted.

 

Please let me know,

 

PreZ :)

GOTH.NET Systems Administrator (http://www.goth.net)

Founder of The Neuromancy Society (http://www.neuromancy.net)

Gentoo Linux Developer (http://www.gentoo.org)

PreZ :)

Link to comment
Share on other sites

In advance, I'm sorry to resurrect such an old topic.

 

I'm going to be installing osCommerce soon, and I want to back it with PostgreSQL.

 

Do you know of a place to mirror the patch posted in the original thread, since it seems to be down.

 

Also, I'm assuming you patched against 2.2 milestone 2?

 

Does this patch just do the 'main' functionality? or does it also store the cookies in the DB too?

 

I am a C++ coder by profession, and have done a lot of work with SQL databases, so I'm perfectly willing to take the patch, apply your corrections, and then, if the cookie support was not included, make the relevant changes there too, however I don't want to have to re-invent the wheel.

 

Everything on my system is PostgreSQL backed - I don't have MySQL even installed, I just prefer PostgreSQL, and osCommerce looks like a very good product.

 

I looked at the latest CVS source, browsing it online, it seems that the database functions still use mysql_* functions ;), rather than something like:

if (DB_TYPE == "mysql") { mysql_X(y); } else if (DB_TYPE == "pgsql") { pgsql_X(y); }

Which is pretty much all that is required, apart from ensuring the SQL is standard.

 

Once done, I'll submit a unified patch that will enable pgsql without disabling mysql back to the devs for inclusion - though I'm not a PHP coder, after C and C++ (and perl, and some python, and shell, etc) I can muddle my way through it.

 

Theres no reason for osCommerce to not support Postgres, since the pgsql_* functions are just as standard as mysql_* functions. And if someone submits a patch that 'just works, and does not break existing functionality', then its more likely to be accepted.

 

Please let me know,

 

PreZ :)

GOTH.NET Systems Administrator (http://www.goth.net)

Founder of The Neuromancy Society (http://www.neuromancy.net)

Gentoo Linux Developer (http://www.gentoo.org)

have you found the anwser/solution? i need to use postgres as well.

Link to comment
Share on other sites

Considering nobody bothered to reply, you can assume no, so I'm going to have to do (or get done) all the legwork myself.

 

Which is annoying, since I hate repeating work thats already been done once.

PreZ :)

Link to comment
Share on other sites

  • 1 month later...
Considering nobody bothered to reply, you can assume no, so I'm going to have to do (or get done) all the legwork myself.

 

Which is annoying, since I hate repeating work thats already been done once.

Which I've done for the past hours.

 

I've got a running database with all the appropriate data. I'm now debugging the oscommerce scripts. At least the main page & session stuff are working, heh.

 

Stumbling with non-standard SQL constructions like 'select [..] if(s.status, s.price, p.price)' really leaves a bad taste. What does the original writer of this piece of code have to say about this?

 

Building internet applications is about using standards as building blocks. Not using non-standard things like mySQL-specific syntaxis.

</rant>

 

Apart from that, it looks good. ;)

 

Pitr

XIDC

--

http://pitr.net | http://www.xidc.nl/

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

 

It has been some time since this thread has been posted on. I was just wondering if any of you have gotten osCommerce to work with PostgreSQL. If so, what version of osCommerce and PostgreSQL are you running?

 

I'm very interested in how you have converted osCommerce to work with PostgreSQL because I'd like to know whether using osCommerce for our company website would be the best solution. Please drop me a line about your progress.

 

Thanks,

Adelaide

Link to comment
Share on other sites

Stumbling with non-standard SQL constructions like 'select [..] if(s.status, s.price, p.price)'  really leaves a bad taste. What does the original writer of this piece of code have to say about this?

It wasnt written with database independence in mind so mysql specific code was used to get the best performance.

 

:)

Mark Evans

osCommerce Monkey & Lead Guitarist for "Sparky + the Monkeys" (Album on sale in all good record shops)

 

---------------------------------------

Software is like sex: It's better when it's free. (Linus Torvalds)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...