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

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)

  • 写回答

1条回答 默认 最新

  • 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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错