returning a contatenated string containing an array value properly ( 4 Views )
-
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)
What error are you getting?
(gül, Djibouti)
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)
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)
Where's the $linkData[] coming from?
(nazlı, Norfolk Island)
$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)
man why cant i spell "being"
(gülşen, Panama)
Where do you connect to mysql? Btw, there is an edit button, no need to double post.
(seckin, Cyprus)
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 )
|