Volledige versie bekijken : flash+PHP gebaseerd guestbook&special characters in flash
laurita
%Europe/Berlin %743 %2006, 18:50
Hoi,
ik heb al op een aantal forums deze vraag gesteld, ik hoop dat hier iemand me kan helpen.
Ik hbe een guestbook gemaakt in flash, deze werkt samen met een PHP file en een txtfile. Op de site kun je gewoon de tekst intypen, dan zie al de special characters, maar zodra je dit verzend....en flash moet de textfile weer downloaden, dan laat ie de special characters weg....
Ik hoop dat iemand mij kan helpen!
Thanks!
Laiverd
%Europe/Berlin %772 %2006, 19:31
Het is al zo vaak gezegd: als je tekst (op wat voor manier dan ook) naar Flash stuurt moet je 'm UTF8 encoden. Daar is in PHP een functie voor. Verder even zoeken op dit forum en je komt meerdere posts tegen.
John
laurita
%Europe/Berlin %883 %2006, 22:12
Ik had de text gesaved als een UMT-8 bestand, en nog steeds verschijnen de tekens niet...zou het ergens anders aan kunnen liggen???
De Kale
%Europe/Berlin %884 %2006, 22:13
volgens mij heeft laurita nog niet zoveel kans gezien om hier flink te zoeken laiverd...beetje lief zijn...
@laurita: sla je textbestand in notepad op als utf-8 (unicode) via 'save as'
dan zouden de karakters goed moeten displayen.
in php heb je idd een functie die je karakters in de utf-8 character encoding om kunnen zetten.
bekijk ook dit even: http://www.depannekoekendekale.nl/projects/unicode
WernerL
%Europe/Berlin %891 %2006, 22:23
php.net - utf8_encode (http://nl2.php.net/utf8_encode)
laurita
%Europe/Berlin %893 %2006, 22:27
ja, ik had het dus gesaved als UTF-8 unicode, maar dan nog steeds niets... helaas!
Ik hbe een script overgenomen in mijn PHP bestand, maar dan ook niets...
<?php
for($i=1; $i<=3000; ++$i){
echo $i.": &#".$i.";<br>\n";
}
?>
wat nu????
help!!!!
laurita
%Europe/Berlin %907 %2006, 22:46
er zijn te veel scripts te vinden over de UTF-8 unicode, ik denk dat er inderdaad een code mist in mijn PHP file, (maar in mijn textfile die flash download, staan wel gewoon alle characters goed...)
ik heb nu meerdere codes geprobeerd, maar dat werkt niet...
Tja ik ben een ontwerper en geen programmeur..(hahaha)
WernerL
%Europe/Berlin %912 %2006, 22:54
Wellicht moet je dmv de header() functie aangeven dat hetgene wat ge-echo-t gaat worden utf8 encode gebruikt. :-)
laurita
%Europe/Berlin %916 %2006, 22:59
Wellicht moet je dmv de header() functie aangeven dat hetgene wat ge-echo-t gaat worden utf8 encode gebruikt. :-)
Hmmm...klinkt logisch...hahaha...maar hoe werkt dat.... (zoals ik al schreef, ik ben geen programmeur...sorry)
WernerL
%Europe/Berlin %924 %2006, 23:11
header("unicode: UTF-8"); probeer dat eens? Gewoon helemaal bovenaanzetten. :-) (wel na de <?php uiteraard..)
laurita
%Europe/Berlin %931 %2006, 23:21
heb ik gedaan...
de text wordt nu helemaal niet geladen....
hmmm
laurita
%Europe/Berlin %935 %2006, 23:27
misschien is dit handiger...dit is mij PHP file:
<title>GuestBook</title><?php
header("unicode: UTF-8")
// If you are using an old version of php, remove the next set of lines.
// or use $HTTP_POST_VARS["..."] instead.
$Submit = $_POST["Submit"];
$Name = $_POST["Name"];
$Email = $_POST["Email"];
$Website = $_POST["Website"];
$Comments = $_POST["Comments"];
$NumLow = $_REQUEST["NumLow"];
$NumHigh = $_REQUEST["NumHigh"];
// Replace special characters - you can remove the next 5 lines if wanted.
//$Name = ereg_replace("[^A-Za-z0-9 ]", "", $Name);
//$Email = ereg_replace("[^A-Za-z0-9 \@\.\-\/\']", "", $Email);
//$Comments = ereg_replace("[^A-Za-z0-9 \@\.\-\/\']", "", $Comments);
//$Website = eregi_replace("http://", "", $Website);
//$Website = ereg_replace("[^A-Za-z0-9 \@\.\-\/\'\~\:]", "", $Website);
// Remove slashes.
$Name = stripslashes($Name);
$Email = stripslashes($Email);
$Website = stripslashes($Website);
$Comments = stripslashes($Comments);
// ################################################## #################################
// ########## Reading and Writing the new data to the GuestBook Database #############
if ($Submit == "Yes") {
// Next line tells the script which Text file to open.
$filename = "GuestBook.txt";
// Opens up the file declared above for reading
$fp = fopen( $filename,"r");
$OldData = fread($fp, 80000);
fclose( $fp );
// Gets the current Date of when the entry was submitted
$Today = (date ("l dS of F Y ( h:i:s A )",time()));
// Puts the recently added data into html format that can be read into the Flash Movie.
// You can change this up and add additional html formating to this area. For a complete listing of all html tags
// you can use in flash - visit: http://www.macromedia.com/support/flash/ts/documents/htmltext.htm
$Input = "Name: <b>$Name</b><br>Email: <u><a href=\"mailto:$Email\">$Email</a></u><br>Website: <u><a href=\"http://$Website\" target=\"_blank\">$Website</a></u><br>Comments: <b>$Comments</b><br><font size=\"-1\">Date: $Today</font><br><br>.:::.";
/* This Line adds the '&GuestBook=' part to the front of the data that is stored in the text file. This is important because without this the Flash movie would not be able to assign the variable 'GuestBook' to the value that is located in this text file */
$New = "$Input$OldData";
// Opens and writes the file.
$fp = fopen( $filename,"w");
if(!$fp) die("&GuestBook=cannot write $filename ......&");
fwrite($fp, $New, 800000);
fclose( $fp );
}
// ################################################## #################################
// ######### Formatting and Printing the Data from the Guestbook to the Flash Movie ##
// Next line tells the script which Text file to open.
$filename = "GuestBook.txt";
// Opens up the file declared above for reading
$fp = fopen( $filename,"r");
$Data = fread($fp, 800000);
fclose( $fp );
// Splits the Old data into an array anytime it finds the pattern .:::.
$DataArray = split (".:::.", $Data);
// Counts the Number of entries in the GuestBook
$NumEntries = count($DataArray) - 1;
print "&TotalEntries=$NumEntries&NumLow=$NumLow&NumHigh=$NumHigh&GuestBook=";
for ($n = $NumLow; $n < $NumHigh; $n++) {
print $DataArray[$n];
if (!$DataArray[$n]) {
Print "<br><br><b>No More entries</b>";
exit;
}
}
?>
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.