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.
Normally, I admit when a title is clickbait (unfortunately, it's become somewhat necessary in AI-dominated news sections today), but in this case, all supported versions is implied and doesn't need to be spelled out in the title. Of course, I'm covering a Patch Tuesday update but that is only available to supported Windows SKUs. All our coverage relates to supported Windows software and SKUs only unless we expressly state that it's "unsupported", "unofficial", or "third-party". I'm sorry, but supported/official SKUs don't need to be spelled out as such in every Neowin headline.
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