drjun1994
drjun1994
2013-10-06 16:23
浏览 20
已采纳

db insert返回带有数值的乱码值

Assuming this is a host issue, but I don't see how it could be reading wrong (works perfectly on locahost)

I an returning an array called $result, for this instance of the loop, $v is a telephone number

$k = 'phone'; $v = '(555) 555-1212)';

I have tried

$result[$k] = preg_replace('/(\W*)/', '', $v);

I have also tried

$result[$k] = preg_replace('/[^0-9]/', '', $v);

I have received values for $v of anything from -198040413 to 1260583916 expected result would be 5555551212

echoing results to page for both cases gives expected result, so its not a preg_repalce issue, must be db issue

I know this is not an int limit issue, I am using a varchar(10) for testing the problem

host is Arvixe.com using PHP 5.3.27, I have had other conflicts with them, but preg_replace should be pretty straight forward code (you would think)

图片转代码服务由CSDN问答提供 功能建议

假设这是一个主机问题,但我看不出它是如何读错的(在locahost上完美运行) )

我返回一个名为 $ result array ,对于这个循环实例, $ v 是电话号码

$ k ='phone'; $ v ='(555)555-1212)';

我试过

  $ result [$ k] = preg_replace('/(\ W *)/','  ',$ v); 
   
 
 

我也试过

  $ result [$ k] = preg_replace(  '/ [^ 0-9] /','',$ v); 
   
 
 

我收到 $ v 的值 从 -198040413 1260583916 expected结果的任何内容都是 5555551212

回显两页的结果 case给出了预期的结果,所以它不是preg_repalce问题,必须是db问题

我知道这不是 int 限制问题,我使用的是 varchar(10)用于测试问题

主机是 Arvixe.com 使用 PHP 5.3.27 ,我和他们有其他冲突,但 preg_replace 应该是相当简单的代码(你会想)

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanjing7298
    duanjing7298 2013-10-06 16:50
    已采纳

    Found the issue, it was with the insert

    I was inserting into a varchar using i as type, changing it to s as type fixed it

    // does not work
    bind_param('i', $phone);
    
    // does work
    bind_param('s', $phone);
    

    when inserting into a varchar field

    点赞 评论

相关推荐