Jump to content

dreamwest

Members
  • Posts

    1,223
  • Joined

  • Last visited

    Never

Posts posted by dreamwest

  1. Is there a way i can amend a field to simply add more data to the end of whats already there

     

    d_id  corpus

     

    1    (3, 17)|(9, 17)

    2    (4, 6)

    3    (89, 97)

     

    mysql_query("update `dic` set `corpus`='|(2, 12)' where `d_id`='3'"); //amend field with this query

     

    so after update row 3 will now be  (89, 97)|(2, 12)

     

  2. Is it possible to get substr to end on a word boundry instead of halfway through a word?

     

     

    $txt = "The cat goes splat on my bumper mat";
    echo substr($txt, 0, 120); //this can be around 12 chars so doesnt need to be exactly 12 chars
    

     

     

  3. Is it possible to have both background-color and background image.

     

    <div align='center' style='border:1px solid #eee;width:850px;height:500px;background-color:#000000;background: url(/17298356341299066112.jpg) no-repeat left top;'>Some white text here</div>

     

  4. So i have a page cached with php pragma headers. How can i clear the cache when someone sets a cookie:

     

    <script>
    function set_cookie(object, value) { 
    var expireDate  = new Date()
    var expstring   = expireDate.setDate(expireDate.getDate() + 500)
    document.cookie = object+'='+value+'; expires='+expireDate.toGMTString()+'; path=/';
    
    window.location.reload()  
    }
    </script>
    
    <a  onclick="set_cookie('list', '1');"  href="javascript:void('0');">Set cookie and clear cache</a>

  5. Whats the best way to remove <script> and <style> tags including the content between them?

     

     

    $txt = "html stuff <script>javascript stuff</script> html stuff <style>.co{color:red}</style>html";
    
    if(preg_match('~<script(.*?)</script>~is', $txt)){
    
    //remove <script> content from $txt
    
    }
    
    

     

  6. $productid has no value aka its empty

     

    You should use to prevent errors

     

    if($productid){
    
    while($row = mysql_fetch_array($productid)) {
    		echo $row['product_id']; //NOW GET AN ERROR Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in XXXXXX/comments.php on line 18
    	} 
    }else{
    
    echo  'No data';  //remove after testing
    }

     

     

  7. Is there a way i can set IN() to return rows in order aka from  left to right

     

    Table:

     

    id  name

     

    2      amazing

    12    video

    15    funny

     

    example query:

    SELECT id FROM table WHERE name IN('funny','amazing','video')

     

    Which out puts:

     

    2

    12

    15

     

    What i need the output to be is

     

    15

    2

    12

  8. Im trying to get this imagemagick to work

     

    echo shell_exec("/usr/bin/convert -version");

     

    outputs:

    Version: ImageMagick 6.4.8 2010-09-03 Q16 OpenMP http://www.imagemagick.org Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC

     

    This doesnt work (no image is output) What am i missing here?

    shell_exec("/usr/bin/convert -compress JPEG -quality 100 -sampling-factor 1x1 -enhance a.jpg b.jpg ");
    echo "<img src='b.jpg'>";

  9. I have a video database that has 500 million rows, and get matches in < 0.0006 secs purely because it inverted. Boolean was slowing down to 2 secs even with full indexing.

     

    The reason the inversion works faster is that your only searching the dictionary and already have the count total there, that way you can also avoid counting groups of data which save another second or so.

     

    Other than that php can compress your frontend data by up to 70% so a 40KB page will be around 6KB by the time you serve it then you can flush it @ini_set('implicit_flush',1);  , this helps with slow user connection speeds and larger docs

  10. Whats the array function to merge two or more similar patterns in a single array.

     

    $a = array('red','pink','red','green','blue');

     

    Basically i need to combine "red" so the output will be

     

    red, pink, green, blue

  11. OK, because REGEX is doing the actual search i dont need to replace IN() because i can limit the amount to 30 items at a time. Its pretty fast on 50 Million rows it returning a set in 0.0006 secs

     

    This is equivilant to "some words" in boolean

    select id from video WHERE word_id REGEXP '[[:<:]]567,765[[:>:]]' = 1 limit 0, 30

     

    This is equivilant to find rows that contain at least one of the two words in boolean

    select id from video WHERE word_id REGEXP '[[:<:]](567|765)[[:>:]]' = 1 limit 0, 30

     

    The final one i need is '+some +words' boolean equivilant aka match both numbers within the string, any suggestions?

     

  12. So i have i simple string of numbers but want to match both numbers, "|" wont work because it matches either number

     

    $string = "567 6776 6656 77";

     

    How can i match both number "567" and "77" within the $string?

     

     

     

×
×
  • 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.