Current location: Hot Scripts Forums » Programming Languages » PHP » Help me


Help me

Reply
  #1 (permalink)  
Old 04-12-06, 06:48 AM
surendra surendra is offline
Newbie Coder
 
Join Date: Apr 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Help me

hey i have problem with php can any one help me!
how do i write arabic text through php in a txt file,,file
Reply With Quote
  #2 (permalink)  
Old 04-12-06, 08:06 AM
YourPHPPro's Avatar
YourPHPPro YourPHPPro is offline
Community VIP
 
Join Date: Aug 2003
Posts: 430
Thanks: 0
Thanked 0 Times in 0 Posts
Does this help ?

http://us2.php.net/fwrite
Reply With Quote
  #3 (permalink)  
Old 04-12-06, 11:57 PM
surendra surendra is offline
Newbie Coder
 
Join Date: Apr 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
its a flash chat room , mate !! all i need to write in UTF-8 encoding ,, i need php file for save data as utf-8 encding !!
Reply With Quote
  #4 (permalink)  
Old 04-13-06, 01:54 AM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
If you have a string containing the utf-8 encoded aribic, the normal file functions will write it and read it -
PHP Code:

$filename 'arabictest.txt';

// got this text from www.columbia.edu/kermit/utf8.html 
// it should say - I can eat glass and it doesn't hurt me.
$somecontent "أنا قادر على أكل الزجاج و هذا لا يؤلمني.";

// Write $somecontent to a file
$handle fopen($filename'w');
fwrite($handle$somecontent);
echo 
"Wrote ($somecontent) to file ($filename)<br />";
fclose($handle);

// get contents of a file into a string
$handle fopen($filename"r");
$contents fread($handlefilesize($filename));
echo 
$contents;
fclose($handle); 
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
  #5 (permalink)  
Old 04-13-06, 02:10 AM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
Here is an updated version of the above that outputs an utf-8 header and wraps the text with the proper language info -
PHP Code:

echo '<META http-equiv=Content-Type content="text/html; charset=utf-8">';

$filename 'arabictest.txt';
$somecontent "أنا قادر على أكل الزجاج و هذا لا يؤلمني.";

// Write $somecontent to our opened file.
$handle fopen($filename'w');
fwrite($handle$somecontent);
echo 
"Wrote (<SPAN lang=AR dir=rtl>$somecontent</SPAN>) to file ($filename)<br />";
fclose($handle);

// get contents of a file into a string
$handle fopen($filename"r");
$contents fread($handlefilesize($filename));
echo 
"<SPAN lang=AR dir=rtl>$contents</SPAN>";
fclose($handle); 
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
  #6 (permalink)  
Old 04-13-06, 03:16 AM
surendra surendra is offline
Newbie Coder
 
Join Date: Apr 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
thankx for da reply !!! just have a look at my chat room !!
My Chat Room

its english version is working fine,, all i need is ,, if i type smthin in Arabic it should go through the php in to txt file .. and display in da arabic too ,,
Reply With Quote
  #7 (permalink)  
Old 04-13-06, 10:24 AM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
To obtain help, you need to describe what the problem is, post the code that is responsible for performing the function in question, provide examples, and telling what you have already tried would not hurt either. Also provide information about what symptoms you have observed (in your case how do you know it is not writing the utf-8 text to a file?) Is it not displaying the text correctly when it is posted? If so, see the next paragraph.

The link you provided goes to blank page, which does not help except that it has this header -
Code:
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
If this is the same header used on pages trying to display utf-8 encoded text, it will probably cause it to be displayed as the utf-8 encoded string and not as the proper text.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
  #8 (permalink)  
Old 04-15-06, 01:26 AM
surendra surendra is offline
Newbie Coder
 
Join Date: Apr 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Im Extremly sorry mate ,,, im not that much gud in php and im new to the forum also pls do mind all my mistakes ..
and again im sayin sorry that cos I hav given the wrong link too ,,, its goes to clear.php.. here is the link just hav a look
my chat room

here with attached my php file for post n display , i hope u will help me ,,
Attached Files
File Type: zip dog_chat.zip (1.9 KB, 28 views)
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 07:09 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.