Jump to content

Search the Community

Showing results for tags 'special characters'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 4 results

  1. I created a form where someone can add their name and a comment and then submit it to my database. here's the code of the form PHP <form method="post" action="addcomments_per_student_action.php" enctype="multipart/form-data" style="width: 700px; height: 400px;"> <?php $x=$_GET['st']; $result = $log->qry("Select * from students where id=".$x); $row=mysql_fetch_assoc($result); echo $row['name'].' - '.$row['surname']; ?> <input type="hidden" name="st" value="<?php echo $row['id']; ?>"> <br><br> <label>name</label> <input type="text" name="comm" required><br> <label>comment</label> <textarea name="comments" style="width: 600px; heigh: 350px;"></textarea> <br> <input name="submit" id="submit" value="submit" type="submit" style="width: 150px;"><br> </form> and here's the code of the form's action PHP <?php require ('logmein.php'); $log = new logmein(); if($log->logincheck($_SESSION['loggedin'],"logon","password","username") == false) { //elenxos egkirotitas sindesis tou xristi sto sistima.An oxi epistrofi stin index me plirofories tou lathous $log->redirect($log->getHost()); } if($_SESSION['userlevel']!=0) { $log->redirect($log->getHost()."?result=3"); } $student=$_POST['st']; $comm=$_POST['comm']; $comments=$_POST['comments']; $log->qry("Insert into comments (student,comm,comment) values (".$student.",'".$comm."','".$comments."')"); $log->redirect("http://spoudastirio.com.gr/grades/comments.php"); ?> THE PROBLEM: When someone submits a plain text, it works fine , but where they write ' symbol the file gets an error. THE ERROR: When i type "here's the game" in the textarea i get this error. You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 's the best game.')' at line 1 My database table is utf8-general ci // text format. How can i solve it, so there won't be this kind of problems.
  2. I have a question, I have a fully working PHP mail form, but I can't seem to find one problem. I thought it had something to do with the data cleansing like trim, htmlspecialcharacters and stripslashes, but unfortunately that wasn't. My form has to be able to process characters like é è á ó etc. Just that now when you fill those characters in it shows some weird code in the mail. (é becomes é in the mail) and this is highly inconvenient. Could any1 tell me how I can fix this? this is the PHP code for my form: <?php if(isset($_POST['submit'])) { function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $error = ""; //Keep Values $Papillon_checked = (isset($_POST['ras']) && $_POST['ras'] == 'Papillon') ? 'checked' : ''; $Phalene_checked = (isset($_POST['ras']) && $_POST['ras'] == 'Phalene') ? 'checked' : ''; $Babyklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Babyklasse') ? 'checked' : ''; $Puppyklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Puppyklasse') ? 'checked' : ''; $Jeugdklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Jeugdklasse') ? 'checked' : ''; $Tussenklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Tussenklasse') ? 'checked' : ''; $Openklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Openklasse') ? 'checked' : ''; $Kampioensklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Kampioensklasse') ? 'checked' : ''; $Fokkersklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Fokkersklasse') ? 'checked' : ''; $Veteranenklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Veteranenklasse') ? 'checked' : ''; //Validate form fields if (!empty($_POST['ras'])) { $ras = $_POST['ras']; } else { $error .= "- Klik het ras van uw hond aan. <br />";} if (!empty($_POST['kleur'])) { $kleur = test_input($_POST['kleur']); } else { $error .= "- Vul de kleur van uw hond in. <br />";} if (!empty($_POST['geslacht'])) { $geslacht = test_input($_POST['geslacht']); } else { $error .= "- Vul het geslacht van uw hond in. <br />";} if (!empty($_POST['naamhond'])) { $naamhond = test_input($_POST['naamhond']); } else { $error .= "- Vul de naam van uw hond in. <br />";} if (!empty($_POST['stamboom'])) { $stamboom = test_input($_POST['stamboom']); } else { $error .= "- Vul het stamboomnummer van uw hond in. <br />";} if (!empty($_POST['geboorte'])) { $geboorte = test_input($_POST['geboorte']); } else { $error .= "- Vul de geboortedatum van uw hond in. <br />";} if (!empty($_POST['klasse'])) { $klasse = $_POST['klasse']; } else { $error .= "- Klik de gewenste klasse aan. <br />"; } if (!empty($_POST['fokker'])) { $fokker = test_input($_POST['fokker']); } else { $error .= "- Vul de naam van de fokker in. <br />";} if (!empty($_POST['vader'])) { $vader = test_input($_POST['vader']); } else { $error .= "- Vul de naam van de vaderhond in. <br />";} if (!empty($_POST['moeder'])) { $moeder = test_input($_POST['moeder']); } else { $error .= "- Vul de naam van de moederhond in. <br />";} if (!empty($_POST['initialen'])) { $initialen = test_input($_POST['initialen']); } else { $error .= "- Vul uw initialen in. <br />";} if (!empty($_POST['eigachternaam'])) { $eigachternaam = test_input($_POST['eigachternaam']); } else { $error .= "- Vul uw achternaam in. <br />";} if (!empty($_POST['minitialen'])) { $minitialen = test_input($_POST['minitialen']);} if (!empty($_POST['meigachternaam'])) { $meigachternaam = test_input($_POST['meigachternaam']);} if (!empty($_POST['straat'])) { $straat = test_input($_POST['straat']); } else { $error .= "- Vul uw straatnaam in. <br />";} if (!empty($_POST['huisnr'])) { $huisnr = test_input($_POST['huisnr']); } else { $error .= "- Vul uw huisnummer in. <br />";} if (!empty($_POST['postcode'])) { $postcode = test_input($_POST['postcode']); } else { $error .= "- Vul uw postcode in. <br />";} if (!empty($_POST['plaats'])) { $plaats = test_input($_POST['plaats']); } else { $error .= "- Vul uw woonplaats in. <br />";} if (!empty($_POST['land'])) { $land = test_input($_POST['land']);} if (!empty($_POST['email'])) { $email = $_POST['email']; if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email)){ $error .= "- U heeft een ongeldig e-Mail adres ingevuld. <br/>";} } else { $error .= "- Vul uw e-Mail adres in. <br />";} if (!empty($_POST['telefoon'])) { $telefoon = test_input($_POST['telefoon']);} if (!empty($_POST['peradres'])) { $peradres = test_input($_POST['peradres']);} if (!empty($_POST['eerstehond'])) { $eerstehond = test_input($_POST['eerstehond']);} if (!empty($_POST['verderehond'])) { $verderehond = test_input($_POST['verderehond']);} if (!empty($_POST['babypup'])) { $babypup = test_input($_POST['babypup']);} if (!empty($_POST['koppelklas'])) { $koppelklas = test_input($_POST['koppelklas']);} if (!empty($_POST['koppelhond1'])) { $koppelhond1 = test_input($_POST['koppelhond1']);} if (!empty($_POST['koppelhond2'])) { $koppelhond2 = test_input($_POST['koppelhond2']);} if (!empty($_POST['totaal'])) { $totaal = test_input($_POST['totaal']);} if (!empty($_POST['naamjh'])) { $naamjh = test_input($_POST['naamjh']);} if (!empty($_POST['leeftijdjh'])) { $leeftijdjh = test_input($_POST['leeftijdjh']);} if (!empty($_POST['akkoord'])) { $akkoord = $_POST['akkoord']; } else { $error .= "- U moet akkoord gaan met de voorwaarden voordat u het bericht kunt versturen. <br />";} //no errors were set if(empty($error)) { //code to send the email //The form has been submitted, prep a nice thank you message $output = '<center><b>Het Inschrijfformulier is verzonden <br />We zullen de gegevens verwerken <br/><u>Papillon & Phalène Vereniging Nederland</u></b></center>'; //Set the form flag to no display (cheap way!) $flags = 'style="display:none;"'; //Deal with the email $to = 'joke@pp-vn.nl'; $from = $_POST['email']; $subject = 'Inschrijfformulier'; $message = 'From: ' .$initialen .' ' .$eigachternaam . ' <' . $email . '>' ."\n\n"; $message .= 'Ras: ' .$ras ."\n"; $message .= 'Kleur: ' .$kleur ."\n"; $message .= 'Geslacht: ' .$geslacht ."\n"; $message .= 'Naam v/d hond: ' .$naamhond ."\n"; $message .= 'Stamboomnummer: ' .$stamboom ."\n"; $message .= 'Geboortedatum: ' .$geboorte ."\n"; $message .= 'Klasse: ' .$klasse ."\n"; $message .= 'Naam Fokker: ' .$fokker ."\n"; $message .= 'Naam Vaderhond: ' .$vader ."\n"; $message .= 'Naam Moederhond: ' .$moeder ."\n"; $message .= 'Eigenaar: ' .$initialen .' ' . $eigachternaam ."\n"; $message .= 'Mede-eigenaar: ' .$minitialen .' ' .$machternaam ."\n"; $message .= 'Adres: ' .$straat .' ' .$huisnr .' ' .$postcode .' ' .$plaats .' ' .$land ."\n"; $message .= 'Telefoon: ' .$telefoon ."\n"; $message .= 'e-Mail: ' .$email ."\n"; $message .= 'Per Adres: ' .$peradres ."\n"; $message .= 'Inschrijving eerste hond: ' .$eerstehond . "\n"; $message .= 'Andere honden ingeschreven: ' .$verderehond . "\n"; $message .= 'Baby- Puppyklasse: ' .$babypup . "\n"; $message .= 'Koppelklasse: ' .$koppelklas . "\n"; $message .= 'Koppelklasse Hond 1: ' .$koppelhond1 . "\n"; $message .= 'Koppelklasse Hond 2: ' .$koppelhond2 . "\n"; $message .= 'Totaalbedrag: ' .$totaal . "\n"; $message .= 'Naam Juniorhandler: ' .$naamjh . "\n"; $message .= 'Leeftijd Juniorhandler: ' .$leeftijdjh . "\n"; $message .= 'Akkoord: ' .$akkoord ."\n"; $attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name']))); $filename = $_FILES['file']['name']; $boundary =md5(date('r', time())); $headers = "From: fransien@pp-vn.nl"; $headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\""; $message="This is a multi-part message in MIME format. --_1_$boundary Content-Type: multipart/alternative; boundary=\"_2_$boundary\" --_2_$boundary Content-Type: text/plain; charset=\"iso-8859-1\" Content-Transfer-Encoding: 7bit $message --_2_$boundary-- --_1_$boundary Content-Type: application/octet-stream; name=\"$filename\" Content-Transfer-Encoding: base64 Content-Disposition: attachment $attachment --_1_$boundary--"; mail($to, $subject, $message, $headers); mail($from, $subject, $message, $headers); } else { //display errors echo '<center><span class="error"><strong>Uw bericht is niet verstuurd<br/> De volgende fout(en) zijn opgetreden:</strong><br/>' . $error . '<br /><strong><u>Pas op: Bij een foutmelding indien nodig Kampioenstitel opnieuw toevoegen!!</u></strong></span></center>'; } } ?>
  3. I found the issue: $letters = ereg_replace("[^A-Za-z0-9 ]", "", $searched); Thanks everyone.
  4. Hi hopefully someone can help, i'm having a slight panic on a project I'm working on. I've got 90% of this all done but am having a few concerns regarding some special characters. Heres' the situation. I have a database table i need to export to a CSV (so the client can then import into their own system) I've got this working a dream, downloads the file and all that perfectly. Now i have a few fields in this table where we're going to get special characters (double quotes, single quotes etc) just the kind of thing that will bust a CSV from importing (or opening in excel/similar properly). Basically what i could do with knowing is should i just clean the strings of the bad characters? possibly loosing some of the meaning of the data (for instance one field is a message, and this is likely to contain all sorts of characters), or is there something else i can do that will retain the data - i'm thinking the brute force clean could be fine, but would like to know my options. Also could do with a hand with regards to cleaning the string, I've had a look at preg_replace, example here: $fnameClean = preg_replace("/'/", "", $fnameDirty); Really hope this is a simple one guys, thanks in advance.
×
×
  • 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.