September 25, 201016 yr this is two line of my php script $url = "p".$page.".html"; if (file_exists($url)) { now i want to replace the $url="p" to $url="x" how can i do it?
September 25, 201016 yr you can use string functions to cut it away, if you need multibyte character support (utf-8 etc) then the following wont work for php5... $page = 'meh'; echo $url = "p".$page.".html"; $url[0] = 'x'; echo $url; using {} for sting access is depreciated annoyingly..
September 26, 201016 yr Author actually, below the original code.by this script i can edit a page name p.html. but i want to edit more pages like x.html,f.html,v.html, etc etc... it is not possible every time change the script manually,i s there any dynamic way that i can change $url = "p".$page.".html"; if (file_exists($url)) { to $url = "x".$page.".html"; if (file_exists($url)) { or $url = "y".$page.".html"; if (file_exists($url)) { or $url = "v".$page.".html"; if (file_exists($url)) { i am sorry for my poor english. can any one help regarding this issue?
September 26, 201016 yr delete the p and put an x there What is it's purpose? How are you using the script? Where do the letters p and x come from? You've used variable $page, could you not do something similar or create a function?
September 26, 201016 yr Author delete the p and put an x there What is it's purpose? How are you using the script? Where do the letters p and x come from? You've used variable $page, could you not do something similar or create a function? i am new in php. and the purpose of the script is to edit .html file. suppose there i 24/25 html file in my site. and i want to edit these html file by this script.so it is not easy to put/change the html file name evrytime.. here is the script <?php function br2nl($str) { return preg_replace('=<br */?>=i', "", $str); } $action=$_POST['action']; $textarea=$_POST['textarea']; if($_GET['p']){ $page=$_GET['p']; } // Assume your text pages are called, p1.db or p2.db, etc. $url = "p".$page.".html"; if (file_exists($url)) { // do nothing } else { $url = "p0.html"; } // where to go back to after the edit ... $return="edit.php?p=$edit"; // Get page $data = implode("", file($url)); if($action=="save"){ $newtext=stripslashes($textarea); $newtext = str_replace("<?", "", $newtext); $newtext = str_replace("?>", "", $newtext); $newtext = nl2br($newtext); //echo "page: $url<br><br>\n"; //echo $newtext; $fh = fopen($url, 'w') or die("can't open file"); fwrite($fh, $newtext); fclose($fh); header ("location:edit.php?p=$page"); } else{ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>abeer cms</title> <script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script> <script type="text/javascript"> tinyMCE.init({ // General options mode : "textareas", theme : "advanced", plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager", // Theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, // Example content CSS (should be your site CSS) content_css : "css/example.css", // Drop lists for link/image/media/template dialogs template_external_list_url : "js/template_list.js", external_link_list_url : "js/link_list.js", external_image_list_url : "js/image_list.js", media_external_list_url : "js/media_list.js", // Replace values for the template plugin template_replace_values : { username : "Some User", staffid : "991234" } }); </script> <style> body,html{ margin:0px auto; width:700px; text-align:center; } #content{ margin:0px auto; width:700px; } #middle h1 { color: transparent; font-family:georgia; font-size:12pt; margin:0; color: #dF9100; padding:10px 0px 15px 0px; text-align:left; } </style> </head> <body> <div id='content'> <? $ta=br2nl($data); echo" <a href='$return'><-- Return to Page</a><br /><br /> Make Changes and click \"Save Changes\" at the very bottom ...<br /> <form action='edit.php' method='post'> <input type='hidden' name='action' value='save'> <input type='hidden' name='p' value='$page'> <input type='hidden' name='n' value='$n'> <textarea name='textarea' rows='25' cols='80'>$ta</textarea> <br /> <input type='submit' name='submit' value='Save Changes'> </form> <div id='middle' style='width:680px; text-align:left; padding-left:20px; border:1px solid #ccc;'> </div> </div> </body> </html> "; } ?>
September 26, 201016 yr apologies for sounding off here... BUT im in the same industry as yourself and for a company selling web software, that has 54 team members with offices in 5 different country's surely one of you can sort out something as basic as this... doesn't give much confidence in platform-it's ability's to prospective clients googling you up & finding posts like this... anyway... why are you prefixing the page name... i dont get it... having designed a system exactly like this im lost as to why $page doesn't represent the FULL page name in the first place... i don't mean to offend with my post just voicing a concern ive had for awhile about your service
September 26, 201016 yr I guess why get a monkey doing it for peanuts when you can get someone on a forum to do it for nothing lol
September 26, 201016 yr I guess why get a monkey doing it for peanuts when you can get someone on a forum to do it for nothing lol good point!
September 26, 201016 yr Author actually i am not a programmer, i am from business field and a business student and i just run the compnay with two of my friends.and i have little knowledge about web designing/developing. but i am trying to learn. and you belive or not i learn all the thing from this forum.and i know that users of this forum is very helpful and they always try to help me. am i in wrong way? shouldnot i learn or know anything about design/coding? you may ask y not i am discussing with my team mate.because i dont want to let them know that i am learning how to develop website. and there is a reason which i should not declare now. i am sorry for my poor english
September 26, 201016 yr i am new in php. and the purpose of the script is to edit .html file. suppose there i 24/25 html file in my site. and i want to edit these html file by this script.so it is not easy to put/change the html file name evrytime.. Thats what I thought you was trying to do but didn't think it would be that basic. ok, I'll be kind and point you in the right direction. Keeping it simple, you can add an auto filled form dropdown or just have a manual input. Then change the p to... oh I don't know. Maybe a variable?
September 26, 201016 yr Basically, you don't want them to know you're learning their job in case they decide to leave for better prospects. Choppy waters
September 26, 201016 yr Author oh thank you mate. i am grateful that you are pointing me to the right direction. i dont like the manual input. i want to add a auto field dropdown.but i dont know how to this.
Create an account or sign in to comment