Ramamoorthy Posted October 1, 2013 Share Posted October 1, 2013 (edited) Hi all, I am coding for Windows software download website - there I ll be having more than 300 softwares . every category will be having its unique ID , every software will be having its unique ID, every software version will be having its unique ID. Example : For category Browser : id will be bro for software chrome : id will be bro_aaaa for chrome 28.0 : id will be bro_aaaa_aa here how I ll print the informations in website // db.php // $bro = "Browsers"; $bro_aaaa = "Google Chrome"; $bro_aaaa_aa = "28.0" -----(end of file db.php) // include.php // <?php echo $softwarecat; echo $softwarename; echo $softwareversion; ?> ---------(end of file include.php) // software-page.php // <?php require_once($_SERVER['DOCUMENT_ROOT'] . '/db.php'); $softwarecat =$bro; $softwarename =$bro_aaaa; $softwareversion =$bro_aaaa_aa; include './include.php'; ?> /* using include.php because just changing only this file , I can implement changes all over the website */ so the server will print everything rightly as mentioned in the db.php Now . if I change the include.php as like below . <?php echo $softwarecat; echo $softwarename; echo $softwareversion; echo $softwaresize; /* listen - new feature */ ?> It will lead to error in all software pages as I haven't specified the value for $softwaresize . but I can specify it for new software pages . How can I fix it . Only way I know is below in softwarepage.php <?php require_once($_SERVER['DOCUMENT_ROOT'] . '/db.php'); $softwarecat = bro; $softwareid = aaaa; $softwareversionid = aa; include './include.php'; ?> now I need help for this part . the server has to replace the $softwarecat as $bro; and $softwareid as aaaa; and $softwareversionid as aa; if this happens I can completely change the include.php file as my wish . any help is greatly appreciated . I am here to clarify any doubt regarding my question (Note : I am very new to this site and I don't know how to even ask a question. anyone please guide) Edited October 1, 2013 by Ramamoorthy Quote Link to comment https://forums.phpfreaks.com/topic/282603-help-need-for-coding-complicated-php-script/ Share on other sites More sharing options...
cyberRobot Posted October 1, 2013 Share Posted October 1, 2013 Sorry, I'm not sure what you're asking. Could you restate the question? Also, could you re-post the code and surround each code block with the tags. This should hopefully make the post easier to follow. Quote Link to comment https://forums.phpfreaks.com/topic/282603-help-need-for-coding-complicated-php-script/#findComment-1452022 Share on other sites More sharing options...
Ramamoorthy Posted October 1, 2013 Author Share Posted October 1, 2013 Hi all, I am coding for Windows software download website - there I ll be having more than 300 softwares . every category will be having its unique ID , every software will be having its unique ID, every software version will be having its unique ID. Example : For category Browser : id will be bro for software chrome : id will be bro_aaaa for chrome 28.0 : id will be bro_aaaa_aa here how I ll print the informations in website // db.php // <?php $bro = "Browsers"; $bro_aaaa = "Google Chrome"; $bro_aaaa_aa = "28.0" ?> -----(end of file db.php) // include.php // <?php echo $softwarecat; echo $softwarename; echo $softwareversion; ?> ---------(end of file include.php) // software-page.php // <?php require_once($_SERVER['DOCUMENT_ROOT'] . '/db.php'); $softwarecat =$bro; $softwarename =$bro_aaaa; $softwareversion =$bro_aaaa_aa; include './include.php'; ?> /* using include.php because just changing only this file , I can implement changes all over the website */ so the server will print everything rightly as mentioned in the db.php Now . if I change the include.php as like below . <?php echo $softwarecat; echo $softwarename; echo $softwareversion; echo $softwaresize; /* listen - new feature */ ?> It will lead to error in all software pages as I haven't specified the value for $softwaresize . but I can specify it for new software pages . How can I fix it . Only way I know is below in softwarepage.php <?php require_once($_SERVER['DOCUMENT_ROOT'] . '/db.php'); $softwarecat = bro; $softwareid = aaaa; $softwareversionid = aa; include './include.php'; ?> now I need help for this part . the server has to replace the $softwarecat as $bro; and $softwareid as aaaa; and $softwareversionid as aa; if this happens I can completely change the include.php file as my wish . any help is greatly appreciated . I am here to clarify any doubt regarding my question (Note : I am very new to this site and I don't know how to even ask a question. anyone please guide) please dont recommend to use mysql - I think it can be easily done . But I dont know mysql (even I know only very little php) Quote Link to comment https://forums.phpfreaks.com/topic/282603-help-need-for-coding-complicated-php-script/#findComment-1452025 Share on other sites More sharing options...
cyberRobot Posted October 1, 2013 Share Posted October 1, 2013 So basically, $softwaresize will be defined in some page, but not others? And you're looking to echo the value only when it's set? If so, you could try something like: if(isset($softwaresize)) { echo $softwaresize; } Quote Link to comment https://forums.phpfreaks.com/topic/282603-help-need-for-coding-complicated-php-script/#findComment-1452026 Share on other sites More sharing options...
Ch0cu3r Posted October 1, 2013 Share Posted October 1, 2013 Now . if I change the include.php as like below . <?php echo $softwarecat; echo $softwarename; echo $softwareversion; echo $softwaresize; /* listen - new feature */ ?> It will lead to error in all software pages as I haven't specified the value for $softwaresize . but I can specify it for new software pages . You need top check if $softwaresize exists before using it. You can do this using the isset function if(isset($softwaresize)) { // variable exists. We can use it with out error echo $softwaresize; /* listen - new feature */ } Now It'll only echo out the $softwaresize variable if it exists and wont display a notice error for undefined variable $softwaresize. Only way I know is below in softwarepage.php <?phprequire_once ($_SERVER['DOCUMENT_ROOT'] . '/db.php'); $softwarecat = bro; $softwareid = aaaa; $softwareversionid = aa; include './include.php'; ?> now I need help for this part . the server has to replace the $softwarecat as $bro; and $softwareid as aaaa; and $softwareversionid as aa; if this happens I can completely change the include.php file as my wish . That doesn't make any sense to me. Where is bro aaa and aa coming from? Quote Link to comment https://forums.phpfreaks.com/topic/282603-help-need-for-coding-complicated-php-script/#findComment-1452027 Share on other sites More sharing options...
Ramamoorthy Posted October 1, 2013 Author Share Posted October 1, 2013 But I want to implement the new feature to the old pages also ..Thanks Ch0cu3ri ll try . The bro , aaaa and aa are unique IDs . used to maintain website . Quote Link to comment https://forums.phpfreaks.com/topic/282603-help-need-for-coding-complicated-php-script/#findComment-1452028 Share on other sites More sharing options...
Ramamoorthy Posted October 1, 2013 Author Share Posted October 1, 2013 So basically, $softwaresize will be defined in some page, but not others? And you're looking to echo the value only when it's set? If so, you could try something like: if(isset($softwaresize)) { echo $softwaresize; } I am not sure that you entirely got my question . But I dont want to check whether the variable is declared or not . I want to implement the feature all over the site .. Quote Link to comment https://forums.phpfreaks.com/topic/282603-help-need-for-coding-complicated-php-script/#findComment-1452029 Share on other sites More sharing options...
cyberRobot Posted October 1, 2013 Share Posted October 1, 2013 I am not sure that you entirely got my question . But I dont want to check whether the variable is declared or not . I want to implement the feature all over the site .. The isset() function is just there as a stopgap. Once all of your pages have the variable defined before calling include.php, the isset() can be removed. Is there other issues with the website if $softwaresize isn't set? Quote Link to comment https://forums.phpfreaks.com/topic/282603-help-need-for-coding-complicated-php-script/#findComment-1452030 Share on other sites More sharing options...
Ramamoorthy Posted October 1, 2013 Author Share Posted October 1, 2013 This post could help more to the question. I have 4 files db.php - databse file include.php - global include file like header and footer soft1.php - single php file for software listing soft2.php - again single php file for software listing. CODES in db.php <?php $bro_aaaa= "google chrome" $bro_aaaa_aa = "28.0" ?> in include.php <?php echo $softwarename; echo $softwareversion; ?> in soft1.php <?php require './db.php'; $softwarename = $bro_aaaa; $softwareversion = $bro_aaaa_aa; include './include.php'; ?> so If I now change the Include.php for adding two more feature like this . <?php echo $softwarename; echo $softwareversion; echo $softwareversion_size; echo $softwareversion_releasedate; ?> and add new file to server called soft2.php <?php require './db.php'; $softwarename = $bro_aaaa; $softwareversion = $bro_aaaa_aa; $softwareversion_size = $bro_aaaa_aa_size; $softwareversion_releasedate = $bro_aaaa_aa_reldate; include './include.php'; ?> (I will add needed informations in the database - db.php) now my soft1.php page will lead to error because it doesnt know what new 2 variables is . but I dont want to use isset - and if it isset it have to show , otherwise it ll will not show the new2 feature .because I need to implement the feature for all softwares (all new and old pages).. how can achieve new feature implementation throughout the site ..? Quote Link to comment https://forums.phpfreaks.com/topic/282603-help-need-for-coding-complicated-php-script/#findComment-1452032 Share on other sites More sharing options...
Ramamoorthy Posted October 1, 2013 Author Share Posted October 1, 2013 The isset() function is just there as a stopgap. Once all of your pages have the variable defined before calling include.php, the isset() can be removed. Is there other issues with the website if $softwaresize isn't set? thanks for the idea. I can add the newly implemented variable .. only if I have some 100 or 200 pages .. what If I have some thousands of page . anyway I ll surely consider this , but man keep giving guidance to me . Quote Link to comment https://forums.phpfreaks.com/topic/282603-help-need-for-coding-complicated-php-script/#findComment-1452033 Share on other sites More sharing options...
Solution cyberRobot Posted October 1, 2013 Solution Share Posted October 1, 2013 now my soft1.php page will lead to error because it doesnt know what new 2 variables is . but I dont want to use isset - and if it isset it have to show , otherwise it ll will not show the new2 feature .because I need to implement the feature for all softwares (all new and old pages).. how can achieve new feature implementation throughout the site ..? Sorry, I'm not seeing the issue. When using the isset feature, the variable will display when it's set. It won't display (and won't give an error) when the variable isn't set. Perhaps I'm missing something. You might need to provide more information about the script and what you're trying to do. thanks for the idea. I can add the newly implemented variable .. only if I have some 100 or 200 pages .. what If I have some thousands of page . anyway I ll surely consider this , but man keep giving guidance to me . Do the pages work fine without the newly added feature? If so, then you can use the stopgap measure. If not, you should set up a development site; change everything (100 or 200 pages); then go live with the updated website. While making the changes, you should consider if there is a better way to build the website. Are many of the pages coded similarly? If so, perhaps you could build a common script that's populated with information from a database. Quote Link to comment https://forums.phpfreaks.com/topic/282603-help-need-for-coding-complicated-php-script/#findComment-1452034 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.