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?

Mr. Polywhirl
  • 42,981
  • 12
  • 84
  • 132
LOLapalooza
  • 2,042
  • 3
  • 17
  • 22
  • 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 09 '13 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 09 '13 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 '13 at 03:55

0 Answers0