choy Posted September 27, 2007 Share Posted September 27, 2007 hello! i have a big trouble inserting data in mysql i have a method called InsertData public function InsertData($keys ,$values,$table) { $this->init(); //initialize the conn and stuff $valueStr=""; //query construction $sql = "INSERT INTO $table ("; foreach ($keys as $key) { $valueStr.= $key .","; } $valueStr = substr($valueStr,0,strlen($valueStr)-1); $sql .= $valueStr . ") VALUES ("; $valueStr =""; foreach ($values as $value) { if (!is_numeric($value)) { $value = "'" .$value ."'"; } $valueStr.= $value.","; } $valueStr = substr($valueStr,0,strlen($valueStr)-1); $sql .= $valueStr . ")" ; //echo $sql; echo mysql_error(); $success = mysql_query($sql, $this->conn) or $success=0 ; return $success; } if i try to insert some data like "Adrián"... the query insert other characters (like "adrÃan34") i called the function this way $keys[] ="name"; $keys[] = "descripction"; $values [] = $_GET["txtName"]; $values [] = $_GET["txtDesc"]; $ob->InsertData($keys ,$values,"division"); i thought that the problem was the array that i passed to the function with the data.... BUT when i print the query it appears like this "INSERT INTO division (name,description) VALUES ('adrián','adrián') " and then... the query are executed and the value is all chunk i tried to change the columns encodings and the headers but nothings work... please help me im so desperate choy Quote Link to comment Share on other sites More sharing options...
jaymc Posted September 27, 2007 Share Posted September 27, 2007 What charset are you using? Quote Link to comment 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.