Jump to content

schilly

Members
  • Posts

    870
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.damnsemicolon.com

Profile Information

  • Gender
    Male
  • Location
    Canada

schilly's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. I might have got it through trial and error: <?php function convert_smart_quotes($string){ $search = array(chr(145), chr(146), chr(147), chr(148), chr(151), "\x80", "\x85", "\xA3", "\x96", "\xB5"); $replace = array("'", "'", '"', '"', '-', '…', "\n", "£", "-", "µ"); return str_replace($search, $replace, $string); } ?> Just a few outlier characters I needed to track down and convert. Hopefully I don't run into more in the future.
  2. Ya I think I'm pretty screwed here. I tried the MySQL binary cast UTF8 conversion method and it didn't work. The single quote is all messed, breaking xml validity Sample after converison: There shouldn't be too many bad character types so I figure if I get a list of them all and do a find/replace of their latin1 counterpart it should work.
  3. Well in latin1 there are those symbols but in UTF8 they are a smart quote I think. Because it's a 2-byte character, latin1 shows it as two characters instead of one.
  4. Yup that was the search replace code above: This: <?php function convert_smart_quotes($string){ $search = array(chr(145), chr(146), chr(147), chr(148), chr(151)); $replace = array("'", "'", '"', '"', '-'); return str_replace($search, $replace, $string); } ?> and <?php function sanitizeString($string = null){ if(is_null($string)) return false; //-> Replace all of those weird MS Word quotes and other high characters $badwordchars=array( "\xe2\x80\x98", // left single quote "\xe2\x80\x99", // right single quote "\xe2\x80\x9c", // left double quote "\xe2\x80\x9d", // right double quote "\xe2\x80\x94", // em dash "\xe2\x80\xa6" // elipses ); $fixedwordchars=array( "'", "'", '"', '"', '—', '...' ); return str_replace($badwordchars,$fixedwordchars, $string); } ?> I still have some weird chars showing up as â I'm not sure if this is because it's a UTF8 character being submitted through our form then being stored as latin1. It looks like most of the issues are with smart quotes and mdash. The text shows up fine in the web as UTF8 but when I generate an XML of it, it completely craps out.
  5. I've got some text in a longtext mysql field (latin1) that contains some smart quotes which are causing problems using this data to generate an xml file. the smart quotes break the xml structure. I've tried a bunch of different conversion methods in PHP and MySQL with no luck. Does anyone have a concrete method for doing this? I've tried search/replace with $search = array(chr(145), chr(146), chr(147), chr(148), chr(151)); Changing longtext to binary then converting to UTF8 then converting back to longtext. Using mb_convert_encoding(). Nothing seems to work. Character encodings still cause a lot of confusion for me. Any help is appreciated. Thanks.
  6. thanks. it's the db connection timing out because the media compression can be anywhere from 3s - 20mins. i ended up reconnecting to the db after every compression. i'm just not sure if that's the best way to do it or not. i guess another option is using some kind of timer class and checking the total time the compression took to decide whether or not to reconnect.
  7. I have a cron running some media compression (FFmpeg, GD stuff). The problem is that some media takes a long time to compress and by the time my compression is done, my mysql connection has timed out so I can't update the media record. What's the best way to get around this? My current process: -query db for media needed for compression -loop through results -compress media -update db record to compressed and each compression interactive_timeout and wait_timeout are set to 60. I tried to do ini_set('mysql.connect_timeout','300'); but it didn't help. Should I get my initial results then close the connection then reopen each time a compression completes to update the record? Thanks.
  8. ah genius!!! I've never used the HAVING clause before. Never quite knew how it was used.
  9. Here is one query I have that works: Now I want to select vendors with <= 5 coupons left. I'm trying this: but I keep getting an error: "invalid use of group function". What's the issue here or is there a better way to do this? I tried WHERE coupons_left <= 5 and that didn't work either.
  10. Thanks Denno. Ya that wouldn't be too hard. I got oiplayer working with fallback so giving it a go for now.
  11. Anyone know a good one? Preferably jquery compatible. I need HTML5 playback for mp3 (Safari/Chrome) and Flash fallback for everything else. I'm trying OIPlayer (http://www.openbeelden.nl/oiplayer/) and can't seem to figure out the fallback and their documentation is brutal. I looked at jPlayer (http://www.happyworm.com/jquery/jplayer/) but it was pretty clunky and not very module for what I needed.
  12. if you do ini_set('post_max_size','10M'); or php_value post_max_size 20M in htaccess then run phpinfo() does it show the changes? ie. ini_set('post_max_size','10M'); phpinfo(); If you can't see the changes in phpinfo you may be at the mercy of your provider. I have had issues with ini_set not working but htaccess has always worked for me.
  13. do phpinfo() on the remote server and look at the upload_max_filesize and post_max_size vars. you may be able to up these via ini_set('upload_max_filesize','10M'); etc or else use htaccess to do it.
  14. $_FILES['uploaded']['type'] is the mime type of the uploaded file. Check this against 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png'. If it doesn't match one of those reject it.
×
×
  • 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.