I am trying to return each description the user has posted for each language the site supports that is active.
I have the data posting into the database ok but there is a function I need, for validating, if the user has disabled there javascript on there browser.
This piece of code checks which languages are active on the site.
/* Detect active languages on the site. */
$qLang = mysql_query("SELECT * FROM languages WHERE `is_active`='Y'") or die("ERROR: ".mysql_error());
while($languages = mysql_fetch_array($qLang)){
$Lang = array($languages['lang_code'] => $languages['lang_code']);
$lang = $Lang[$languages['lang_code']];
$description[$lang] = mysql_real_escape_string($_POST['description_'.$lang.'']);
$convert = array("\r\n", "\n", "\r", " "); /* Remove bad code to a friendly text */
$replace = " "; /* Don't replace anything just leave it blank to remove bad content. */
$description[$lang] = str_replace($convert, $replace, $_POST['description_'.$lang.'']); /* Processes \r\n's first so they aren't converted twice. */
$description[$lang] = strip_tags($description[$lang]," "); /* Removes any HTML Tags. */
if(!empty($description[$lang])){ $addDescription[$lang] = "description_$lang=$description[$lang]&"; } /* If user input for description is not empty then description in that language will be added. */
}
The top part works for the other functions in my script, but this bottom piece of code does not.
foreach($Lang as $languages['lang_code'] => $description[$lang]){
$addDescription = $addDescription[$lang];
}
I only get 1 of them returning whether or not the user has entered a description for another language.
I looks like this when it is echoed: description_en=description text goes here&
I need it to be able to echo more than one for each language the site has provided like so: description_en=description text goes here&description_fr=texte de la description va ici&
If any one can help me figure this out I would mostly appreciate it.
my old precision t3600 that was my main rig till I got my current build
will post pics of the server soon but here's the drives: (Intel DCS-4500 960gb enterprise grade MLC SATA SSD for boot drive + Ironwolf Pro 14TB)
and my main rig does a backup to this every wed w luckybackup rsync/rclone frontend. mounted locally n added to fstab on the main rig and this t3600 does a nice job as being the backup rig n everything's synced.
Wow you are right, I never even noticed this until you said it! (870E Aorus Master)
Before testing this card I had a TP-Link tx401 10GbE PCIe card in that slot (now using XikeStor 310 Thunderbolt to Ethernet adapter).
Recent Achievements
DrWankel earned a badge First Post
DrWankel earned a badge Reacting Well
Supreme Spray LV earned a badge Week One Done
Genuinetonerink- Dubai earned a badge One Month Later
Genuinetonerink- Dubai earned a badge Week One Done
Question
seb86
I am trying to return each description the user has posted for each language the site supports that is active.
I have the data posting into the database ok but there is a function I need, for validating, if the user has disabled there javascript on there browser.
This piece of code checks which languages are active on the site.
/* Detect active languages on the site. */ $qLang = mysql_query("SELECT * FROM languages WHERE `is_active`='Y'") or die("ERROR: ".mysql_error()); while($languages = mysql_fetch_array($qLang)){ $Lang = array($languages['lang_code'] => $languages['lang_code']); $lang = $Lang[$languages['lang_code']]; $description[$lang] = mysql_real_escape_string($_POST['description_'.$lang.'']); $convert = array("\r\n", "\n", "\r", " "); /* Remove bad code to a friendly text */ $replace = " "; /* Don't replace anything just leave it blank to remove bad content. */ $description[$lang] = str_replace($convert, $replace, $_POST['description_'.$lang.'']); /* Processes \r\n's first so they aren't converted twice. */ $description[$lang] = strip_tags($description[$lang]," "); /* Removes any HTML Tags. */ if(!empty($description[$lang])){ $addDescription[$lang] = "description_$lang=$description[$lang]&"; } /* If user input for description is not empty then description in that language will be added. */ }The top part works for the other functions in my script, but this bottom piece of code does not.
foreach($Lang as $languages['lang_code'] => $description[$lang]){ $addDescription = $addDescription[$lang]; }I only get 1 of them returning whether or not the user has entered a description for another language.
I looks like this when it is echoed: description_en=description text goes here&
I need it to be able to echo more than one for each language the site has provided like so: description_en=description text goes here&description_fr=texte de la description va ici&
If any one can help me figure this out I would mostly appreciate it.
Thank you.
Link to comment
https://www.neowin.net/forum/topic/925504-foreach-language-add-value/Share on other sites
5 answers to this question
Recommended Posts