How to debug a "decoding error"

Hi everyone, I have inherited a site written in php, and I’m not the most experienced php coder (by a LONG way :slight_smile: ). The site is intermittently getting this error when doing mysql inserts:
Decoding error! The response was : HTTP/1.1 200 OK Date: Fri, 06 Sep 2013 10:59:19 GMT Server: Apache X-Powered-By: PHP/5.2.17 Set-Cookie: PHPSESSID=lo4au4skm1jshu1rs7a2rve5i4; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Content-Length: 197 Connection: close Content-Type: text/html; charset=UTF-8 ERROR (US.2): Team Update Failed!
Now I’ve checked the sqlstate, error, errno and they are all empty, and it does appear the update is working. My question is how do I track down what this “Decoding error!” actually is?
The data is being read from XML to be inserted to the DB.
The database is UTF_UNICODE_CI.

Thanks

	$mysqli = new mysqli('xxx','xxx','xxx','xxx');
        $mysqli->set_charset("utf8");

$query = "INSERT INTO `team`
                            SET
                            id = '".$teamArray['id']."',
                            name = '".$teamArray['teamName']."',
                            league = '".addslashes($league_id)."',
                            conference = '".$teamArray['conference']."',
                            season = '".addslashes($season_id)."',
                            wins = '".$teamArray['wins']."',
                            losses = '".$teamArray['losses']."',
                            pf = '".$teamArray['pf']."',
                            pa = '".$teamArray['pa']."'
                            ON DUPLICATE KEY UPDATE
                            name = '".$teamArray['teamName']."',
                            league = '".addslashes($league_id)."',
                            conference = '".$teamArray['conference']."',
                            season = '".addslashes($season_id)."',
                            wins = '".$teamArray['wins']."',
                            losses = '".$teamArray['losses']."',
                            pf = '".$teamArray['pf']."',
                            pa = '".$teamArray['pa']."'";

                           $items = $mysqli->query($query) or die("ERROR (US.2): Team Update Failed!");

Change:

[php] $items = $mysqli->query($query) or die(“ERROR (US.2): Team Update Failed!”);
[/php]

To:

[php] $items = $mysqli->query($query) or die(“ERROR (US.2): Team Update Failed!” . $query);
[/php]

I have a feeling it’s some funky character, someplace in the XML that it’s having trouble with, you can display the $query to see where the issue might be.

I tried that but when I cut and paste the query and run directly in the database it works fine :frowning: So it doesn’t seem to be the query itself.

Is it the same query at the same point in the XML?

yes, cut and paste from the $query that is displayed when the error occurs.

I mean is it always the same query values that causes the error in the xml?

If it is can you send me the xml and tell me which line number? I want to run it through a hex viewer.

I mean is it always the same query values that causes the error in the xml?
No, different values (XML input) are causing the same error :( The input seems fine to me, and the fact that I can cut and paste the query in to mysql and it works fine makes me think the XML itself is not the problem. Other code is using the same XML without problems

Send me the XML File, I’ll recreate your tables on my database and I’ll see if I have the same issues.

Sponsor our Newsletter | Privacy Policy | Terms of Service