Bug #29401 Errors in SELECT DECODE
Submitted: 27 Jun 2007 21:02 Modified: 27 Jul 2007 23:33
Reporter: Fco ml Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Errors Severity:S3 (Non-critical)
Version:5.0.27 OS:Windows (Windows 2000 server SP2)
Assigned to: CPU Architecture:Any
Tags: SELECT DECODE

[27 Jun 2007 21:02] Fco ml
Description:
I use the SELECT ENCODE and SELECT DECODE under PHP 5.2.0 and see some errors, I send my code and the results

<?php
mysql_connect("localhost","root");
$enc = mysql_query("SELECT ENCODE('06/07','me')");
$str_enc = mysql_fetch_array($enc);
$val_enc = $str_enc[0];
echo $str_enc[0];

$dec = mysql_query("SELECT DECODE('".$val_enc."','me')");
$str_dec = mysql_fetch_array($dec);
echo "<br>".$str_dec[0];
?>

Result : MÙòÊ      06/07    This is OK.

If use:

$enc = mysql_query("SELECT ENCODE('06/07','mex')");
$dec = mysql_query("SELECT DECODE('".$val_enc."','mex')");

Result : j\†˜`      0¶Áj     Bad result.

If use:

$enc = mysql_query("SELECT ENCODE('06/07','mexi')");
$dec = mysql_query("SELECT DECODE('".$val_enc."','mexi')");

Result : ½ô I'      Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Archivos de programa\EasyPHP 2.0b1\home\encode.php on line 9

How to repeat:
Run the code and change the values 'me' to 'mex' and  'mex' to 'mexi'

Suggested fix:
Maybe is some escape character in the results.
[27 Jun 2007 23:33] Sveta Smirnova
Thank you for the report.

But version 5.0.27 is quite old. Please upgrade to current version 5.0.41, try with it and if you can repeat provide us value of variable $val_enc. We need result of PHP command `echo $val_enc, "SELECT DECODE('".$val_enc."','mex')";`
[28 Jul 2007 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".