Autor Zpráva
leorond
Profil
Dobrý den,
již jednou jsem tu tento problém řešil a řeším tento problém i nadále už skoro rok, stále nemohu najít žádné řešení. Mám MSSQL 2005 express a na mém webu který je spuštěný na XAMPP 1.7.3 mi nefungují znaky ýáíé, zkusil jsem snad všechny metody jak to opravit ale stále se mi do databáze zapisuje místo požadovaného ěščřžýáíé toto %u011B%u0161%u010D%u0159%u017Eýáíé a právě tam je ten problém. Pokud vložím do hlavičky mého scryptu tento header:

header("Content-Type: text/html; charset=Windows-1250");

Po manuálním zapsání do databáze se znaky oběvují správně ale v hlavičce webu se mi oběví toto .

Nemohl by jste mi někdo poradit jak upravit můj scrypt tak aby posílal do databáze data ve správném formátu a toto  na mém webu nebylo?

Zde je scrypt pro odesílání dat do databáze:
addnews.php
<?php
include    ("gmaccess.php");
include    ("functions/textreplace.php");
include    ("functions/text.php");
if ($cat[1]    !=    NULL)    $cat[1]    =    ";".$cat[1];
if    (isset($_POST['add_news']))
{
    $result    =    mssql_query("select top 1 id from ew_news order by id desc");
    $myrow    =    mssql_fetch_array($result);
    if (mssql_num_rows($result)    ==    0)    $idn    =    1;
    else    $idn    =    $myrow[0];
    $languages    =    explode(",",$enemy['languages']);
    $k    =    0;
    $ii    =    0;
    do
    {
    
        $title    =    trim(stripslashes($_POST['title'.$languages[$k].'']));
        $text    =    trim(stripslashes($_POST['text'.$languages[$k].'']));
        if    (empty($title)    or    empty($text))
        {
            echo    "<p><ul><li>".eror_complete_data."</li></ul></p>";
        }
        elseif (strlen($text)    >    $Limit['news_post'])
        {
            echo    "<ul><li>".try_to_enter_more_char."</li></ul>";
        }
        else    
        {
            $ii++;
            $text    =    replace_text('add',$text);
            $query    =    mssql_query("insert into EW_NEWS (title,lang,date,idn,text,posted_by) values ('$title','".$languages[$k]."','$date',$idn+1,'$text','$nickname')");
        }
        $k++;
    }
    while    ($k    <    count($languages));
    if ($ii    ==    count($languages))    echo    "<ul><li>".news_added."</li></ul>";
}
elseif    (isset($_POST['delete_news'])) 
{
    $id        =    trim($_POST['id']);
    if (!preg_match('/^[0-9]/i',    $id))
    {
        echo "<ul><li>".something_wrong."</li></ul>";
    }
    else
    {
        $result    =    mssql_query("select id from ew_news where idn='$id'");
        if    (mssql_num_rows($result)    >    0)
        {
            $query    =    mssql_query("delete from EW_NEWS where idn    =    $id");
            echo    "<ul><li>".news_deleted."</li></ul>";
        }
        else
        {
            echo    "<ul><li>".news_not_found."</li></ul>";
        }
    }
}
elseif    (isset($_POST['edit_newss']))
{
    $title        =    trim(stripslashes($_POST['title']));
    $text        =    trim(stripslashes($_POST['text']));
    $id_news    =    trim($_POST['id_news']);
    if    (empty($title)    or    empty($text) or !preg_match('/^[0-9]/i',    $id_news))
    {
        echo    "<ul><li>".eror_complete_data."</li></ul>";
    }
    elseif (strlen($text)    >    $Limit['news_post'])
    {
        echo    "<ul><li>".try_to_enter_more_char."</li></ul>";
    }
    else    
    {
        $result    =    mssql_query("select id from ew_news where id='$id_news'");
        if    (mssql_num_rows($result)    >    0)
        {
            $text    =    replace_text('add',$text);
            $query    =    mssql_query("update EW_NEWS set title    =    '$title', text    =    '$text' where id=$id_news");
            echo    "<p><ul><li>".news_edited."</li></ul></p>";
        }
        else
        {
            echo    "<ul><li>".news_not_found."</li></ul>";
        }
    }
}
echo "<script type=\"text/javascript\">document.getElementById(\"h4\").innerHTML = \"".admin_news."\"</script>
        <input type='hidden' id='module_contet' value='".admin_news."'>";
echo    "<table width='100%' align=center border='0' cellpadding='0' cellspacing='2'>
            <tr class='top_table'>
                <td><b>№</b></td>
                <td><b>".title."</b></td>
                <td><b>".posted_by."</b></td>
                <td><b>".posted_date."</b></td>
                <td colspan='2'><b>".table_options."</b></td>
            </tr>
";
$num        =    $Option['news_pg'];
@$page        =    $_GET['page'];
$result00    =    mssql_query("SELECT COUNT(*) FROM EW_NEWS");
$temp        =    mssql_fetch_array($result00);
$posts        =    $temp[0];
if    ($posts    ==    0)    $posts    =    1;
$total        =    (($posts - 1) / $num) + 1;
$total        =    intval($total);
$page        =    intval($page);
if    (empty($page)    or    $page < 0)    $page    =    1;
if    ($page    >    $total)    $page    =    $total;
$start        =    $num * ($page - 1);
$result        =    mssql_query("SELECT TOP $num * FROM EW_NEWS where id NOT IN (SELECT TOP $start id FROM EW_NEWS ORDER BY id desc) ORDER BY id desc");
if    (mssql_num_rows($result)    >    0)
{
    $myrow    =    mssql_fetch_array($result);
    $kk        =    0;
    do
    {
        $kk++;
        $myrow["title"]    =    UTF8RawUrlDecode(htmlspecialchars($myrow["title"]));
        printf    ("<tr class='contet_table' align='center'>
                    <td><b>%s</b></td>
                    <td><a>%s</a></td>
                    <td>%s</td>
                    <td>%s</td>
                    <td width='5'>
                        <form onsubmit=\"request('form_edit%s','sh_','POST','getpage.php?cat=Add-News".$cat[1]."'); return false;\" id='form_edit%s'>
                            <input name='id' type='hidden' value='%s'>
                            <input name='edit_news' type='submit' value='".edit_news."'>
                        </form>            
                    </td>
                    <td width='5'>
                        <form onsubmit=\"request('form_delete%s','sh_','POST','getpage.php?cat=Add-News".$cat[1]."'); return false;\" id='form_delete%s'>
                            <input name='id' type='hidden' value='%s'>
                            <input name='delete_news' type='submit' value='".delete_news."'>
                        </form>
                    </td>
        ",    $kk,    $myrow['title'],    $myrow['posted_by'],    $myrow['date'],    $myrow['id'],    $myrow['id'],    $myrow['id'],    $myrow['id'],    $myrow['id'],    $myrow['idn']);
    }
    while    ($myrow    =    mssql_fetch_array($result));
}
echo    "</table><br>";
if    ($page    !=    1)    $pervpage    =    '<a href=?emw;Add-News;1 rel="history2">'.first.'</a> | <a href=?emw;Add-News;'. ($page - 1) .' rel="history2">'.previous.'</a> | ';
if    ($page    !=    $total)    $nextpage    =    ' | <a href=?emw;Add-News;'.($page + 1).' rel="history2">'.next.'</a> | <a href=?emw;Add-News;'.$total.' rel="history2">'.last.'</a>';
if    ($page - 5    >    0)    $page5left    =    '<a href=?emw;Add-News;'.($page - 5).' rel="history2">'.($page - 5).'</a> | ';
if    ($page - 4    >    0)    $page4left    =    '<a href=?emw;Add-News;'.($page - 4).' rel="history2">'.($page - 4).'</a> | ';
if    ($page - 3    >    0)    $page3left    =    '<a href=?emw;Add-News;'.($page - 3).' rel="history2">'.($page - 3).'</a> | ';
if    ($page - 2    >    0)    $page2left    =    '<a href=?emw;Add-News;'.($page - 2).' rel="history2">'.($page - 2).'</a> | ';
if    ($page - 1    >    0)    $page1left    =    '<a href=?emw;Add-News;'.($page - 1).' rel="history2">'.($page - 1).'</a> | ';
if    ($page + 5    <=    $total)    $page5right    =    ' | <a href=?emw;Add-News;'.($page + 5).' rel="history2">'.($page + 5).'</a>';
if    ($page + 4    <=    $total)    $page4right    =    ' | <a href=?emw;Add-News;'.($page + 4).' rel="history2">'.($page + 4).'</a>';
if    ($page + 3    <=    $total)    $page3right    =    ' | <a href=?emw;Add-News;'.($page + 3).' rel="history2">'.($page + 3).'</a>';
if    ($page + 2    <=    $total)    $page2right    =    ' | <a href=?emw;Add-News;'.($page + 2).' rel="history2">'.($page + 2).'</a>';
if    ($page + 1    <=    $total)    $page1right    =    ' | <a href=?emw;Add-News;'.($page + 1).' rel="history2">'.($page + 1).'</a>';
if    ($total    >    1)
{
    Error_Reporting(E_ALL & ~E_NOTICE);
    echo    "<center><div class=\"pstrnav\">";
    echo    $pervpage.$page5left.$page4left.$page3left.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.$page2right.$page3right.$page4right.$page5right.$nextpage;
    echo    "</div></center>";
}
if    (isset($_POST['edit_news']))
{
    $id        =    trim($_POST['id']);
    if (!preg_match('/^[0-9]/i',    $id))
    {
        echo "<ul><li>".something_wrong."</li></ul>";
    }
    else
    {
        $result    =    mssql_query("select * from EW_NEWS where id=$id");
        $myrow    =    mssql_fetch_array($result);
        ?>
        <br>
        <form onsubmit="request('form_com','sh_','POST','getpage.php?cat=Add-News<? echo $cat[1];?>'); return false;" id="form_com">
            <? echo    title;?>:<input  value="<? echo    htmlspecialchars(UTF8RawUrlDecode($myrow['title']));?>" name="title" type="text" size="30" maxlength="100">
            <?php    $myrow['text']    =    preg_replace("'<br>'",    "\n",    $myrow['text']);    ?>
            <? echo news_textarea("form_com","text",htmlspecialchars(UTF8RawUrlDecode($myrow['text'])),$Limit['news_post'],"");?>
            <input name="id_news" type="hidden" value="<?    echo    $myrow['id'];    ?>" >
            <input type="submit" name="edit_newss" id="submit" value="<?    echo    edit_news;    ?>" >
        </form>
        <?
    }
}
else
{
    ?>
    <br>
    <form onsubmit="request('form_com','sh_','POST','getpage.php?cat=Add-News<? echo $cat[1];?>'); return false;" id="form_com">
    <?
    $languages    =    explode(",",$enemy['languages']);
    $k    =    0;
    do
    {
        if ($k    ==    0)    $background    =    "background:#dddddd;";
        else    $background    =    "background:#aaaaaa;";
        $kk    =    0;
        $onclick    =    "";
        do
        {
            if ($kk    ==    $k)    $onclick    .=    "document.getElementById('news".$languages[$kk]."').style.display='';document.getElementById('language".$languages[$kk]."').style.backgroundColor='#dddddd';";
            else    $onclick    .=    "document.getElementById('news".$languages[$kk]."').style.display='none';document.getElementById('language".$languages[$kk]."').style.backgroundColor='#aaaaaa';";
            $kk++;
        }
        while ($kk    <    count($languages));
        echo "<input style='".$background."' id='language".$languages[$k]."' type='button' value='".$languages[$k]."' onclick=\"".$onclick."\">";
        $k++;
    }
    while ($k    <    count($languages));
    $k    =    0;
    do
    {
        if ($k    !=    0)    $display    =    "display:none;";
        else    $display    =    "";
        ?>
        <div style=" <? echo $display;?>" id="news<? echo $languages[$k];?>"><? echo    title;?>:<input name="title<? echo $languages[$k];?>" type="text" size="30" maxlength="100">
        <? echo news_textarea("form_com","text".$languages[$k],"",$Limit['news_post'],$languages[$k]);?>
        </div>
        <?
        $k++;
    }
    while ($k    <    count($languages));
    ?>
        <input name="add_news" type="submit" value="<? echo    add_news;?>">
    </form>
    <?
}
?>

Zde pro výpis z databáze:
news.php

[pre]<?
include ("functions/textreplace.php");
echo "<script type=\"text/javascript\">document.getElementById(\"h4\").innerHTML = \"".news."\"</script>
<input type='hidden' id='module_contet' value='".news."'>";
$num = $Option['news_pg'];
$page = $_GET['page'];
$result00 = mssql_query("SELECT COUNT(*) FROM EW_NEWS where lang='".$language."'");
$temp = mssql_fetch_array($result00);
$posts = $temp[0];
if ($posts
Toto téma je uzamčeno. Odpověď nelze zaslat.