#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Location
    Denmark
    Posts
    53
    Rep Power
    15
    I've been here before (some weeks ago) with the same problem, but it's still not working. I have now added some more information.
    I'm trying to avoid more than double linespaces, but the array_walk function does not seem to work. Why? (Actually there is more than three pieces of text.)

    <?PHP
    require("common.php");
    require("db_vari.php");

    //something here

    IF($update){
    $t_texts = array($text1, $text2, $text3);
    array_walk( $t_texts, 'spaces' );

    MYSQL_CONNECT($host,$user,$password);
    mysql_select_db($database);
    $query = MYSQL_QUERY("UPDATE ugen SET text1 = '$text1', text2 = '$text2', text3 = '$text3' WHERE id='$id' ");
    }
    ?>

    <?PHP
    //common.php

    FUNCTION spaces(&$str){
    $str = ereg_replace("[nr]{3,}","nn",$str);
    }
    ?>
    Of course, I could do something like:
    ombrud($text1);
    ombrud($text2);
    ombrud($text3);
    ... and so on, but array_walk would make it easier!
    Thanks
    Ole, Denmark
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    You're inserting the values of $text1, $text2, $text3 into the the db, but you haven't modified them with the function. You've modified the array! You need to insert the array values:

    $query = MYSQL_QUERY("UPDATE ugen SET text1 = '$t_texts[0]', text2 = '$t_texts[1]', text3 = '$t_texts[2]' WHERE id='$id' ");
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Location
    Denmark
    Posts
    53
    Rep Power
    15
    Of course!!!
    Thanks!

Similar Threads

  1. UTF-8 problem in 4.1.1a
    By mehran20 in forum MySQL Help
    Replies: 1
    Last Post: February 8th, 2004, 02:21 PM
  2. fread problem: doesn t compile php code
    By ghorghor2002 in forum PHP Development
    Replies: 2
    Last Post: February 3rd, 2004, 05:25 AM
  3. Wierd problem inserting data with VB6
    By gregquinn in forum MySQL Help
    Replies: 5
    Last Post: February 2nd, 2004, 07:37 AM
  4. WinNT4 problem
    By sandipguha in forum Windows Help
    Replies: 0
    Last Post: January 27th, 2004, 02:06 AM
  5. Session Variable problem :(
    By modesty in forum PHP Development
    Replies: 1
    Last Post: January 15th, 2004, 04:00 AM

IMN logo majestic logo threadwatch logo seochat tools logo