dongyongyu0789 2010-01-10 00:00
浏览 821
已采纳

Mysql查询只返回字符串的第一个字母

Can someone please tell me what I am missing. the following sql query returns only the first letter of strings it fetched from the my database:

 $result = mysql_query("SELECT * FROM users) or die("error in the query");

thanks.

Update


$result = mysql_query("SELECT * 
                         FROM properties 
                         JOIN users USING(UserId) 
                        WHERE Level <> 'Admin' $pages->limit") or die("could not load all the properties"); 

$i=0; 
while($row = mysql_fetch_array($result)) { 
  $fn[$i] = $row ['FN']; 
  $ln[$i] = $row ['LN']; 
  $phone[$i] = $row ['Phone']; 
  $Email[$i] = $row ['Email']; 
} 

...the part of the code that giving me head ache since yesterday. $fn, $ln, $email and$phone` all contain only one character. I think the error is on my own page but i just can't see it. anything concerning property contains the rite value

  • 写回答

7条回答 默认 最新

  • duanquan4451 2010-01-10 00:43
    关注

    If you're using the while() to allocate variables to an array, I don't think you need to use the $i, if you change the code to:

    while($row = mysql_fetch_array($result)) { 
      $fn[] = $row ['FN']; 
      $ln[] = $row ['LN']; 
      $phone[] = $row ['Phone']; 
      $Email[] = $row ['Email']; 
    }
    

    The $row['whatever'] variable should be appended to the array. This was posted as an answer because it's too long to post as a comment (at least legibly); I don't, however, think it's affecting your problem.

    It is, though, worth trying:

    `echo "<pre>" . print_r(get_defined_vars(),true) . "</pre>";
    

    to see what the contents of the variables are, and whether they're being returned from the db as one-character strings, or if it's happening in the code somewhere.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(6条)

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制