tmyonline Posted April 6, 2009 Share Posted April 6, 2009 Hi guys, Is there a way to store the source code (output) of my program in a MySQL database table ? By meaning "source code", I mean, on Firefox, you go to View > Page Source, i.e., the output of my program. Is there a way to access this source code using PHP so that I can dump it into a MySQL table. Any ideas ? Thanks so much. Quote Link to comment https://forums.phpfreaks.com/topic/152900-how-to-store-my-source-code-in-a-mysql-table/ Share on other sites More sharing options...
Brian W Posted April 6, 2009 Share Posted April 6, 2009 Look into file_get_contents() and then you'll need to escape it (best use mysql_real_escape_string())... there may be conflicts with some symbols, if so, look into htmlentites() and html_entity_decode() Best of luck Quote Link to comment https://forums.phpfreaks.com/topic/152900-how-to-store-my-source-code-in-a-mysql-table/#findComment-803003 Share on other sites More sharing options...
tmyonline Posted April 7, 2009 Author Share Posted April 7, 2009 Thanks so much Brian. It helped. I tested it and it worked great. The only issue is that somehow this PHP function, file_get_contents(), only works on the server and not locally. Any ideas ? Thanks a lot again. Quote Link to comment https://forums.phpfreaks.com/topic/152900-how-to-store-my-source-code-in-a-mysql-table/#findComment-803429 Share on other sites More sharing options...
PFMaBiSmAd Posted April 7, 2009 Share Posted April 7, 2009 That would depend on how you are using file_get_contents() and what errors there are. What is your code and what does putting the following two lines immediately after your first opening <?php tag give - ini_set ("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/152900-how-to-store-my-source-code-in-a-mysql-table/#findComment-803455 Share on other sites More sharing options...
tmyonline Posted April 7, 2009 Author Share Posted April 7, 2009 Thanks PFMaBiSmAd. I tried your suggestion: ini_set ("display_errors", "1"); error_reporting(E_ALL); and no errors were reported. Unfortunately, my code is rather long and, due to the imposed security at my work place, I cannot post my code here or elsewhere. However, I have tried your suggestions on several files and didn't receive any error. Quote Link to comment https://forums.phpfreaks.com/topic/152900-how-to-store-my-source-code-in-a-mysql-table/#findComment-803490 Share on other sites More sharing options...
PFMaBiSmAd Posted April 7, 2009 Share Posted April 7, 2009 Sorry, cannot help you without any specific information to go by. There are several php configuration differences that could cause code to work on one server and not on another one and based on the symptoms the problem might not even have anything to do with file_get_contents(). Quote Link to comment https://forums.phpfreaks.com/topic/152900-how-to-store-my-source-code-in-a-mysql-table/#findComment-803546 Share on other sites More sharing options...
tmyonline Posted April 7, 2009 Author Share Posted April 7, 2009 Thanks PFMaBiSmAd. Quote Link to comment https://forums.phpfreaks.com/topic/152900-how-to-store-my-source-code-in-a-mysql-table/#findComment-803678 Share on other sites More sharing options...
laffin Posted April 7, 2009 Share Posted April 7, 2009 If this is on a local server, and the retrieval is also on the local server. U may opt to use ob_start/ob_end_clean functions. This will buffer the output, until ob_end_clean is called, which returns a string with the buffer contents (output to browser). from there ya can save or do wutever ya like. Quote Link to comment https://forums.phpfreaks.com/topic/152900-how-to-store-my-source-code-in-a-mysql-table/#findComment-803820 Share on other sites More sharing options...
tmyonline Posted April 8, 2009 Author Share Posted April 8, 2009 If this is on a local server, and the retrieval is also on the local server. U may opt to use ob_start/ob_end_clean functions. This will buffer the output, until ob_end_clean is called, which returns a string with the buffer contents (output to browser). from there ya can save or do wutever ya like. Thanks so much laffin. You are the man. Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/152900-how-to-store-my-source-code-in-a-mysql-table/#findComment-804887 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.