Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help with checkout_process.php


Guest

Recommended Posts

Hi there,

 

I was just wondering if anyone could help me out with an error I am receiving on my site.

To explain what exactly I have is as follows :

 

I have paid a programmer to help me out as I am running osCommerce with PostNuke so that if a person signs up with either osCommerce or PostNuke then they are automatically logged into both systems.

 

I then have groups setup in PostNuke to be able to add a person to upon the successful purchase of an item from the osCommerce side.

 

Once they have purchased an item they can then go to PostNuke and download the item. If they haven't purchased it then it tells them to go and do so and then they can download it.

 

I have done the site like this as I needed to use the full CMS management capabilites for the main information on the site as I envisage the site becoming quite large. I am then using osCommerce for people to purchase items as basically I think that it is the best software out there full stop!!!

 

The problem I am having though (down to the nitty gritty now!!!) is when someone goes to purchase an item they click through all the sections fine but when they go to click on the last submit button to use the 'checkout_process.php' file the following error appears :

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/local/psa/home/vhosts/themusicbuilders.com/httpdocs/musicbuilders/checkout_process.php on line 227

 

[pre]Warning: Cannot modify header information - headers already sent by (output started at /usr/local/psa/home/vhosts/themusicbuilders.com/httpdocs/musicbuilders/checkout_process.php:227) in /usr/local/psa/home/vhosts/themusicbuilders.com/httpdocs/musicbuilders/includes/functions/general.php on line 29

[/pre]

 

In the file 'checkout_process.php' the programmer has made slight alterations so that the product in osCommerce is noted and then a groupID number which has been added into the admin side of osCommerce is placed into the PostNuke groups section for each item purchased by the user so that they can download the items.

 

I have seen the installation working fine on the programmers server and it works like a dream but it is now stumping both of us as to why it won't work on my server.

 

I was just wondering if anyone had any ideas as to why this might be??

 

The code (only part of the whole job that he did) that has been added to the 'checkout_process.php' file is shown below :

 

 

/*********Changes Start************/

$result=mysql_query("select distinct(pn_gid) from products where products_id in(select products_id from orders_products where orders_id=$insert_id)");
while($row=mysql_fetch_array($result))
{
$gid=$row[0];
echo "<br>select * from nuke_group_membership where pn_uid=$customer_id AND pn_gid=$gid";
$check=mysql_query("select * from nuke_group_membership where pn_uid=$customer_id AND pn_gid=$gid");
$items=mysql_fetch_array($check);
if($items[0]==0){
 mysql_query("insert into nuke_group_membership values($gid,$customer_id)");
 echo "<br>insert into nuke_group_membership values($gid,$customer_id)";
}
}

/*********Changes End************/

 

This hopefully will mean something to someone somewhere and maybe someone could help me to figure all this out?

 

Thank you in advance for any help that you might be able to shed on this.

 

The programmer has been excellent with everything that he has done so far but this last bit is now getting a bit problematic so I thought I would ask on these forums as I know that you are all brilliant at what you do and someone may have seen this kind of thing before.

 

 

Regards,

 

Mark Bowen

Link to comment
Share on other sites

your programmer should know this, very simple, do a search of 'headers already sent' in the knowledge base and you can fix the end of the file, line 227.

Link to comment
Share on other sites

Hi John,

 

Thanks for the exceptionally fast reply!! I have actually come across the header thing before and knew about the white space at the end of files but I have already checked that out on every file in osCommerce to make sure that they definitely didn't have any there and they don't (unfortunately!).

 

I think it has more to do with the first part of the error but with my limited knowledge of programming I am not really too sure as to what the error means is goint wrong.

 

If possibly you have any more ideas then I would be massively greatful.

 

Thanks for all the help so far though.

 

Link for anyone who has had the header problem :

 

http://www.oscommerce.info/kb/osCommerce/G...mon_Problems/15

 

Thanks John,

 

Regards,

 

Mark

Link to comment
Share on other sites

I see not a lot has changed in my absence - place is still full of bumbling newbees hiring incompetent programmers.

 

It is the version of MySQL you are using. Versions of MYSQL prior to 4.1.XX don't support subqueries.

 

$result=mysql_query("select distinct(pn_gid) from products where products_id in(select products_id from orders_products where orders_id=$insert_id)");

 

 

This is an example of a subquery.

Link to comment
Share on other sites

Hi there,

 

Thanks for the insult but also for the reply stroke answer :D .

I had actually thought that it might be something like that as I had never seen a query like that before in my life. I thought at first that he was maybe using some new MyISAM type of database that allows foreign key relationships but soon found out that wasn't the answer.

 

I am not actually a total newby thanks. I have actually installed over 25 versions of osCommerce with completely changed designs but I had to get a programmer in on this one as I needed osCommerce and PostNuke to work together seamlessly which were beyond me!

 

If possible could you possibly tell me how this could be fixed as I really need to get this up and running as soon as possible.

 

Thanks for the email and the help though.

 

Best wishes.

 

Mark

Link to comment
Share on other sites

Hi there,

 

That's fine. I know what it must be like to have us lot pretending we know what we're doing. I must admit I sometimes feel like that at work where I am the Senior Producer for the second largest Independent Commercial Production studio in the UK. Some of the people we work with I just want to throttle sometimes as I just think to myself that they should know the answer. I never do throttle them though. I just wish it!!! :D

 

If I could possibly be a bit more pushy and ask how would I go about rewriting it?

I know a little about PHP and coding queries but really only fairly simple ones. I actually was one of the technical advisors on the 'Advanced PHP For Flash' book that came out some time ago where we made forums and chat applications using a combination of Flash / PHP & MySQL but none of the queries were ever all that complicated.

 

If you could help me out with this at all then I would be eternally grateful.

I would like to release the code to the osCommerce and PostNuke communities when it is all stable to say a big thankyou for all the great work everyone puts in on the forums. It did cost me over $600 to get the work done but he has done a fantastic job and I think it was probably maybe slightly my fault as I never knew about the many different versions of MySQL and so never told him the version as I didn't even think it would matter!! There you go, you learn something new everyday!! I won't forget that in a hurry!!! :D

 

Thanks for all the help again and if you could possibly let me in on how to rewrite it or maybe point me in the right direction then I would be forever in your debt!!

 

 

Best wishes.

 

Mark

Link to comment
Share on other sites

Hi there,

 

All I can say is a massive thanks for this. It did the trick marvellously, well, at least on that one file. I have now passed this information on to the programmer who is changing any files that have sub-queries in them into standard table joins.

 

Just out of interest do you know of any really good sites that teach all about joins and the such maybe even with some downloadable database table examples. I would really like to take back up my learning these kinds of things and thought you might know of somewhere that could help?

 

Anyway another massive big thanks for the code snippet!!

 

Best wishes,

 

Mark

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...