jmr3460 Posted March 12, 2009 Share Posted March 12, 2009 Can I create a global variable ($table) that can be used in my update script that I can use in MySQL queries? Also is is possible to upload a file to a MySQL DataBase? (May not be considered PHP question.) Like Images or data files? jmr3460 Link to comment https://forums.phpfreaks.com/topic/149065-global-question/ Share on other sites More sharing options...
genericnumber1 Posted March 12, 2009 Share Posted March 12, 2009 Yes. http://us.php.net/variables.scope But you shouldn't.. Link to comment https://forums.phpfreaks.com/topic/149065-global-question/#findComment-782752 Share on other sites More sharing options...
jmr3460 Posted March 12, 2009 Author Share Posted March 12, 2009 Is this because of a security? Link to comment https://forums.phpfreaks.com/topic/149065-global-question/#findComment-782756 Share on other sites More sharing options...
rblake81 Posted March 12, 2009 Share Posted March 12, 2009 Hi jmr3460, In answer to your section question, yes you can upload files like images and data files to a MYSQL database, using the BLOB field type, however, for improved performance, it is usually better to upload files to the server and reference them in the database (ie. put the path to the file in the database and use that to find the file that you uploaded to the server). And yes you can use global variables but it's not a good idea. Here's some reading: http://blog.case.edu/gps10/2006/07/22/why_global_variables_in_php_is_bad_programming_practice http://c2.com/cgi/wiki?GlobalVariablesAreBad Cheers Link to comment https://forums.phpfreaks.com/topic/149065-global-question/#findComment-782776 Share on other sites More sharing options...
jmr3460 Posted March 14, 2009 Author Share Posted March 14, 2009 Yea Thanks rblake81 for that reading info. Most of the second link was way over my head but I hope to come to understand those subjects and much more. One thing that does happen when reading some things like those articles is that it helps me form more questions to search out answers for. Thanks again for all of the replies. Generally after all the replies I have deduced that global variables are bad form. So for now with the limited knowledge I have now I will turn away from global variables. Link to comment https://forums.phpfreaks.com/topic/149065-global-question/#findComment-784731 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.