DevinGn Posted March 11, 2009 Share Posted March 11, 2009 Alrighty, so I am attempting to create a PHPNuke host script, and I've run into a problem with generating the config file. I'm so close to finishing, with just a few steps left, but I'm at a stand still because of this. What I'm trying to do is create a file named: variable.php, which contains some variables for each specific installation of PHPNuke. Here is the error I receive: Parse error: syntax error, unexpected T_STRING in /home2/depthhos/public_html/host/create.php on line 54 Now, here's my code. I've believe the problem exists somewhere under: //create config file <? //PHPNUKE AUTOINSTALLER //Static Variables $source ='/home2/depthhos/public_html/freshnuke/'; $destination = "/home2/depthhos/public_html/host/$subdomain/"; //Form Variables $subdomain = $_POST["subdomain"]; $adminlogin = $_POST["adminlogin"]; $adminpass = $_POST["adminpass"]; $adminemail = $_POST["adminemail"]; $sitename = $_POST["sitename"]; //create subdomain folder mkdir("/home2/depthhos/public_html/host/$subdomain/") or die ("Could not make directory"); //Copy Function function full_copy( $source, $target ) { if ( is_dir( $source ) ) { @mkdir( $target ); $d = dir( $source ); while ( FALSE !== ( $entry = $d->read() ) ) { if ( $entry == '.' || $entry == '..' ) { continue; } $Entry = $source . '/' . $entry; if ( is_dir( $Entry ) ) { full_copy( $Entry, $target . '/' . $entry ); continue; } copy( $Entry, $target . '/' . $entry ); } $d->close(); }else { copy( $source, $target ); } } //Copy Nuke full_copy($source, $destination); //create file to contain variables $ourFileName = realpath( $_SERVER['DOCUMENT_ROOT'] )."/host/$subdomain/variables.php"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fclose($ourFileHandle); //create config file $variables=" <?php $prefix = "$subdomain"; $user_prefix = "nuke"; $dbtype = "MySQL"; $sitekey = "cPEnq15ZPmejnuKtzZMUHFH1bee9KLT9i5FfZBmI"; $subscription_url = ""; $admin_file = "admin"; ?>"; $file = realpath( $_SERVER['DOCUMENT_ROOT'] )."/host/$subdomain/variables.php"; $fh = fopen($file, 'w') or die("can't open file"); fwrite($fh, $config); fclose($fh); //All Done ?> I'm still new to PHP, so any help (or better methods of accomplishing the same task) would be greatly appreciated. Thanks! -Devin Quote Link to comment https://forums.phpfreaks.com/topic/148876-solved-error-generating-php-file/ Share on other sites More sharing options...
trq Posted March 11, 2009 Share Posted March 11, 2009 The problem is your using double quotes within a double quoted string. each of these will need to be escaped using the \ char. Quote Link to comment https://forums.phpfreaks.com/topic/148876-solved-error-generating-php-file/#findComment-781723 Share on other sites More sharing options...
phpdragon Posted March 11, 2009 Share Posted March 11, 2009 replace $prefix = "$subdomain"; with $prefix = $subdomain; also change the " to ' for other variables Quote Link to comment https://forums.phpfreaks.com/topic/148876-solved-error-generating-php-file/#findComment-781725 Share on other sites More sharing options...
trq Posted March 11, 2009 Share Posted March 11, 2009 Actually, this whole section.... $variables=" <?php $dbhost = "localhost"; $dbuname = "root"; $prefix = "$subdomain"; $user_prefix = "nuke"; $dbtype = "MySQL"; $sitekey = "cPEnq15ZPmejnuKtzZMUHFH1bee9KLT9i5FfZBmI"; $subscription_url = ""; $admin_file = "admin"; ?>"; should be replaced with..... [pre] $variables=" <?php \$dbhost = \"localhost\"; \$dbuname = \"root\"; \$prefix = \"$subdomain\"; \$user_prefix = \"nuke\"; \$dbtype = \"MySQL\"; \$sitekey = \"cPEnq15ZPmejnuKtzZMUHFH1bee9KLT9i5FfZBmI\"; \$subscription_url = \"\"; \$admin_file = \"admin\"; ?>"; [/pre] Quote Link to comment https://forums.phpfreaks.com/topic/148876-solved-error-generating-php-file/#findComment-781726 Share on other sites More sharing options...
DevinGn Posted March 11, 2009 Author Share Posted March 11, 2009 Brilliant! It works. Thank you so much for the assistance. edit: No errors, but no data gets written to variables.php Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/148876-solved-error-generating-php-file/#findComment-781727 Share on other sites More sharing options...
trq Posted March 11, 2009 Share Posted March 11, 2009 When you place a double quotes within a double quoted string it needs to be escaped otherwise php thinks you want to end the string. In your case, you also need to escape the $ char so that it won't be interpolated. The code I posted should work. Quote Link to comment https://forums.phpfreaks.com/topic/148876-solved-error-generating-php-file/#findComment-781728 Share on other sites More sharing options...
DevinGn Posted March 11, 2009 Author Share Posted March 11, 2009 I get it, thank you for explaining. Your code doesn't deliver any errors, but I don't understand why it won't write any data to the file. Quote Link to comment https://forums.phpfreaks.com/topic/148876-solved-error-generating-php-file/#findComment-781729 Share on other sites More sharing options...
trq Posted March 11, 2009 Share Posted March 11, 2009 Your not writing anything to the file. fwrite($fh, $config); should be.... fwrite($fh, $variables); Quote Link to comment https://forums.phpfreaks.com/topic/148876-solved-error-generating-php-file/#findComment-781732 Share on other sites More sharing options...
DevinGn Posted March 11, 2009 Author Share Posted March 11, 2009 oops, I feel like an idiot. I recently changed the variable name and I must have missed that one. It's fully functional now, thanks for the speedy assistance! -Devin Quote Link to comment https://forums.phpfreaks.com/topic/148876-solved-error-generating-php-file/#findComment-781735 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.