Click here to Skip to main content
15,912,021 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i insert some name and ... in persian and my collation is utf8_general_ci
when i insert some data from mysql all thing is true but when i insert from my web i get some thing like سعید رچبی

my code :



HTML
<!DOCTYPE HTML>
<html>
	<head>
		<title></title>
		<meta charset="utf8"></meta>
	</head>
	<body>
		<form method="post"action="prc_test.php">
			<input type="text"name="name"value=""/><br/><br/>
			<input type="text"name="fname"value=""/><br/><br/>
			<input type="submit"name="sbm"value="ثبت"/>
		</form>
	</body>
</html>
<?php
	if(isset($_POST['sbm']))
	{
		done($_POST['name'],$_POST['fname']);	
	}
	function done($name, $fname)
	{
		if($con = mysqli_connect("localhost","root",'1050585712'))
		{
			mysqli_select_db($con,"pr_test");
			$p = $con -> prepare("CALL Insert_Comment(?,?)");
			$p -> bind_param('ss', $name, $fname);
			$p -> execute();
		}
		else
		{
			echo 'db connection error';
		}
	}
?>


What I have tried:

i wrote the meta tag with the charset but .....
Posted
Updated 23-Aug-16 9:56am
Comments
Richard Deeming 23-Aug-16 14:55pm    
Have you tried calling mysqli_set_charset[^] before inserting the data?
saeed rajabi 23-Aug-16 15:13pm    
thank you.
fixed
Richard Deeming 23-Aug-16 15:55pm    
OK, I'll post that as a solution to move your question off the "unanswered" list. :)

1 solution

As discussed in the comments, calling mysqli_set_charset[^] before executing the query resolved the problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900