Mysql query returns only the first letter of strings

mysql, php, sql

Solution

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.

Problem

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

Original source