Hi fibo,
thanks for your reply.
1- I'm working on localhost (not uploaded yet)
2- I didn't really understand what you meant by #2
thanks alot
Main Topics
Browse All TopicsHi,
I have recently installed the ar_SA extension for arabic translation on my magento site. However, when I choose a language (English or Arabic) on my frontend interface through the "your language" drop down, I get the following error:
Warning: PDO::quote() expects parameter 1 to be string, object given in C:\xampp\htdocs\battery\li
However, if I navigate to an arabic page by providing the explicit link: http://localhost/battery/i
Whats causing the error is actually the Your Language drop down.Even if I try to switch back to English, I get the same error.
any help is appreciated..
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
1- OK. Unless you run Vista you should not have too many problems there
2 - If you look at the source code of your page, you will see just before <body> a huge javascript which handles translations by replacing "on the fly" in the source code of the page english strings by their "local" counterpart. If any of this strings contains an unescaped apostroph, you might have problems.
OK, yes, this is the code I wanted.
Looking at this code:
- facts: the language name (or rather, the store name) appears as being "91(J" in latin characters (might be different in an arabic display); you did not paste it, but I would bet that there is an extra </div> close to the code you pasted. IF there is no </div> close to the end (with no <div> in between) then this might be the source of the problem. otherwise i see no possible explanation.
Now, a small note of WARNING:
- although Magento code and display suggest a change in language, it is in fact a change in STORE. You are changing from one store to the other.
- this is totally different from the change in language, where all translatable strings are translated by their equivalent.
- it so happens that currently you "default" store is labelled English and that, presumably, default language for this store is English; you have another store labelled Arabic for which I presume you selected Arabic at the default language...
So the problem you currently have is NOT a LANGUAGE switch, but a STORE switch... which does not make it less of a problem, but at least places the focus on the problem.
You said that switching store from the rolldown list does not work, but that browsing directly to
http://localhost/battery/i
Can you check if the following links work correctly:
http://localhost/battery/i
http://localhost/battery/i
I tried both links:
http://localhost/battery/i
http://localhost/battery/i
They produce the following error:
Warning: PDO::quote() expects parameter 1 to be string, object given in C:\xampp\htdocs\battery\li
.... Which is the same as the error produced by changing languages with the drop down list!
And I can see a div closing the code I pasted:
1 - There is probably another </div> more or less close.
But it does not matter, because
2 - These 2 links are those generated by the code in the options list. Since they both fail when typed directly, the </div> play no role in the failure.
3 - So the extra part &___from_store=xxxx is responsible for the problem, since when you are not using it all is fine.
This is generated by the php code echo $_lang->getCurrentUrl() (which generates the complete URL).
4 - Can you test first going to http://localhost/battery/i
5 - Which options have you selected for url generation, specially for the part that concerns the store?
4-
going to http://localhost/battery/i
working fine
THEN selecting language English:
crash (same error as before)
http://localhost/battery/i
working fine
then selecting language arabic:
crash (same error as before)
So, yes they are both working for the first and crashing for the second.
5- How do I select specific options for url generation?
OK.
My idea is simply to preposition HTML code instead of the php generated one.
Starting from the php code you gave in your post 25741364
<?php if(count($this->getStores()
<div class="language-switcher">
<label for="select-language"><?php echo $this->__('Your Language:') ?> </label>
<select id="select-language" onchange="window.location.
<?php foreach ($this->getStores() as $_lang): ?>
<?php $_selected = ($_lang->getId()==$this->get
<option value="<?php echo $_lang->getCurrentUrl() ?>" <?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->ge
<?php endforeach; ?>
</select>
</div>
<?php endif; ?>
I would "hardcode" the option list itself, so that would be:
<?php if(count($this->getStores()
<div class="language-switcher">
<label for="select-language"><?php echo $this->__('Your Language:') ?> </label>
<select id="select-language" onchange="window.location.
<?php /* foreach ($this->getStores() as $_lang): // replaced by hard-coded html
?>
<?php $_selected = ($_lang->getId()==$this->get
<!-- option value="<?php echo $_lang->getCurrentUrl() ?>" <?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->ge
<?php endforeach; */ ?>
<?php // start of hard-coded html
?>
<option value="http://localhost/ba
<option value="http://localhost/ba
<?php // end of hard-coded html
?>
</select>
</div>
<?php endif; ?>
Note:
1 - I suggest you comment as I did so that later you remember what was done and why
2 - Unless the phtml file, of which this code is part, is placed in a /theme/ directory tree in parallel with the Magento provided one (whether it is 'default', 'bmlank' or equivalent), these changes will probably be wiped out at the next Magento update
ok now it's working..
But I'm concerned about 2 issues:
1. when I choose Arabic, it automatically converts back to English (even though it takes me to the arabic page). I want it to stay on Arabic when I'm on the arabic page.
2. is this method safe? or is there a possibility that something may go wrong later?
thanks for your help
2 - I am just "cleaning" the html code from what is generated to what works. So there should be no ulterior surprise.
It seems though that as you pointed it is not working perfectly.
1 - I could not test fully my change, and did not found the problem you mention.
Just to be sure of what is happening:
- You have 2 stores, one called English which is the default one, another which is called Arabic. (Remember that these are store names, not really languages)
- The default language in your English store is English, the default language in Arabic store is Arabic (we are associating stores and language).
From what I understand:
- With my code, you are changing store but not language, ie when you are on the English store with its default English language, and you switch to the Arabic store, the switch works BUT the language is not switched.
Is that a correct description of the situation?
actually what I was trying to say is:
when I'm on the English page (default store), and use the drop down to select the Arabic store, the correct page will appear (same page with arabic language). However, the problem is that the drop down menu automatically switches back to "English" (I want it to stay on "arabic"). This is just a display issue. I know there's a simple way to do this but I really can't remember how (I think you need to echo 'selected' when the option is selected or something like that)
Another problem is that if I'm on the let's say the product page, and I choose "arabic", it takes me to the arabic homepage instead of the arabic product page..
<<However, the problem is that the drop down menu automatically switches back to "English" (I want it to stay on "arabic"). This is just a display issue. I know there's a simple way to do this but I really can't remember how (I think you need to echo 'selected' when the option is selected or something like that)>>
OK. So the problem is that the dropdown list does not reflect correctly that a store is selected. I will change the code for that to-morrow (I need to think to a clever way).
<<Another problem is that if I'm on the let's say the product page, and I choose "arabic", it takes me to the arabic homepage instead of the arabic product page..>>
Oops... sorry for this mistake. Not sure how the change I propose below works..
Change
<option value="http://localhost/ba
<option value="http://localhost/ba
to
<option value="<?php echo getCurrentUrl(); ?>?___store=default" >English</option>
<option value="="<?php echo getCurrentUrl(); ?>?___store=arabic" >91(J</option>
------------
Remark: although I believe this solution to be "safe" once it works,
-- remember that they might be wiped during a Mahento update
-- they do not solve tyhe undelying problem, which might resurface later. it should be considered as a temporary "stop remover" to allow you to proceed.
for some reason, it's not working on the arabic page anymore :S
when I'm on the arabic page and choose English, it just takes me back to the arabic page again. However, the page URL changes to: http://localhost/battery/i
instead of: http://localhost/battery/i
The code you have typed is not the one I suggested. For which BTW i am not suer it works.
The main difference is that instead of using
$_lang->getCurrentUrl();
as you typed, I suggest to use
getCurrentUrl();
which I somehow expect to appear as http://localhost/battery/i
and which would then generate http://localhost/battery/i
ok I was able to figure out the url that magento is trying to navigate to when it produces the error (the original one from the original code -not the hardcoded). It was trying to navigate to the url in the screen shot below.
I was able to figure out the URL by replacing getName() with getCurrentUrl() to see which URL it's trying to open. It turns out it's navigating to some weirdo URL.. could that be the source of the problem?
OK.
getCurrent is a method that needs to be applied to some object.
So I can probably trick by using
$my_current_url = Mage::getModel('core/url')
So replace
<option value="<?php echo $_lang->getCurrentUrl();?>?_
<option value="<?php echo $_lang->getCurrentUrl();?>?_
With
<?php $my_current_url = Mage::getModel('core/url')
<option value="<?php $my_current_url; ?>?___store=default" >English</option>
<option value="<?php $my_current_url; ?>?___store=arabic" >91(J</option>
EDIT: all the links take me to arabic pages except the home, category and product pages (they take me to the english interface)
for some reason, pressing on home, category or product links takes me to the default URL (for example: localhost/battery/index.ph
I meant when I'm inside my arabic store (text in arabic), then I press the home link for example, I get my homepage alright, but not the arabic homepage (just the default one). It just opens localhost/battery/index.ph
get my point?
I just tried adding a link like this: <a href="http://localhost/bat
surprizingly, even pressing on that link, gives the same error as I was facing in the beginning. However, if I enter this exact URL explicitly into the address bar, the page is displayed correctly!
I've never seen anything like this in my life!
no, not pasting here.
just keep a copy of the current "html hard-coded" file, and restore the phtml file back to its previous state (you have a copy here earlier in the thread).
The idea is that adding the store code seems to solve your problem... and so switching back to the "normal" code should work.
tried that... still getting the same error.
btw, did you read post # 25782931, which says:
>>I just tried adding a link like this: <a href="http://localhost/bat
surprizingly, even pressing on that link, gives the same error as I was facing in the beginning. However, if I enter this exact URL explicitly into the address bar, the page is displayed correctly!
I've never seen anything like this in my life!
maybe that will give you a clue?
- your last comment: yes, having this link in html is the problem we are facing from start
- when you say you have "the same error" is it also for the home, category and product link pages?
- can you paste back here:
-- the current version of the phtml (it should be ok, but an extra check is not useless!)
-- a scren capture of the error you get when switching (be sure that the url is readable too)
- What I mean by the same error is the initial error we started with: Warning: PDO::quote() expects parameter 1 to be string, object given in C:\xampp\htdocs\battery\li
I get that error everytime I switch languages with the drop down menu. However, if I happen to explicitly type the URL:
http://localhost/battery/i
into my address bar, I get a perfect arabic page.The home, category and product links work fine inside the arabic store view: take me to the corresponding arabic pages correctly. (here I have enabled "add store code to urls").
here's languages.phtml as well as a screen shot of the error:
btw, I just noticed that the language drop down works perfectly when I'm on a page with a URL that ends with: ?___from_store=arabic OR ?___from_store=default.. The error only appears when I'm on a page with a regular URL like: localhost/battery/index.ph
Here's the code for C:\xampp\htdocs\battery\li
return $this->_connection->quote($v
update: I have tried installing extension: ar_KW (which has worked without any problems on a site I developed before) and deleted extension ar_SA. But that didnt' change a thing (still same error).
I even tried deleting the arabic store view and recreating it... same result
then, I changed the theme to default.. also same result.
so it's not the extension or the store view and not even the theme!
OK. From what I understand, the function _quote($value) is meant to build SQL queries, and to return a string ready to be inserted in a sql query for a condition such as
where argument = value if value is an integer or
where argument = 'value' if value is a string
It currently explodes because at the time of the call something is going wrong: $value should be a string but is an object or an array.
This is in the Zend Framework, so presumably there is no error in this code... but there might be some problem anyway.
What I would try to do:
- backup all the magento app, including the /libs/ directory and the Zend framework
- on your system, re-download your complete version of Magento, unzip it in a new directory
- copy this new directory to the old one, overwriting EVERY file that is there... except those in the home directory
Recheck for the problem...
My experience is that in several occasions reinstalling all the files was the fastest option...
You might also consider 2 tools, if you don't already:
1 - source-versioning tool, such as subversion: this would allow you to copare easily different versions (in the history) of the same file
2 - WinDiff which allows to compare 2 different files /directories.
I use 1/ to check files part of the "collection" of the thousands of files in Magento
I use 2/ to check changes when upgrading versions: I compare the complete versions old and new, checking if they look relevant for any change I have done. Once this is done, I usually upload all the files of the new version to the remote site, & make any needed change.
Business Accounts
Answer for Membership
by: fiboPosted on 2009-11-04 at 05:31:50ID: 25739061
Just in case... I have had problems with the transalation, which is done thru javascript.
1 - Check on the server if all the files in /libs/ have the correct access rights, wether php, js or directories
2 - look at the javascript for translation: maybe some apostroph has been uncorrectly escaped, or more exactly non escaped: any ' inside a 'script' should be written \'