patrik20
asked on
create two tables, default collation is "latin1_swedish_ci” and other table with collation “utf8 COLLATE utf8_persian_ci”
Hi
I try to create two tables, the first one has the default collation "latin1_swedish_ci” and the other table should has collation “utf8 COLLATE utf8_persian_ci”, and I will insert Persian text into the second table.
But my script creates both tables with the default collation "latin1_swedish_ci” , and put ???? in the second table.
Here is the code. What am I missing / doing wrong?
<?
include ("serverdata.php");
$con = mysql_connect($dbHost,$dbU ser,$dbPas s);
mysql_select_db($dbName, $con);
$query1="
CREATE TABLE admin (
id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
username VARCHAR( 11 ) NOT NULL ,
password VARCHAR( 11 ) NOT NULL ,
email VARCHAR( 50 ) NOT NULL
) TYPE=MyISAM";
$query2="INSERT INTO admin VALUES (1, 'över', 'för titel1 på svenska', 'webb@hotmail.com');";
$query3="
CREATE TABLE subjectir (
id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
title1f TEXT( 200 ) CHARACTER SET utf8 COLLATE utf8_persian_ci NOT NULL ,
title2f TEXT( 200 ) CHARACTER SET utf8 COLLATE utf8_persian_ci NOT NULL ,
textf TEXT( 1500 ) CHARACTER SET utf8 COLLATE utf8_persian_ci NOT NULL
) TYPE=MyISAM";
$query4="INSERT INTO subjectir VALUES (1, ' some persian text, .', ' some persian text ', ' some persian text ');";
$result1 = mysql_db_query($dbName,$qu ery1) or die('Error1: creating admin table');
$result2 = mysql_db_query($dbName,$qu ery2) or die('Error2: inserting in admin table');
$result3 = mysql_db_query($dbName,$qu ery3) or die('Error3: creating subjectir table');
$result4 = mysql_db_query($dbName,$qu ery4) or die('Error4: inserting in subjectir table');
echo "<FONT SIZE=4><b>All tables created successfully</b></FONT><BR ><BR>";
?>
I try to create two tables, the first one has the default collation "latin1_swedish_ci” and the other table should has collation “utf8 COLLATE utf8_persian_ci”, and I will insert Persian text into the second table.
But my script creates both tables with the default collation "latin1_swedish_ci” , and put ???? in the second table.
Here is the code. What am I missing / doing wrong?
<?
include ("serverdata.php");
$con = mysql_connect($dbHost,$dbU
mysql_select_db($dbName, $con);
$query1="
CREATE TABLE admin (
id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
username VARCHAR( 11 ) NOT NULL ,
password VARCHAR( 11 ) NOT NULL ,
email VARCHAR( 50 ) NOT NULL
) TYPE=MyISAM";
$query2="INSERT INTO admin VALUES (1, 'över', 'för titel1 på svenska', 'webb@hotmail.com');";
$query3="
CREATE TABLE subjectir (
id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
title1f TEXT( 200 ) CHARACTER SET utf8 COLLATE utf8_persian_ci NOT NULL ,
title2f TEXT( 200 ) CHARACTER SET utf8 COLLATE utf8_persian_ci NOT NULL ,
textf TEXT( 1500 ) CHARACTER SET utf8 COLLATE utf8_persian_ci NOT NULL
) TYPE=MyISAM";
$query4="INSERT INTO subjectir VALUES (1, ' some persian text, .', ' some persian text ', ' some persian text ');";
$result1 = mysql_db_query($dbName,$qu
$result2 = mysql_db_query($dbName,$qu
$result3 = mysql_db_query($dbName,$qu
$result4 = mysql_db_query($dbName,$qu
echo "<FONT SIZE=4><b>All tables created successfully</b></FONT><BR
?>
That is if tables actually have collation at all?
As far as I'm aware collation is defined either at the server, database or column levels.
Looking at the code you posted it seems that you have achieved what you want to.
If you have access to the sql server, open the 2nd table in design view and click on one of the text columns.... in the properties for that column you will see the collation. If it says database default then it didn't work.
As far as I'm aware collation is defined either at the server, database or column levels.
Looking at the code you posted it seems that you have achieved what you want to.
If you have access to the sql server, open the 2nd table in design view and click on one of the text columns.... in the properties for that column you will see the collation. If it says database default then it didn't work.
ASKER
you are right, but how should I make it to put persian text into columns?
ASKER
yes 3 columns in table2 have collation utf8_persian_ci.
ASKER
I make the first table in default collation latin1_swedish_ci and then I put Swedish text into those columns.
And I have the second table with column collation “utf8 COLLATE utf8_persian_ci”.
Is it possible to insert "Persian text" Into those second table?
And I have the second table with column collation “utf8 COLLATE utf8_persian_ci”.
Is it possible to insert "Persian text" Into those second table?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I don't know about persian, but for chinese collation you actually have to change the database collation to be Chinese, not just the column. I don't know what impact this will ahve if you have swedish and persian - you would have to test.
ASKER
I run the line but got error:
Fatal error: Undefined class name 'from' in /home/bc9ba1a/public_html/ test.php on line
Fatal error: Undefined class name 'from' in /home/bc9ba1a/public_html/
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Therefore your table may have the default collation but your text columns are utf8_persian_ci