הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   בעיה עם ajax ועברית (https://hosts.co.il/forums/showthread.php?t=66757)

kfir91 26-08-08 12:50

בעיה עם ajax ועברית
 
http://depsport.freehost.co.il/update/test.php
תנסו ללחוץ על מה שרשום ולשנות אותו לעברית ולעדכן תראו איזה שפה זה עושה
ובאנגלית זה עובד טוב
זה הקוד של הקובץ עידכון ב PHP :
קוד:

<?
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header('Content-Type: text/html; charset=windows-1255');
include "config.php";

$content = $_GET['content'];
list($fieldname, $id) = explode("-|||-",$_GET['fieldname']);
mysql_query("UPDATE result SET $fieldname='$content' WHERE id='$id'") or die("blah failure - ".mysql_error() );
$result = mysql_query("SELECT * FROM result WHERE id='$id'");
$row = mysql_fetch_assoc($result);
echo $row["{$fieldname}"];
?>


reXtea 26-08-08 13:51

ציטוט:

נכתב במקור על ידי kfir91 (פרסם 662722)
http://depsport.freehost.co.il/update/test.php
תנסו ללחוץ על מה שרשום ולשנות אותו לעברית ולעדכן תראו איזה שפה זה עושה
ובאנגלית זה עובד טוב
זה הקוד של הקובץ עידכון ב PHP :
קוד:

<?
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header('Content-Type: text/html; charset=windows-1255');
include "config.php";

$content = $_GET['content'];
list($fieldname, $id) = explode("-|||-",$_GET['fieldname']);
mysql_query("UPDATE result SET $fieldname='$content' WHERE id='$id'") or die("blah failure - ".mysql_error() );
$result = mysql_query("SELECT * FROM result WHERE id='$id'");
$row = mysql_fetch_assoc($result);
echo $row["{$fieldname}"];
?>


הבעיה זה הקידוד בעצם, והפתרון הוא להעביר את מה שאתה מקבל בget בעצם את
$_GET['content'] בפונקציה הבאה:

PHP קוד:

    function iconv_utf8_cp1255($utf8) {
        return 
preg_replace "/\xD7([\x90-\xAA])/e""chr(ord(\${1})+80)"$utf8 );
    } 

בהצלחה

kfir91 26-08-08 14:11

עדיין לא עובד
עשיתי ככה :
קוד:

<?
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header('Content-Type: text/html; charset=windows-1255');
include "config.php";

function iconv_cp1255_utf8($cp1255) {
        return preg_replace ( "/([\xE0-\xFA])/e", "chr(215).chr(ord(\${1})-80)", $cp1255 );
    } 

$content = iconv_cp1255_utf8($_GET['content']);
list($fieldname, $id) = explode("-|||-",$_GET['fieldname']);
mysql_query("UPDATE result SET $fieldname='$content' WHERE id='$id'") or die("blah failure - ".mysql_error() );
$result = mysql_query("SELECT * FROM result WHERE id='$id'");
$row = mysql_fetch_assoc($result);
echo $row["{$fieldname}"];
?>


O-B 26-08-08 18:01

אצלי אי אפשר ללחוץ על זה..
פיירפוקס 2..

kfir91 26-08-08 18:37

בסדר נפתרה ההבעיה פה תעזרו לי באשכול השני בבקשה


כל הזמנים הם GMT +2. הזמן כעת הוא 16:31.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ