Database returning different errors for same query. Instead of column name, column id is returning
I am very much annoyed with servers...
I have seen so many problems which didn't occurs on local system environment, and when the code is uploaded on server... everything seems to be against developers.
Problem :
On my local system I m using database error returned from mysql like :
  0 => string '23000' (length=5)
  1 => int 1062
  2 => string 开发者_Go百科'Duplicate entry 'xyzabc.com' for key 'domain'' (length=46)
and moulding error msg as my wish like:
string 'Error: xyzabc.com already exist/used.' (length=38)
for jquery flashing message as it didin't look good to display exactly same error returned by database.
X-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-X
Now when I uploaded on server to make it live it responded like this:
array(3) {
[0]=>  string(5) "23000"
[1]=>  int(1062) 
[2]=>  string(39) "Duplicate entry 'xyzabc.com' for key 2" 
}
Field       Type                 Collation
id      int(11) 
domain      varchar(50)              latin1_swedish_ci
added       datetime    
is_delete   enum('no','yes')   latin1_swedish_ci
I can only use 1062 message,but I m posting multiple values, so for that I need to go through every posted value to check, that for which the error is coming.
Now where this key '2' came from?? :-/ as it should be domain. I am assuming that it is column_id. But how to solve this problem?? what I need to change in server to response like my local sytem environment?
I think the problem may be that you have locally
  2 => string 'Duplicate entry 'xyzabc.com' for key 'domain'' (length=46) 
and remotely
[2]=>  string(39) "Duplicate entry 'xyzabc.com' for key 2" 
NB Different quotes!
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论