T-Hawk Posted September 2, 2007 Share Posted September 2, 2007 Hey all I'm working on a site for my brothers friend and it has a commentary system. The commentaries get added by calling a Javascript which updates the current page and then call a PHP script to store the comment in a mySQL database. My problem is at if the user uses any kind of special chars like the danish chars: æ, ø and å then the PHP script will just die on them. It will store the message until the chars and then stop. I've tried running an escape () in the javascript on the txt i'm sending, and i've tried using CONVERT ('string' USING utf8) in the SQL query. The entire site is encoded in UTF-8, and so is the database but the user might type in ISO-8859-1 (?). Somewhere else on the site i have a fileupload, here the page calls the upload script directly and it has no problems storing special chars in the database, so i'm thinking the problem might be a combination of the Javascript and PHP. I'm hoping someone has an idea to what might be wrong. The page can be seen on: http://t-hawk.com/david User / pass: test / test And yes the site is in danish, but the problem is in the section labelled: "Gæstebog", and if one clicks on one of the posts on the frontpage. Thanks in advance Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted September 2, 2007 Share Posted September 2, 2007 Why not just make the entry into the database a string type? Quote Link to comment Share on other sites More sharing options...
T-Hawk Posted September 2, 2007 Author Share Posted September 2, 2007 I'm going to have to get that spelled out a bit more. What do you mean a string type? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted September 2, 2007 Share Posted September 2, 2007 I assume you do this: <form action='<?php $_SERVER['PHP_SELF']; ?>' method='post'> <input type='textarea' size='100' name='input' /> </form> <?php mysql_connect("localhost", "ken", "blah"); mysql_select_db("test"); $input = $_POST['input']; $query = "INSERT INTO table (input) VALUES ('$input')"; mysql_query($query) or die(mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
T-Hawk Posted September 2, 2007 Author Share Posted September 2, 2007 As i said i use a Javascript to open a XMLRequest object and send the txt to a PHP script, that then does: <?PHP $query = "INSERT INTO `guestbook` (`name`, `mail`, `time`, `text`) VALUES (CONVERT ('" .mysql_escape_string ($_REQUEST['name']) ."' USING utf8), CONVERT ('" .mysql_escape_string ($_REQUEST['mail']) ."' USING utf8), '" .$time ."', CONVERT ('" .$_REQUEST['txt'] ."' USING utf8));"; $query = mysql_query ($query); dbErr (); ?> Quote Link to comment Share on other sites More sharing options...
T-Hawk Posted September 2, 2007 Author Share Posted September 2, 2007 Anybody? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.