Jump to content

jasonc

Members
  • Posts

    860
  • Joined

  • Last visited

Everything posted by jasonc

  1. ALTER TABLE `tablename` CONVERT TO CHARACTER SET utf8 [COLLATE utf8_general_ci] I used this but still the text in the data is not showing on the webpage as that of a new entry that is added via my CMS area.
  2. All tables and databases are set to utf-8. Adding/editing new entries is working ok. The actual data in the database which was added ages ago is still in the old format. Is there a way to convert the previous existing data before I changed to the correct method of storing the data.
  3. Yes my page is html5, but some of the code was outdated. It seems that so far all information that I add as new is being stored as is, no change to the text apart from escaping before being added and when displayed all looks ok and of the scripting text I tried this also shows as html entities in the source code. All good so far. But still there is the issue of all the entries in the database that was incorrectly stored. How would I start to convert it to normal text as it would be if I had entered it as of now. £ instead of the chr(163) which shows on the page as a diamond with question mark in it. and the other unicode characters.
  4. ok all seem ok, apart from the £ sign, i get the diamond with a question mark in it. ❤French style nest of table , oh la la �40❤ it should be ❤French style nest of table , oh la la £40❤ ok what I have done is echod out all the ord() codes... 226 � 157 � 164 � 70 F 114 r 101 e 110 n 99 c 104 h 32 115 s 116 t 121 y 108 l 101 e 32 110 n 101 e 115 s 116 t 32 111 o 102 f 32 116 t 97 a 98 b 108 l 101 e 32 44 , 32 111 o 104 h 32 108 l 97 a 32 108 l 97 a 32 163 � 52 4 48 0 226 � 157 � 164 �
  5. Now the big issue I have is to convert everything back to normal text in the database after I have incorrectly converted most if not all special characters to their hash and other formats.
  6. ah after splitting up the line in to sections I found the error... the missing ) all working now, and I see who this works too. Thank you
  7. Yes both of these are already set and in php.ini file. But no errors are logged
  8. ok I use the following to add the entry as it and escape the text in case it contains something it should not... $query="INSERT INTO `tablename` (`id`, `title`) VALUES ('1','".$mysqli->real_escape_string('<script>alert("1");< /script>')."')"; db_query($mysqli, $query); Then to get it back I use... echo(htmlentities($title, ENT_QUOTES | ENT_IGNORE, "UTF-8"); But I get a blank page, not even any source code... so I change it to this... echo($title); and sure enough the alert box shows up. Am I missing something here ? How do I stop code like this from working as the bad poster expected...
  9. I just entered the text as is in the table using my script. escaping the string first.. ❤French style nest of table , oh la la £40❤ and it shows as this in the database... â¤French style nest of table , oh la la £40⤠But the £ and the heart do not show up even when I set the page as UTF-8 I used echo htmlentities($str, ENT_QUOTES | ENT_IGNORE, "UTF-8"); to output it on the page, but the page is blank still and nothing in the source code. in the script I placed this at the start... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> and the following at the end... </body> </html>
  10. I was just checking the PHP.net site for the htmlentities it seems I may have found out why I was not able to convert/remove the special characters before as I was getting a blank string back. I may have forgotten to use the | ENT_IGNORE part. I am going to find the code I used to test this out. <?php $str = "\x8F!!!"; // Outputs an empty string echo htmlentities($str, ENT_QUOTES, "UTF-8"); // Outputs "!!!" echo htmlentities($str, ENT_QUOTES | ENT_IGNORE, "UTF-8"); ?>
  11. So if I have understood this the htmlentities will convert all special caracters to their ACSII numbers and still show the text as say... <script>...</script> to the viewer but in the source code it shows as the ASCII version.
  12. I currently use MySQLi and $mysqli->real_escape_string($string) to escape the string before adding to the database. So I just add the text as they entered it without altering it in anyway but escape it using $mysqli->real_escape_string($string) Then when grabbing it from the table to display on the webpage I just unescape it using htmlentities($yourContentFromTheDB, ENT_QUOTES, 'UTF-8');
  13. I have been using an outdated method for sometime to store and retrieve records from my database. I am wanting to know the best way to convert or translate, whatever, the text to a format that I store in the database and then what I should be doing to get it back before it is displayed on the webpage. I tried htmlentities and stuff like that but not realy understanding the flags and stuff and not getting it. Please help me or at least guide me to the right commands that I should be using for what. I do not really want someone to do it, just tel me what commands and how to use them. The adding to the database and getting back is something I know.
  14. function checkUsernameIsCleanOfBadWords($string) { $badWords = "["; $badWords.= "ARSE|"; $badWords.= "*******|"; $badWords.= "*****|"; // i $badWords.= "B1TCH|"; // one $badWords.= "BLTCH|"; // L $badWords.= "BOLLOCKS|";// oh oh $badWords.= "BOLL0CKS|";// oh zero $badWords.= "B0LLOCKS|";// zero oh $badWords.= "B0LL0CKS|";// zero zero $badWords.= "****|"; // oh $badWords.= "C0CK|"; // zero $badWords.= "CLIT|"; // L i $badWords.= "CIIT|"; // i i $badWords.= "CILT|"; // i L $badWords.= "CLLT|"; // L L $badWords.= "C11T|"; // one one $badWords.= "CL1T|"; // L one $badWords.= "C1LT|"; // one L $badWords.= "****|"; $badWords.= "dickhead|";// i $badWords.= "dLckhead|";// L $badWords.= "d1ckhead|";// one $badWords.= "fanny|"; $badWords.= "****|"; $badWords.= "gay|"; $badWords.= "lesbian|"; // i $badWords.= "lesbLan|"; // L $badWords.= "lesb1an|"; // one $badWords.= "*****|"; // i $badWords.= "pen1s|"; // one $badWords.= "penls|"; // L $badWords.= "pOOf|"; // oh oh $badWords.= "pO0f|"; // oh zero $badWords.= "p0Of|"; // zero oh $badWords.= "p00f|"; // zero zero $badWords.= "prick|"; // i $badWords.= "pr1ck|"; // one $badWords.= "prLck|"; // L $badWords.= "rape|"; $badWords.= "****|"; // i $badWords.= "sh1t|"; // one $badWords.= "shLt|"; // L $badWords.= "wank]"; if(preg_match(strtolower($badwords), strtolower($string))) { return "bad"; } return "ok"; } if (checkUsernameIsCleanOfBadWords($username) === "bad") { // tell them so. }
  15. the site has been completely redone and it now stores the date and time in this format so to make things easy i wanted to keep the same format throughout, and all the other entries that i have copied over from the old database had the old formated date/time so now none of these entries show up on the site at all because of it. all i want to do is convert them and remove the old formated date field once done.
  16. i have a backup of the DB but wanted to find a quicker way as there are 1000's of entries. and removing them and reverting back to previous would be annoying if i kept having to do it until it was right. once it is correct i would remove the old field.
  17. I have stored my dates like so for years but now need to convert them to the TIME format `orignal_date` format is Y-m-d H:i:s and would like to have all of these converted to unix format and stored in `newdate` can this be done in phpmyadmin ?
  18. ok I have found a RSS feed code and added it to my file, it work stand alone in an .XML file but how do I get the data from MySQL in to it. When I add .XML to my .htaccess file AddType application/x-httpd-php5 .php .htm .html .xml the page fails with an error Parse error: syntax error, unexpected T_STRING on line 1 <?xml version="1.0" encoding="utf-8"?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <title>Your title goes here</title> <description>Your RSS feed description goes here</description> <link>http://www.rssFeedFolder.com/</link> <language>en</language> <copyright>rssFeedFolder.com</copyright> <pubDate>Fri, 07 Dec 2007 21:58:26 CST</pubDate> <lastBuildDate>Fri, 07 Dec 2007 21:58:26 CST</lastBuildDate> <generator>rssFeedFolder.com</generator> <ttl>30</ttl> <atom:link href="http://www.yourdomain.com/yourfeed.xml" rel="self" type="application/rss+xml" /> <image> <title>Your title goes here</title> <url>http://www.rssFeedFolder.com/images/rssFeedFolderLogo.gif</url> <link>http://www.rssFeedFolder.com/</link> <description>your RSS feed description goes here</description> </image> <item> <title>Your first feed file goes here</title> <description>A brief description of the file goes here</description> <link>http://www.yourdomain.com/rssfeedfolder/file1.html</link> <guid isPermaLink="true">http://www.yourdomain.com/rssfeedfolder/file1.html</guid> <pubDate>Tue, 04 Dec 2007 09:19:42 CST</pubDate> <source url="http://www.rssFeedFolder.com/">rssFeedFolder.com</source> </item> <item> <title>Your second feed file goes here</title> <description>A brief description of the file goes here</description> <link>http://www.yourdomain.com/rssfeedfolder/file2.html</link> <guid isPermaLink="true">http://www.yourdomain.com/rssfeedfolder/file1.html</guid> <pubDate>Web, 05 Dec 2007 10:23:10 CST</pubDate> <source url="http://www.rssFeedFolder.com/">rssFeedFolder.com</source> </item> </channel> </rss>
  19. I have tried sitemap.org and a few others but have not found anything that will give the results I am after. I have a blog site that has a URL and a Description for the URL and wish to have the description show as the anchor text which is linked to the URL, all data is taken from MySQL. Does anyone have a code that will generate something like this ?
  20. I tried the following SELECT * FROM `links` WHERE `link` IN ( SELECT `link` FROM `links` GROUP BY `link` HAVING count(*) > 1 ) ORDER BY `id` DESC But it caused the server error 500, so I entered it in phpmyadmin and got no results.
  21. I have got this far and would like to find out how I change the query so it shows all duplicates instead of just one of them. SELECT count(*), `id`, `linklocation`, `link` FROM `links` WHERE `link` != '' GROUP BY `link` having count(*) > 1
  22. validate meaning, that the original format used is not trying to use, 31-02-2012 or other invalid dates i.e. 31-**-**** when the month only has 30 days
  23. my fault I had the wrong string name that was being checked. how would I validate that the date entered was a valid date before it is converted?
  24. Using this method I get errors every now and then, not always.. Warning: mktime() expects parameter 5 to be long actual code i am using. $date = $_POST['makeLiveTime']; list($day, $month, $year) = explode('-', $date); $uploadTime = mktime(0, 0, 0, $month, $day, $year); echo($uploadTime); I have this placed just after the field just for testing it out. The field is not empty, it has todays date entered as default.
  25. Can anyone please tell me how I convert DD-MM-YYY (text) to TIME (unix) thought I'd say that I have this line at the top of all my pages, just in case it means a different code. date_default_timezone_set('Europe/London'); //### Set the default timezone
×
×
  • 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.