sniperscope Posted December 20, 2008 Share Posted December 20, 2008 hi all; I have a little problem which is my sql query does not get all records from db, it take all records-1. I mean if i have 10 records then my query show only 9. here is my sql query <?php $host_name = "localhost"; $db = "stuff"; $user = "root"; $pass = "123456"; $deli = mysql_pconnect($hostname, $user, $pass) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db($db, $deli); $query_r = "SELECT id, Nick_Name FROM stuff_data ORDER BY id ASC"; $r = mysql_query($query_r, $deli) or die(mysql_error()); $row_r = mysql_fetch_assoc($r); $totalRows_r = mysql_num_rows($r); ?> and here is form code <select name='stuff'> <?php while ($row_r=mysql_fetch_array($r)){ $id = $row_r['id']; $nick = $row_r['Nick_Name']; echo "<option value='$nick' id='$id'>$nick</option>"; } ?> </select> My another major problem is; i develop web pages with UTF-8 default charset and my db collation also UTF-8, when i check data in my tables all i see is wierd characters instead of japanese chars. What do i have to do ? If my visitors' borwser set SHIFT_JIS as default encoding does is effect result of page viewing or browser will change to UTF-8 automatically ? Great appreciate for any help and advice. Quote Link to comment https://forums.phpfreaks.com/topic/137786-japanese-char-and-record-problem/ Share on other sites More sharing options...
sniperscope Posted December 20, 2008 Author Share Posted December 20, 2008 I solved record problem. Here, let me share my experience for others who have same problem. The solution was very easy; in my query i checked the condition at top of loop with <?php while($row_r=mysql_fetch_array($r)){ ... ... ?> but i figured out to check the condition with <?php do{ ?> ... ... ... <?php } while ($row_r=mysql_fetch_array($r)); ?> This is the solution for getting records. But still i have problem about UTF-8. Quote Link to comment https://forums.phpfreaks.com/topic/137786-japanese-char-and-record-problem/#findComment-720241 Share on other sites More sharing options...
fenway Posted December 22, 2008 Share Posted December 22, 2008 Your "solution" has nothing to do with the record problem.... you simply called fetch() before you started your loop. Quote Link to comment https://forums.phpfreaks.com/topic/137786-japanese-char-and-record-problem/#findComment-721569 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.