Azzyh Posted November 22, 2009 Share Posted November 22, 2009 Hello. I have made this script: <? $msg = $_GET['testc']; if($_GET["testc"]) { if(mkdir(strtolower($msg), 0775)) { if(fwrite(fopen(strtolower($msg)."/index.php", "w+"), "CONTENT FOR THE INDEX FILE")) { print "Done: <a href='http://azzyh.dk/$msg'>$msg.azzyh.dk</a>"; }else{ print "Error #8 contact admin, and report please."; } }else{ print "Error #9 contact admin, and report please."; } } ?> But i want to have a PHP script in the index.php file that the script above ^ is writing. How should i do that ? Here's the script i want in: <? $msg = $_GET['test']; $logfile= 'log.html'; $fp = fopen($logfile, "a"); fwrite($fp, $msg); fclose($fp); ?> Should i go like this: <? $msg = $_GET['testc']; if($_GET["testc"]) { if(mkdir(strtolower($msg), 0775)) { if(fwrite(fopen(strtolower($msg)."/index.php", "w+"), ?> <? $msg = $_GET['test']; $logfile= 'log.html'; $fp = fopen($logfile, "a"); fwrite($fp, $msg); fclose($fp); ?> <? )) { print "Done: <a href='http://azzyh.dk/$msg'>$msg.azzyh.dk</a>"; }else{ print "Error #8 contact admin, and report please."; } }else{ print "Error #9 contact admin, and report please."; } } ?> That wouldn't work i believe!? unexpected syntax. Thanks in forward! - My other topic, i was too fast saying that i solved it myself, because the include function didnt work. And i couldnt change the topic again to not solved.. Quote Link to comment Share on other sites More sharing options...
purencool Posted November 22, 2009 Share Posted November 22, 2009 <? $msg = $_GET['testc']; if($_GET["testc"]) { if(mkdir(strtolower($msg), 0775)) { if(fwrite(fopen(strtolower($msg)."/index.php", "w+"), $msg = $_GET['test']; $logfile= 'log.html'; $fp = fopen($logfile, "a"); fwrite($fp, $msg); fclose($fp); )) { print "Done: <a href='http://azzyh.dk/$msg'>$msg.azzyh.dk</a>"; }else{ print "Error #8 contact admin, and report please."; } }else{ print "Error #9 contact admin, and report please."; } } ?> Quote Link to comment Share on other sites More sharing options...
emopoops Posted November 22, 2009 Share Posted November 22, 2009 if ur doing it for multiples or maybe not, then u can have the file that has the php script in it, then copy that file.... $nameyourfile = $documentroot ."/". $variableornothere ."/index.php" ; $filegettingcopied = $documentroot ."/directory/index.php" ; if (copy($filegettingcopied, $nameyourfile)) {$congrats = "Congrats!the file was copied";} Quote Link to comment Share on other sites More sharing options...
Azzyh Posted November 22, 2009 Author Share Posted November 22, 2009 Purencool- I get, Parse error: syntax error, unexpected ';' in on line 7 emopoops - I dont get that coding, more than thankful if you would explain more. Just to clear it up, the php script $msg = $_GET['test']; $logfile= 'log.html'; $fp = fopen($logfile, "a"); fwrite($fp, $msg); fclose($fp); Shall not be used with that script, BUT the script shall be on the index.php' the script is building Quote Link to comment Share on other sites More sharing options...
purencool Posted November 22, 2009 Share Posted November 22, 2009 What is on line 7 Quote Link to comment Share on other sites More sharing options...
Azzyh Posted November 22, 2009 Author Share Posted November 22, 2009 $msg = $_GET['test']; Quote Link to comment Share on other sites More sharing options...
purencool Posted November 22, 2009 Share Posted November 22, 2009 is this the line above 7 if(fwrite(fopen(strtolower($msg)."/index.php", "w+") Quote Link to comment Share on other sites More sharing options...
Azzyh Posted November 22, 2009 Author Share Posted November 22, 2009 Yes. Quote Link to comment Share on other sites More sharing options...
purencool Posted November 22, 2009 Share Posted November 22, 2009 When you get this error always look at the line above Parse error: syntax error, unexpected ';' in on line 7 below I have gone through your code with comments that tell you what it does I not trying to mean. Because you are new I stepping you though what you have written In dot point what is you want to do exactly and I will help you write the code <? // grabbing a global var $msg = $_GET['testc']; // if testc is what eg empty full what? if($_GET["testc"]) { // change $msg to lower cand and make a dir if(mkdir(strtolower($msg), 0775)) { // make it lowercase and then open the file and write into the file if(fwrite(fopen(strtolower($msg)."/index.php", "w+"), // the the test var and place into msg $msg = $_GET['test']; // log file = log .html (if it exists) $logfile= 'log.html'; // open log file and place into $fp $fp = fopen($logfile, "a"); // write message into log fwrite($fp, $msg); // close log file fclose($fp); )) { // This code is not attached to any thing? print "Done: <a href='http://azzyh.dk/$msg'>$msg.azzyh.dk</a>"; }else{ print "Error #8 contact admin, and report please."; } }else{ print "Error #9 contact admin, and report please."; } } ?> Quote Link to comment Share on other sites More sharing options...
Azzyh Posted November 22, 2009 Author Share Posted November 22, 2009 Thank you for take your time! Big up! But i still got an unexpected ';' syntax error on line 7.. for some reason :/ Quote Link to comment Share on other sites More sharing options...
purencool Posted November 22, 2009 Share Posted November 22, 2009 This because your if statement is missing a { Quote Link to comment Share on other sites More sharing options...
Azzyh Posted November 22, 2009 Author Share Posted November 22, 2009 No it's not? Quote Link to comment Share on other sites More sharing options...
emopoops Posted November 22, 2009 Share Posted November 22, 2009 $newfile = $documentroot ."/thedrectoryyouarewritingyourfilein/thenameofthenewfile.php" ; $thefilethatsgettingcopiedAKAtheonewithallthephpcodeyourtryingtoputinthephp = $documentroot ."/anydirectoryornot/thefilenameTHATISGETTINGCOPIED.php" ; if (copy($thefilethatsgettingcopiedAKAtheonewithallthephpcodeyourtryingtoputinthephp, $newfile)) {$congrats = "Congrats!the file was copied";} a. make a file with the contents u want the new file thats being created to have. b.make the new file. Quote Link to comment Share on other sites More sharing options...
Azzyh Posted November 22, 2009 Author Share Posted November 22, 2009 That worked!!! Thank you! Quote Link to comment 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.