Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Error message


RojanUK

Recommended Posts

Guess what I've got back?

 

Warning: htmlspecialchars() expects parameter 1 to be string, array given in c:\program files\easyphp1-7\home\catalog\includes\functions\general.php on line 53

 

When I create a new account every works like a charm. The country_id gets input into the database, no errors, ordering can be done, country is displayed. The moment I want to edit my address book entry things go pearshaped. It takes the change I put in - I changed the housenumber - without any problems, but the country disappears and the account gets updated in the database with country_id=0 and so there's the htmlspecialchars error again...

 

No idea why the address_book_process.php does that. I can't seem to find a reason. Especially considering I'm using exactly the same coding as in Create Account and there it does work....

RojanUK

Link to comment
Share on other sites

  • Replies 78
  • Created
  • Last Reply
gives me an error message stating that I have to select a country from the list

That is right: in the JavaScript in the top of the document (oh well, in the source code at least, haven't checked from which file this is pulled) it does error checking and if the value of the field is the default value (which it is now) the JS code thinks that no country was selected.... So that is a explainable thing. Just take it out I would say, that line of JS code.

Still, I would go for the hidden field ;-)

 

I couldn't really see it, but perhaps the JavaScript "nulls" that POST parameter if there is a fault like that.

Link to comment
Share on other sites

Yeah, it was a bit silly of me not to have mentioned this before, but I'd already done that. I've taken the error message out and even though the Create Account still works as it should, the edit address book does not. It goes through when I take the error message out, but it wipes the country field clean and when the changes are put to the database the country_id=0 again. And then we're back to the original problem.

 

I would still prefer the hidden field scenario as well. Hopefully that will sort out this thing I have now too. And I don't want to stop searching for the hidden field scenario either, but in the meantime the site does need to work. Since this problem started I haven't been able to do any more developing of the site, as I don't see the point in investing a lot of time investing in a site that might never go live. As long as it's not working that's the situation I'm in. So I would like to have a working situation while looking for the perfect, hidden field solution.

RojanUK

Link to comment
Share on other sites

Did you edit this page also to "clean" it from the countries list? If so, then it all makes sense, since the database is updated with all the fields and since the field "country" is not existing, the default value or null goes into the dabase. Try adding the hidden field code to that page, between the form tags. I wouldn't be surprised if that would solve it.

Link to comment
Share on other sites

Please excuse my ignorance but I have no idea what you just said.

 

I switched the pulldown menu coding from the original to the static echo in two files: create_account.php and address_book_details.php. In both I've switched it back to the original programming. Then I've made the murdah change in the html_output.php file. That's it.

 

Create_account.php works, address_book_details.php doesn't. And this is a copy/paste job so it's the same coding in both files. In address_book_details.php - which gets called upon by address_book_process.php when you edit your details - I've tried to switch the error code off, but that results in the country_id and field being wiped. Leaving the error in just tells me to choose a country before I can continue, even though there's only one and that one is chosen by default. Same as in create account where it does work.

 

Adding a hidden field: I haven't got the faintest how to, mate I have to admit.... :(

RojanUK

Link to comment
Share on other sites

Latest news: I've solved the immediate problem. For starters I've been looking in the wrong file. The problem originated from address_book_process.php after all. I've replaced the shop's file with a stock version from a fresh installation and the problem is solved.

 

I've still got Murdah's solution installed in html_output.php and this works. OK, it's not the final solution yet - being getting rid of the pulldown menu all together - but at least I've got a working site again. And I know that both you and Murdah are working on the final solution, which includes writing whole new code which at this point in time is still very much beyond me, so I am very very grateful for everything you guys are doing. And I'll gladly but the solutions to the test of course... :D

 

Hopefully we'll get to the bottom of this thing in the end. ;)

RojanUK

Link to comment
Share on other sites

Hidden field, instead of:

?<td class="main"><?php echo ENTRY_COUNTRY; ?></td>
? ? ? ? ? ? ?<td class="main">United Kingdom</td>

Try this:

?<td class="main"><?php echo ENTRY_COUNTRY; ?></td>
? ? ? ? ? ? ?<td class="main"><input type="hidden" name="country" value="222">United Kingdom</td>

My expectation is that this will work the same as if you had chosen "United Kingdom" in a select list. Of course it should be put anywhere where the list of countries is displayed, provided it works...

Link to comment
Share on other sites

I just applied this to Create_account.php on my test installation - which i created yesterday obviously for testing purposes - and created a new account. No error messages. When I go to look in the database the country_id is set to 222. Seems like you cracked it!

 

And even applied to address_book_details.php for the editing of an existing account there's no error, country stays where it is and so does the country_id. Honestly I think you've got it!

RojanUK

Link to comment
Share on other sites

I've been testing like mad in the test installation, seeing if I can find all the pages with 'country' in them. So far I've only been able to locate three, which seems to be the main ones:

 

catalog/create_account.php

catalog/includes/modules/address_book_details.php

catalog/includes/modules/checkout_new_address.php

 

My tests so far haven't come up with a single page with the old setting in, after changing these three. Do you know of any other pages that need changing or are these it?

RojanUK

Link to comment
Share on other sites

Fabulous... you've cracked it mate! I've done some more testing since the last posting and everything is working smoothly. No error messages, and the database list the country_id as it should. Thank you so much!

RojanUK

Link to comment
Share on other sites

  • 1 year later...

Roger,

Ok, so maybe I'm too stupid to know what to do, but I read almost every post in 3 different threads trying to figure out how you got your shop to show only one country in the drop down list and have it work.

 

In my case, I need only the United States to show up- whether it is static or a drop down list, I don't care. Whatever is easiest. I want my shop to look similar to the screen shots that you posted at this thread.

 

Hopefully you will see this reply and will be able to help me by either making a contribution or just explaining what files need to be changed.

 

Much thanks if you can help.

Link to comment
Share on other sites

Roger,

Ok, so maybe I'm too stupid to know what to do, but I read almost every post in 3 different threads trying to figure out how you got your shop to show only one country in the drop down list and have it work.

 

In my case, I need only the United States to show up- whether it is static or a drop down list, I don't care. Whatever is easiest. I want my shop to look similar to the screen shots that you posted at this thread.

 

Hopefully you will see this reply and will be able to help me by either making a contribution or just explaining what files need to be changed.

 

Much thanks if you can help.

 

I had the same problem, and used a workaround that was posted here somwhere inthe board. than I messed up with my countires, languages, taxclasses and zones ... and was kind of 'lost in space'.

 

enigma1 helped me out, or in better words, he pulled the car out of the mud, and I just am really thankfull to him for that. the result was that we altered some code, that you can type in the countries to be listed.

 

GENIUOS and polite as enigma1 is he than sat down and wrote a contrib for that, in order to choose the countries to be allowed to sign on for in the admin section. I do have it here for testing, yet not implemented, as I will go live tonight with my store. you might want to see who it looks like -> https://elflein-kosmetik.de/create_account.php.

 

same will than be working for all customer address pages

 

he asked me to test this before implementing, which I will do on weekend due to time. I do notwant to spread hes work so you might contact him by pm and for sure he will send ya the code to be alpha-tester as well. but do not worry any problem I had he fixed! so the code I have now workz and the contrib to be launched will even be better ;)

 

dahui

Link to comment
Share on other sites

  • 1 month later...

I have a live site (up to about 3000 orders now) and I've had a couple of reports of problems of missing orders recently. One customer made a note of the error message and it was the htmlspecialchars error discussed here. It has happened a couple of times in the last 3 months. I've had another report again today and amazingly, although I'm sure this can't have anything to do with the error, both customers have the surname Roberts. Spooky coincidence or what?!!!

Anyway has there been a definirive fix for this or does anyone even know what causes it? It must be something that most customers don't do to their address book (like maybe make changes to it) otherwise my site would be out of business with the complaints. As it is this problem seems only to occeu very occasionally. Any help much appreciated.

Link to comment
Share on other sites

Still no luck getting any help with this. I've had another order today where the payment has been received but no order created.

My workaround is to recreate the order in the a dummy account with the name and address of the customer as the delivery name/address.

The thread here doesn't seem to propose a definitive solution and my problem is that this only happens occasionally and I can't simulate it.

I haven't installed any contributions for a while (I learned the hard way along time ago - if it ain't broke don't fix it!) so can't figure that I've done anything that would cause this. I've read the thread above and it doesn't seem like anyone knows why this bug occurs.

Help please?

Link to comment
Share on other sites

I haven't got time to try and sort this out myself as this is my busiest time of year. I have ?200 or $300 for the person who can provide an explanation and a fix. I don't care if it's one line of code.

I have 3 sales yesterday that I have payments but no orders for. If you are interested in sorting out this bug and your fix works, the money will be paid into your paypal account asap

Help please. Contact me first as I'm happy to pay for the fix but don't want 6 people trying to bill me!!

 

And this isn't the protx problem posted below. I'm using SECPay. Could it be a similar problem??

Link to comment
Share on other sites

I haven't got time to try and sort this out myself
Since it occurs only occasionally... just a hunch... could it be related to the bug which was fixed in the November 13 update?

customer_country_id in addressbook
http://www.oscommerce.com/community/bugs,1662
------------------------------------------------------------------------------

Problem:

When the customer updates their address in the My Account page, their country value is being stored in an incorrect variable that can cause an incorrect tax rate value being used in product prices.

Solution:

The following lines must be replaced in catalog/address_book_process.php:

Line 150, from:

$customer_country_id = $country_id;

to:

$customer_country_id = $country;

Line 171, from:

$customer_country_id = $country_id;

to:

$customer_country_id = $country;

Link to comment
Share on other sites

  • 4 months later...

It seems like everytime I install a store I get this error and I forget how I fixed it earlier. This is the latest fix that I did that worked for me. I just plow throught stuff to fix it, maybe not the best method.

 

Ok here goes:

1. I get the error, crap, then it tells me what line of includes/functions/general.php it is on. Line 44 in my case.

 

2. I go to the file and I see this:

if ($protected == true) {
  return htmlspecialchars($string);

Because PHP is so great with error messages I know exactly what is wrong, at some point the variable $string is an array instead of a $string. So to find out whay is going on I used my favorite function in the whole world for debugging: print_r(

 

3. I now change the code to this for debugging:

if ($protected == true) {
print_r($string);
  return htmlspecialchars($string);

, save it and rerun the page I'm having problems with. Now it seems obvious that it was the country because that is the only one that returned an array. The array had 3-

 

4 parts and the part I wanted to show was [title] (you might want something else). So now I want the PHP code to check if it is an array, and if it is I want it to only show me the title, then I won't get that error.

So I changed the original code from:

if ($protected == true) {
  return htmlspecialchars($string);

 

to:

 

if ($protected == true) {
if (is_array($string)) {
$string=$string[title];
}
  return htmlspecialchars($string);

 

And it works great for me.

 

explanation:

if (is_array($string)) {

$string=$string[title];

}

 

This if statement checks the $string variable each time to see if it is an array, then if it is it only grabs the [title] portion for me to use.

 

I put the logic into this post to help you diagnose your OWN problem and follow my logic that I used to fix mine. Usually I have seen this is just a problem with the country array. I think my blurp of code is very easy, and very unobtrusive because $string should NEVER be an array or it will throw that error, and so my code just fixes it if it is an array. Good fix.

B)

Link to comment
Share on other sites

  • 4 months later...

Hi Ben - thanks very much for your fix. It has made my paypal express checkout function - whereas before I was getting the dreaded error of the html char's.

 

gracias!

Link to comment
Share on other sites

  • 9 months later...

I have the same error except my error only comes up when the customer is in "my account" and they click "view" to view the order details. Can anyone help with this one?

Link to comment
Share on other sites

  • 4 months later...

Archived

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

×
×
  • Create New...