xam Posted June 30, 2006 Share Posted June 30, 2006 Hello,I use below code to change my language files.[code]<?phpsession_start();function addslashes2 ($string) {if (!get_magic_quotes_gpc()) return str_replace('\'','\\\'',$string);else return str_replace('\'','\\\'',stripslashes($string));}if (isset($_POST['new_lang'])): $current_lang = $_SESSION['lang']; $new_lang_file_content = array(); foreach ($_POST['new_lang'] as $key => $value): $new_lang_file_content[] = '$lang[\''.$key.'\'] = \''. addslashes2($value) .'\';'; endforeach; $handler = fopen('lang.inc','w'); fwrite($handler,"<?php\n".implode("\n",$new_lang_file_content)."\n?>"); fclose($handler); Die ('Language file has been updated. Click <a href=javascript:history.go(-1)> here</a> to go back.');endif;include_once 'lang.inc';echo $lang['category'];?> <form method="post"><input name="new_lang[category]" type="text" value="<?=$lang['category'];?>"><input type="submit"></form>[/code]It works fine but I need some help about; When I insert a text with php string into input area, e.g. following text: You have been redirected to main page '.$MAIN['mainpage'].'It save it as a text I want to save it as php string, take a look at below example thats what I want..e.g.:I wrote: You have been redirected to main page '.$MAIN['mainpage'].'It has been saved as (lang.inc): [code]<?php$lang['category'] = 'You have been redirected to main page \'.$MAIN[\'mainpage\'].\' ';?>[/code]I want:[code]<?php$lang['category'] = 'You have been redirected to main page '.$MAIN['mainpage'].' ';?>[/code]without slashes.. Quote Link to comment https://forums.phpfreaks.com/topic/13338-need-help/ Share on other sites More sharing options...
Orio Posted June 30, 2006 Share Posted June 30, 2006 [url=http://www.php.net/manual/en/function.stripslashes.php]stripslashes()[/url]Orio. Quote Link to comment https://forums.phpfreaks.com/topic/13338-need-help/#findComment-51439 Share on other sites More sharing options...
xam Posted June 30, 2006 Author Share Posted June 30, 2006 [quote author=Orio link=topic=99045.msg389894#msg389894 date=1151701226][url=http://www.php.net/manual/en/function.stripslashes.php]stripslashes()[/url]Orio.[/quote]ok done, thx Quote Link to comment https://forums.phpfreaks.com/topic/13338-need-help/#findComment-51442 Share on other sites More sharing options...
xam Posted July 1, 2006 Author Share Posted July 1, 2006 well, I have another question / I need another help..An example language file content:language.php[code]$lang['Copyright'] = 'Copyright '.$Settings['url'].' All Rights Reserved.';[/code]An example modify script for language file:[code]include_once ('language.php');echo '<input onClick="highlight(this);" size="200" type="text" name="new_lang[Copyright]" value=" '.$lang['Copyright'].' ">'[/code]It shows:[code]<input onClick="highlight(this);" size="200" type="text" name="new_lang[Copyright]" value="Copyright All Rights Reserved.">[/code]I want:[code]<input onClick="highlight(this);" size="200" type="text" name="new_lang[Copyright]" value="Copyright '.$lang['Copyright'].' All Rights Reserved.">[/code]$settings[xxxx] values should be write as text content..I use htmlspecialchars but It wont help ... Quote Link to comment https://forums.phpfreaks.com/topic/13338-need-help/#findComment-51648 Share on other sites More sharing options...
xam Posted July 1, 2006 Author Share Posted July 1, 2006 I need urgent help ??? Quote Link to comment https://forums.phpfreaks.com/topic/13338-need-help/#findComment-51693 Share on other sites More sharing options...
Barand Posted July 1, 2006 Share Posted July 1, 2006 Do you mean this[code=php:0]$lang['Copyright'] = 'Copyright All Rights Reserved.';echo $lang['Copyright']; //--> Copyright All Rights Reserved.echo '<br>'; // text in single quotesecho '$lang[\'Copyright\']'; //--> $lang['Copyright'];[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13338-need-help/#findComment-51697 Share on other sites More sharing options...
eunicewt Posted July 1, 2006 Share Posted July 1, 2006 Hi, I have this error and I know it is an empty string but I cannot find where is my mistake. Anyone can tell me where is my mistake. My coding // update asset $sql = "UPDATE Assets SET financetag='" . $assettype_id . $assettag . "',assettype='" . $assettype . "',assetsupplier='" . $assetsupplier . "',assetmodel='" . $assetmodel . "',assetserial='" . $assetserial . "',assetprice='" . $assetprice . "',description='" . $assetdescription . "',make='" . $assetmake . "',year='" . $assetyear . "',rego='" . $assetrego . "',notes='" . $notes . "' WHERE id=" . $key . ";"; if ($result = doSql($sql)) {An error occurred while attempting to update the database. Please contact the webmaster. This is action attempted:: INSERT INTO Assets (financetag,assettype,assetsupplier,assetmodel,assetserial,assetprice,description,make,year,rego,status,notes,added_by, date_added) VALUES ('1691751','sdsd','16','','','0','','','2006','','','', '1', '2006-07-01 15:09:11');Duplicate entry '' for key 2Eunice Quote Link to comment https://forums.phpfreaks.com/topic/13338-need-help/#findComment-51702 Share on other sites More sharing options...
xam Posted July 1, 2006 Author Share Posted July 1, 2006 [quote author=Barand link=topic=99045.msg390167#msg390167 date=1151765522]Do you mean this[code=php:0]$lang['Copyright'] = 'Copyright All Rights Reserved.';echo $lang['Copyright']; //--> Copyright All Rights Reserved.echo '<br>'; // text in single quotesecho '$lang[\'Copyright\']'; //--> $lang['Copyright'];[/code][/quote]no, I mean:$lang['leecher'] = 'This page is only avaliable from the '.$MAIN['url'].' site.';The code:<input onClick="highlight(this);" size="200" type="text" name="new_lang[leecher]" value="'.$lang['leecher'].'">It shows: <input onClick="highlight(this);" size="200" type="text" name="new_lang[leecher]" value="This page is only avaliable from the site.">It should be:<input onClick="highlight(this);" size="200" type="text" name="new_lang[leecher]" value="This page is only avaliable from the '.$MAIN['url'].' site.">It must show '.$MAIN['url'].' string as text not a php value/string.. Quote Link to comment https://forums.phpfreaks.com/topic/13338-need-help/#findComment-51704 Share on other sites More sharing options...
xam Posted July 2, 2006 Author Share Posted July 2, 2006 Does anyone help me about that my problem ???? ??? Quote Link to comment https://forums.phpfreaks.com/topic/13338-need-help/#findComment-51943 Share on other sites More sharing options...
Barand Posted July 2, 2006 Share Posted July 2, 2006 [quote author=Barand link=topic=99045.msg390167#msg390167 date=1151765522]Do you mean this[code=php:0]$lang['Copyright'] = 'Copyright All Rights Reserved.';echo $lang['Copyright']; //--> Copyright All Rights Reserved.echo '<br>'; // text in single quotesecho '$lang[\'Copyright\']'; //--> $lang['Copyright'];[/code][/quote]I already have Quote Link to comment https://forums.phpfreaks.com/topic/13338-need-help/#findComment-51945 Share on other sites More sharing options...
xam Posted July 3, 2006 Author Share Posted July 3, 2006 [quote author=Barand link=topic=99045.msg390437#msg390437 date=1151836056][quote author=Barand link=topic=99045.msg390167#msg390167 date=1151765522]Do you mean this[code=php:0]$lang['Copyright'] = 'Copyright All Rights Reserved.';echo $lang['Copyright']; //--> Copyright All Rights Reserved.echo '<br>'; // text in single quotesecho '$lang[\'Copyright\']'; //--> $lang['Copyright'];[/code][/quote]I already have[/quote]I mean:lang-en.php[code=php:0]$lang['protected2'] = 'Copyright '.$MAIN['url'].' All Rights Reserved.';[/code]Form (to change/edit language text in adminpanel):[code=php:0]echo '<input onClick="highlight(this);" size="200" type="text" name="new_lang[protected2]" value="'.$lang['protected2'].'"><br>';[/code]Output (to input value):<input onClick="highlight(this);" size="200" type="text" name="new_lang[protected2]" value="Copyright All Rights Reserved.">I want:Output (to input value):<input onClick="highlight(this);" size="200" type="text" name="new_lang[protected2]" value="Copyright '.$MAIN['url'].' All Rights Reserved."> Quote Link to comment https://forums.phpfreaks.com/topic/13338-need-help/#findComment-52449 Share on other sites More sharing options...
Barand Posted July 3, 2006 Share Posted July 3, 2006 http://uk.php.net/manual/en/language.types.string.php Quote Link to comment https://forums.phpfreaks.com/topic/13338-need-help/#findComment-52476 Share on other sites More sharing options...
xam Posted July 3, 2006 Author Share Posted July 3, 2006 [quote author=Barand link=topic=99045.msg391003#msg391003 date=1151940373]http://uk.php.net/manual/en/language.types.string.php[/quote]Its hard for me ;( my english not enought for this tutorial thats why I wrote here.... ??? Quote Link to comment https://forums.phpfreaks.com/topic/13338-need-help/#findComment-52483 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.