Jump to content

RonnyZenn

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

RonnyZenn's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I tried the following utf8 decode function but it doesnt really solve the char problem as well <?php # GLOBAL VARIABLES $url = "http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-9.TXT"; //$url = "8859-9.txt"; $iso2utf = array(); $utf2iso = array(); # UNICODE MAPPING TABLE PARSING function create_map($url){ global $iso2utf, $utf2iso; $fl = @(file($url)) OR (die("cannot open file : $url\n")); for ($i=0; $i<count($fl); $i++){ if($fl[$i][0] != '#' && trim($fl[$i])){ list($iso, $uni, $s, $desc) = split("\t",$fl[$i]); $iso2utf[$iso] = $uni; $utf2iso[$uni] = $iso; } } } # FINDING UNICODE LETTER'S DECIMAL ASCII VALUE function uniord($c){ $ud = 0; if (ord($c{0})>=0 && ord($c{0})<=127) $ud = $c{0}; if (ord($c{0})>=192 && ord($c{0})<=223) $ud = (ord($c{0})-192)*64 + (ord($c{1})-128); if (ord($c{0})>=224 && ord($c{0})<=239) $ud = (ord($c{0})-224)*4096 + (ord($c{1})-128)*64 + (ord($c{2})-128); if (ord($c{0})>=240 && ord($c{0})<=247) $ud = (ord($c{0})-240)*262144 + (ord($c{1})-128)*4096 + (ord($c{2})-128)*64 + (ord($c{3})-128); if (ord($c{0})>=248 && ord($c{0})<=251) $ud = (ord($c{0})-248)*16777216 + (ord($c{1})-128)*262144 + (ord($c{2})-128)*4096 + (ord($c{3})-128)*64 + (ord($c{4})-128); if (ord($c{0})>=252 && ord($c{0})<=253) $ud = (ord($c{0})-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128); if (ord($c{0})>=254 && ord($c{0})<=255) $ud = false; //error return $ud; } # PARSING UNICODE STRING function utf2iso($source) { global $utf2iso; $pos = 0; $len = strlen ($source); $encodedString = ''; while ($pos < $len) { $is_ascii = false; $asciiPos = ord (substr ($source, $pos, 1)); if(($asciiPos >= 240) && ($asciiPos <= 255)) { // 4 chars representing one unicode character $thisLetter = substr ($source, $pos, 4); $thisLetterOrd = uniord($thisLetter); $pos += 4; } else if(($asciiPos >= 224) && ($asciiPos <= 239)) { // 3 chars representing one unicode character $thisLetter = substr ($source, $pos, 3); $thisLetterOrd = uniord($thisLetter); $pos += 3; } else if(($asciiPos >= 192) && ($asciiPos <= 223)) { // 2 chars representing one unicode character $thisLetter = substr ($source, $pos, 2); $thisLetterOrd = uniord($thisLetter); $pos += 2; } else{ // 1 char (lower ascii) $thisLetter = substr ($source, $pos, 1); $thisLetterOrd = uniord($thisLetter); $pos += 1; $encodedString .= $thisLetterOrd; $is_ascii = true; } if(!$is_ascii){ $hex = sprintf("%X", $thisLetterOrd); if(strlen($hex)<4) for($t=strlen($hex);$t<4;$t++)$hex = "0".$hex; $hex = "0x".$hex; $hex = $utf2iso[$hex]; $hex = str_replace('0x','',$hex); $dec = hexdec($hex); $encodedString .= sprintf("%c", $dec); } } return $encodedString; } # CREATING ISO2UTF & UTF2ISO MAPS create_map($url); # TESTING $unicode_string = "Ekonomi_ve_\xc4\xb0\xc5\x9f_D\xc3\xbcnyas\xc4\xb1"; echo "unicode string : <b>" . $unicode_string . "</b>"; echo "<br><br>"; echo "ISO8859 (latin5 / turkish) converted string : <b>" . utf2iso($unicode_string) . "</b>"; ?>
  2. I create an excel file with php, everything seems fine but there're character problems, can't display some chars properly, and I can't format titles bold. Example code is below; <? function xlsBOF() { echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0); return; } function xlsEOF() { echo pack("ss", 0x0A, 0x00); return; } function xlsWriteNumber($Row, $Col, $Value) { echo pack("sssss", 0x203, 14, $Row, $Col, 0x0); echo pack("d", $Value); return; } function xlsWriteLabel($Row, $Col, $Value ) { $L = strlen($Value); echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L); echo $Value; return; } // Query Database $result=mysql_db_query($dbname,"select id,prename,name,sname,grade from appdata where course='$courseid' and sec='$section'") // Send Header header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Disposition: attachment;filename=$courseid-$sec.xls "); header("Content-Transfer-Encoding: binary "); // XLS Data Cell xlsBOF(); xlsWriteLabel(1,0,"Student Register $semester/$year"); xlsWriteLabel(2,0,"COURSENO : "); xlsWriteLabel(2,1,"$courseid"); xlsWriteLabel(3,0,"TITLE : "); xlsWriteLabel(3,1,"$title"); xlsWriteLabel(4,0,"SETION : "); xlsWriteLabel(4,1,"$sec"); xlsWriteLabel(6,0,"NO"); xlsWriteLabel(6,1,"ID"); xlsWriteLabel(6,2,"Gender"); xlsWriteLabel(6,3,"Name"); xlsWriteLabel(6,4,"Lastname"); $xlsRow = 7; while(list($id,$prename,$name,$sname,$grade)=mysql_fetch_row($result)) { ++$i; xlsWriteNumber($xlsRow,0,"$i"); xlsWriteNumber($xlsRow,1,"$id"); xlsWriteLabel($xlsRow,2,"$prename"); xlsWriteLabel($xlsRow,3,"$name"); xlsWriteLabel($xlsRow,4,"$sname"); $xlsRow++; } xlsEOF(); exit(); ?> Original article for the code could be found in http://www.appservnetwork.com/modules.php?name=News&file=article&sid=8 Cheers
  3. Hey, I'm not sure if this is the right place to ask that question but here you go... I use google map api with xml in my site and i want to disable public access to xml file.Is there anyway of doing it?! I thought maybe i could use php/mysql instead of xml but don't know how to do it exactly with google map api. cheers
  4. i don't think there will be anyone giving you a whole script, but i can list you so simply what you need to do, 1)Find a multiple image upload script.here is an example: [url=http://www.plus2net.com/php_tutorial/php_multi_file_upload.php]http://www.plus2net.com/php_tutorial/php_multi_file_upload.php[/url] 2) Then find a image resize script. here is an example: [url=http://www.bigbold.com/snippets/posts/show/486]http://www.bigbold.com/snippets/posts/show/486[/url] 3) Last thing you need to do is after each image uploade, insert their details to DB : Ex: [code] mysql_query("INSERT INTO images_table VALUES('$imageID','$imagename')"); [/code] Hope this path will be helpful for you.
  5. see this line [code]echo '<img src="',$Sigs[$i],'" >';[/code] I took it from your code, better if you change it in that way, [code] echo '<img src=\"'.$Sigs[$i].'\" >'; [/code] i think then it should work ok.
  6. if i understood correct what you mean, then you need to use ajax(simply javascript). better if you check some beginner ajax tutorials for XMLRequest so on.
  7. You have to write session_start() at the top of the page.Solution is so easy, replace this [code]if (!isset($_SESSION)) {   session_start(); }[/code] with that [code]session_start();[/code] that's it.You already have to start session anyway if you wanna use it in the page, you don't need to check it like that.If you wanna check a specific session then you could use the one below [code] session_start(); if (!isset($_SESSION['test'])) {   //here you can do what ever you wanna do } [/code]
  8. utexas_pjm, thank you for you answer.This way might be usefull also but as i was in a kind of hurry, i found and used someother technic. I would like to explain it here for other people who may be intereste in future. What I did is, First I search with RAND() then put all the results into a SESSION, cookie could be used also, then I used session just like array and made pagination thru it. Thank you again.
  9. hi, I wrote a script to search the database and page the results.There is no problem upto here. But I want to display in different order each time. I tried to use ORDER BY rand() and it seems working but there are two problems with that, First, as I cannot follow the order,sometimes same result(s) is diplayed in more than one page. And the second problem is, when i click on the list to any link and then go back to list, the result list is changed as everytime ORDER BY rand() runs. As far as I see ORDER BY rand() is not what i am looking for.I thought I could insert SQL results into array and then page the array to follow the order but again how am I gonna pass the array to next pages to follow the order?! I am a bit mixed-up here. Could be great if someone could help me. Cheers
  10. I even don't know how to ask this question properly. I want to use DBA function (such as dba_open so on.). But I think first I have to enable PHP for basic support of dbm-style databases. In the manuel it says [tt]By using the --enable-dba=shared  configuration option you can build a dynamic loadable module to enable[/tt] how can I use "--enable-dba=shared"? I know it's quit silly question  :-\ I use windows, so if it changes the way to use it! Thanx
×
×
  • 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.