returning a contatenated string containing an array value properly ( 4 Views )

no kitty!
  1. hey,

    i have this function, but I cant get it to return the string properly:

    PHP Code:

      function addLink($linkData){
    //trim any white space off of the link info being entered
    $linkData['name'] = trim($linkData['name']);
    $linkData['url'] = trim($linkData['url']);
    $linkData['linkInfo'] = trim($linkData['linkInfo']);
    //escape out any special characters
    $linkData['name'] = addslashes($linkData['name']);
    $linkData['url'] = addslashes($linkData['url']);
    $linkData['linkInfo'] = addslashes($linkData['linkInfo']);


    //create temp variables for the query
    $n = $linkData['name'];
    $u = $linkData['url'];
    $l = $linkData['linkInfo'];
    $query = "INSERT INTO links (name, url, linkInfo) VALUES ('".$n."', '".$u."', '".$l."')";

    $result = mysql_query($query);

    if (!
    $result ){
      return
    'Error adding news';
    }else{
      
    $success = 'New link'. $u . ' added successfully.';
      return
    $success;
      
    };

    }


    I thought the problem might be that the return statement wont do any operations or somethign so i created a varibale to send back, but it doesnt work..

    (emrah, French Polynesia)

  2. What error are you getting?

    (gül, Djibouti)

  3. Well, I'm using this script with flash remoting, so what I am getting back is jsut the string, minus the variable...so i am getting back "New link added succssfully". I'll check the script in the browser now..

    (hasan, Syrian Arab Republic)

  4. ok here we go. if i change up the script and add add this on the end of it:


    $l = new Links();
    $ld = array (
    "name"=>"theLink",
    "url"=>"http://wwww.blah.com",
    "linkInfo"=>"a new link"
    );
    $l->addLink($ld);


    and view this in a browser it works fine...so im guessing something is wrong on teh flash remoting side of it.

    (gozde, Lithuania)

  5. Where's the $linkData[] coming from?

    (nazlı, Norfolk Island)

  6. $linkData is an object ebing sent from flash. Everythign else is working right, i can see the data beign inserted into the database correctly.

    (mesut, Cuba)

  7. man why cant i spell "being"

    (gülşen, Panama)

  8. Where do you connect to mysql? Btw, there is an edit button, no need to double post.

    (seckin, Cyprus)

  9. i connect to mysql in the class constructor.

    (gökhan, British Indian Ocean Territory)



Related Topics ... (or search in 1.720.883 topics !)

problem with returning a string from an array (5)
returning smallest value (string) in a bst (10)
returning smallest value (string) in a bst (10)
returning a 2d array (5)
php: array[string] to array[int] (2)
returning an array from a function.... (4)
returning duplicates from an array (1)
returning array values? (9)
returning an array from a function (5)




copyright © 2007-2031 Pfodere.COM ( 5 Pfoyihuee Online )

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 
0.6355