1

Using WordPress with WordPress MultiLanguage. I noticed a page was 404ing, so I dumped the query that was being output, and got the following (formatted exactly like below):

SELECT   newsite_posts.* FROM newsite_posts   JOIN newsite_icl_translations t ON newsite_posts.ID = t.element_id
                    AND t.element_type = 'post_sectors' JOIN newsite_icl_languages l ON t.language_code=l.code AND l.active=1 WHERE 1=1  AND newsite_posts.post_name = 'advisory-practice' AND newsite_posts.ID = 456 AND newsite_posts.post_type = 'sectors' AND t.language_code='es'  ORDER BY newsite_posts.post_date DESC 

Threw it in PHPMyAdmin SQL tab, got 0 results. Beneath the part where it says "MySQL returned an empty result set", it reoutputted my query for me, formatted like below:

SELECT newsite_posts. * 
FROM newsite_posts
JOIN newsite_icl_translations t ON newsite_posts.ID = t.element_id
AND t.element_type =  'post_sectors'
JOIN newsite_icl_languages l ON t.language_code = l.code
AND l.active =1
WHERE 1 =1
AND newsite_posts.post_name =  'advisory-practice'
AND newsite_posts.ID =456
AND newsite_posts.post_type =  'sectors'
AND t.language_code =  'es'
ORDER BY newsite_posts.post_date DESC 

so I copied and pasted back into the SQL tab of phpmyadmin and it works, 1 row found. This is the same exact query, formatted differently. What is going on here? This is affecting my code, too, it's not just a phpmyadmin bug. Am I crazy? Am I missing something?

3
  • What happens when you copy and paste the PHPMYADMIN SQL back into your original PHP code (for testing only)? Does it work properly then?
    – Sablefoste
    Sep 9, 2013 at 21:43
  • I had same problem once. Try to change JOIN not to have AND on it. ON t.language_code = l.code AND l.active =1 - separate ON t.language_code = l.code and put AND l.active =1 in WHERE condition
    – jaczes
    Sep 9, 2013 at 21:52
  • Are your server and database using the same character encoding? Last time I had something like this happen, it was because the character encoding was different, so even though it looked like the same content it actually wasn't.
    – DiMono
    Sep 10, 2013 at 3:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.