Jump to content

japanese char and record problem


sniperscope

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/137786-japanese-char-and-record-problem/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.