Dobrý den.
Mám takový problém.
Do databáze se mi ukládá <, když ve formuláři odešlu data.
Jak mám ale udělat, aby mi to neukládalo <, ale to co chci a to znak <?
Děkuju za pomoc.
Fórum › MySQL
Vkládání < a > do databáze

wise napsal:
Dobrý den.
Mám takový problém.
Do databáze se mi ukládá <, když ve formuláři odešlu data.
Jak mám ale udělat, aby mi to neukládalo <, ale to co chci a to znak <?
Děkuju za pomoc.
daj sem kod akym to vkladas, lebo mne sa to este nestalo ;)
To 7raul :
// pridani clanku
$sValue = /*stripslashes*/($_POST['FCKeditor']);
$sValue_introduction = ($_POST['FCKeditor2']);
$sql="INSERT INTO `ramsey_articles` (`section` , `author` , `time` , `caption` , `text` , `introduction`, `ok` )"
." VALUES('".$_POST["section"]."' , '".$auth_user."' , '".time()."' , '".$_POST["caption"]."' , \"$sValue\" ,\"$sValue_introduction\",'".$_POST["ok"]."' ) ";
$insert=mysql_query($sql);
To 7raul : hledal jsem hledal, ale nikde jsem nenašel. FCKeditor to někde konvertuje na entity, ale já nevim kde a nechci to.
Asi tu nebude nikdo, kdo má zkušenosti s FCKeditorem že? Aby mi poradil.
Takže našel sem v editoru toto:
// '>':'gt', // This entity is automatically handled by the XHTML parser.
A teď by mě zajímalo, jak to udělat, aby to dělalo to, co chci...Poradí někdo prosím? :o)
tak stiahol som si tento editor aby som ti mohol pomoct tak ideme na to:
POSTUP:
otvor subor fckeditor_php5
najdi
$HtmlValue = htmlspecialchars( $this->Value ) ;
nahrad tymto:
$HtmlValue = $this->Value;
_______________________________________________________________________
otvor subor fckeditor_php4
najdi
$HtmlValue = htmlspecialchars( $this->Value ) ;
nahrad tymto:
$HtmlValue = $this->Value;
no myslym ze by to malo byt vyriesene ked tak napis ako si dopadol...
Bohužel. Stále to stejné.
Vložím do editoru tento kod:
<pre class="brush: c-sharp;">
function test() : String
{
return 10;
}
</pre>
a do databáze se mi uloží
<p><pre class="brush: c-sharp;">
function test() : String
{
return 10;
}
</pre>
</p>
Pokud se podíváš souboru editor/_source/internals/fckxhtmlentities.js najde tam toto a podobné.
// '>':'gt', // This entity is automatically handled by the XHTML parser.
Dále, pokud vypíšu kod z databáze, je tak jak má být a to:
<pre class="brush: c-sharp;">
function test() : String
{
return 10;
}
</pre>
Ale nejde na něj aplikovat css styly, jelikož se mi aplikuje na tag <pre>, ale není to <pre> ale <pre
Každopádně úpravou podle tebe to nepomohlo, bohužel.
Narazil jsem na internetu na tohle : http://webdrive.cz/phpnet/phpnet-funkce-detail.php?kod=function.html-entity-decode
Zkusil jsem to podle toho
// pridani clanku
$fckeditorT = $_POST['FCKeditor'];
$fckeditorT2 = $_POST['FCKeditor2'];
$sValueE = htmlentities($fckeditorT);
$sValue_introductionE = htmlentities($fckeditorT2);
$sValue = html_entity_decode($sValueE);
$sValue_introduction = html_entity_decode($sValue_introductionE);
$sql="INSERT INTO `ramsey_articles` (`section` , `author` , `time` , `caption` , `text` , `introduction`, `ok` )"
." VALUES('".$_POST["section"]."' , '".$auth_user."' , '".time()."' , '".$_POST["caption"]."' , \"$sValue\" ,\"$sValue_introduction\",'".$_POST["ok"]."' ) ";
$insert=mysql_query($sql);
ale stále se do databáze ukládají entity
Jinak, přihlásil jsem se do DB a tam to upravil ručně, aby to vypadlo tak, jak chci a poté co jsem to vypsal to udělalo to co chci. Takže je problém v ukládání do DB.
skus pouzit tento kod
// pridani clanku
$fckeditorT = $_POST['FCKeditor'];
$fckeditorT2 = $_POST['FCKeditor2'];
$sql="INSERT INTO `ramsey_articles` (`section` , `author` , `time` , `caption` , `text` , `introduction`, `ok` )"
." VALUES('".$_POST["section"]."' , '".$auth_user."' , '".time()."' , '".$_POST["caption"]."' , \"$sValue\" ,\"$sValue_introduction\",'".$_POST["ok"]."' ) ";
$insert=mysql_query($sql);
Otevři konfigurační soubor fckconfig.js a nastav viz. níže, pak by to mělo být ok.
FCKConfig.ProcessHTMLEntities = false;
FCKConfig.IncludeLatinEntities = false;
FCKConfig.IncludeGreekEntities = false;
FCKConfig.ProcessNumericEntities = false;
FCKConfig.AdditionalNumericEntities = '';
To 7raul : neboj, to jsem tam měl předtím, než jsem to upravil podle tamtý stránky.
btw. jak si napsal ten kod, tak máš špatně přiřazený proměnný, ale to je detail
Stále stejné...
<pre class="brush: php;">
echo "ahoj";
</pre>
takto se mi to ukládá do databáze...pořád jako na začátku
nastavení fckconfig.js jsem udělal,
a zde jde kod pro vložení nového článku
// vlozeni noveho clanku
if ($action=="new")
{
// pridani clanku
$sValue = $_POST['FCKeditor'];
$sValue_introduction = $_POST['FCKeditor2'];
$sql="INSERT INTO `ramsey_articles` (`section` , `author` , `time` , `caption` , `text` , `introduction`, `ok` )"
." VALUES('".$_POST["section"]."' , '".$auth_user."' , '".time()."' , '".$_POST["caption"]."' , \"$sValue\" ,\"$sValue_introduction\",'".$_POST["ok"]."' ) ";
$insert=mysql_query($sql);
To wise : To nastaveni v fckconfig.js by mělo stačit. Napadá mě jedině, že se ti natahuje jiný konfigurák. Já volám FCKeditor s těmito parametry (viz. dokumentace FCKeditoru na http://www.fckeditor.net).
Jakou máš verzi FCKeditoru?
<?php
$oFCKeditor = new FCKeditor('FCKeditor');
$oFCKeditor->BasePath = '/editor/FCKeditor/';
$oFCKeditor->Value = 'Zde napište text';
$sValue = stripslashes( $_POST['FCKeditor'] );
$oFCKeditor->Width = '700';
$oFCKeditor->Height = '400';
$oFCKeditor->Config['CustomConfigurationsPath'] = '/editor/FCKeditor/myconfig.js';
$Config['UserFilesPath'] = '/upload/';
$oFCKeditor->Create();
?>
To bl4z4 : Používám verzi 2.6.3, Build 19836
resp. ten nejnovější myslím.
Jinak já ho volám takto: (resp. je, jelikož mám 2, jeden pro úvod a druhý pro hl. novinku)
echo "<b>Úvod:</b><br>";
$oFCKeditor2 = new FCKeditor('FCKeditor2');
$oFCKeditor2->BasePath = 'fckeditor/';
$oFCKeditor2->Value = $edited_text2;
$oFCKeditor2->Width = '100%';
$oFCKeditor2->Height = '300';
$oFCKeditor2->Create();
echo "<br><br><br>";
echo "<b>Text:</b><br>";
$oFCKeditor = new FCKeditor('FCKeditor');
$oFCKeditor->BasePath = 'fckeditor/';
$oFCKeditor->Value = $edited_text;
$oFCKeditor->Width = '100%';
$oFCKeditor->Height = '500';
$oFCKeditor->Create();
btw. zkoušel sem přidat přes editor třeba tučný písmo a do db se to uloží normálně jako
<strong>sdasdasdasd</strong>
a co je to za soubor myconfig.js?

Přidej příspěvek
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
































Uživatelé prohlížející si toto vlákno
Podobná vlákna
Vkládání obrázků do databáze — založil Anonym
Vkladani zaznamu z XML do databaze — založil Anonymní uživatel
Pomoc s PHP/DATABAZE - vkladani — založil Jakub Hencl
Vkládání dat z databáze do souboru — založil Hatykar
Vkládání více možností z formuláře do databáze — založil divady
Moderátoři diskuze