Lol5916 Posted February 5, 2009 Share Posted February 5, 2009 Ok so I have something on my index.php like: <?php $filename = "install.php"; if (file_exists($filename)) { echo "Site cannot be executed until the site is installed. <br> <a href="install.php">Click here to install site</a>"; die; } else { REMOVETHISCODE ?> If else is ran how do I get it to remove every line above it until it's at the top of the file, OR how do I get it to remove that php? Link to comment https://forums.phpfreaks.com/topic/143860-remove-code/ Share on other sites More sharing options...
crashmaster Posted February 5, 2009 Share Posted February 5, 2009 Hey man, if you have DIE function - PHP stops executing rest of the code Link to comment https://forums.phpfreaks.com/topic/143860-remove-code/#findComment-754876 Share on other sites More sharing options...
crashmaster Posted February 5, 2009 Share Posted February 5, 2009 should be die(); Link to comment https://forums.phpfreaks.com/topic/143860-remove-code/#findComment-754878 Share on other sites More sharing options...
Lol5916 Posted February 5, 2009 Author Share Posted February 5, 2009 Ok thanks, but that's not the question and I would have figured it out eventually xD Link to comment https://forums.phpfreaks.com/topic/143860-remove-code/#findComment-754883 Share on other sites More sharing options...
gevans Posted February 5, 2009 Share Posted February 5, 2009 should be die(); Actually if you're not doing anything within the parenthesis they are option so die; is fine... @ Lol5916 So once your code is installed you go to index.php and do; <?php $filename = "install.php"; if (file_exists($filename)) { echo "Site cannot be executed until the site is installed. <br> <a href="install.php">Click here to install site</a>"; die; } else { REMOVETHISCODE And the first time that runs successfully you want to delete those lines so it never does the check again? Link to comment https://forums.phpfreaks.com/topic/143860-remove-code/#findComment-754884 Share on other sites More sharing options...
Lol5916 Posted February 5, 2009 Author Share Posted February 5, 2009 And the first time that runs successfully you want to delete those lines so it never does the check again? Yes, that is correct. Link to comment https://forums.phpfreaks.com/topic/143860-remove-code/#findComment-754896 Share on other sites More sharing options...
gevans Posted February 5, 2009 Share Posted February 5, 2009 My heads telling me the quick answer is no, because you'll be executing a script on the file that the script is running from. So as it start to write the file (without your lines) it will basically kill itself and leave you with a blank index.php Seeing as the insignificance of the few lines of code why not just leave them in.... <?php if (file_exists("install.php")) { echo "Site cannot be executed until the site is installed. <br> <a href="install.php">Click here to install site</a>"; die; } REMOVETHISCODE You can just make it the first line of the page Link to comment https://forums.phpfreaks.com/topic/143860-remove-code/#findComment-754916 Share on other sites More sharing options...
gevans Posted February 5, 2009 Share Posted February 5, 2009 Actually, if you really want to get rid of it I think I've found away. The first time index.php runs successfully you push it to another page header('Location: sort_index.php'); then sort_index.php write the index file and deletes itself. though i still dont think its necessary Link to comment https://forums.phpfreaks.com/topic/143860-remove-code/#findComment-754920 Share on other sites More sharing options...
Lol5916 Posted February 5, 2009 Author Share Posted February 5, 2009 What if I do something like include the install.php, I just don't know how I would stop it from making an error after it was installed. Link to comment https://forums.phpfreaks.com/topic/143860-remove-code/#findComment-754926 Share on other sites More sharing options...
corbin Posted February 5, 2009 Share Posted February 5, 2009 echo "Site cannot be executed until the site is installed. <br> <a href="install.php">Click here to install site</a>"; Is a syntax error.... echo "Site cannot be executed until the site is installed. <br> <a href=\"install.php\">Click here to install site</a>"; Link to comment https://forums.phpfreaks.com/topic/143860-remove-code/#findComment-754928 Share on other sites More sharing options...
gevans Posted February 5, 2009 Share Posted February 5, 2009 Well if you're making this for users I'd recommend on completion tell them they should delete it. If it is called have a check at the top to see if it's already installed. Link to comment https://forums.phpfreaks.com/topic/143860-remove-code/#findComment-754930 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.