php - Is This a Bug in MySQL? -


i using mysql , php (laravel) , facing strange situation .

i trying encrypted user type , user id , decrypt . , find records user id .

my code . using laravel framework .

        $key = config::get('app.key');         $decodeduseridwithtype = base64_decode($encrypteduseridwithtype);         $decrypteduseridwithtype = mcrypt_decrypt(xxxxx , $key, $decodeduseridwithtype, xxxxxx);         $useridwithtype = $decrypteduseridwithtype; 

i expecting decoded value

id@100 

so explode @ , find user id , here 100 .

for testing have changed encrypted value manually adding 1 or 2 characters . when decrypt got

id@100������������������������]u甀�+&�fj�w�zЪs��d��]3�]" 

and after explode id 100���]u甀�+&�fj�w�zЪs��d��]3�]"

now select raws same id using .

select * table id=$id

it select recordes id = 100 actual id is 100���]u甀�+&�fj�w�zЪs��d��]3�]"

so weird . type of id column int may why matched .

but point of view bad , because whole logic got incorrect because of .

i checked query both in laravel , raw mysql query , results same .

any ideas , in advance .

update

i understand point mentioned shadow, how handle scenario , decryption expect id 100 , if got 1asasas, if cast int 1 (this example) . problem database has user id 1 , can see how trouble in because incorrect user , sadly related payment :p . incorrect users wallet topped . ha ha .how handle this

this not bug, feature in mysql described in type conversion in expression evaluation section of mysql manual:

when operator used operands of different types, type conversion occurs make operands compatible. conversions occur implicitly. example, mysql automatically converts numbers strings necessary, , vice versa.

when mysql converts string number, evaluates characters starting left long characters can interpreted part of number , stops, if encounters character cannot considered part of number. in case of 100���]u甀�+&�fj�w�zЪs��d��], first cannot interpreted part of number, mysql stops after 100. characters after 100 seem kind of garbage anyway , should check php code why produces garbage.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -