d22552000 Posted August 13, 2007 Share Posted August 13, 2007 My Source In Problem... $filename = "C:/Inetpub/wwwroot/" . $p . "/forum/includes/config.php"; My Outcome: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING. What the Hell? Quote Link to comment https://forums.phpfreaks.com/topic/64690-picky-variable/ Share on other sites More sharing options...
NArc0t1c Posted August 13, 2007 Share Posted August 13, 2007 Try htmlspecialchars function. Example, $filename = "C:/Inetpub/wwwroot/" . htmlspecialchars($p) . "/forum/includes/config.php"; Quote Link to comment https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322560 Share on other sites More sharing options...
akitchin Posted August 13, 2007 Share Posted August 13, 2007 shouldn't make a difference, as the parse error is encountered before the variable is glued in. try removing the spaces around the concatenators, and also ensure that you're looking at the correct line. post the line before and after. Quote Link to comment https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322561 Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Author Share Posted August 13, 2007 the funny part is that $p is just 3 letters... but im trying it... *EDIT* same error. Quote Link to comment https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322563 Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Author Share Posted August 13, 2007 I am parsing this line ALL BY ITSELF cause it kept giving me shit before. ... no spaces $filename="C:/Inetpub/wwwroot/".$p."/forum/includes/config.php"; result: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING. Quote Link to comment https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322565 Share on other sites More sharing options...
trq Posted August 13, 2007 Share Posted August 13, 2007 We need to see more code. The previous few lines. Quote Link to comment https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322566 Share on other sites More sharing options...
akitchin Posted August 13, 2007 Share Posted August 13, 2007 let's see all lines in the script you're running, whether they seem innocuous or not. also, if you're going to be parsing the variable outside of the string assignment anyway, might as well use single quotes (just as a general rule). Quote Link to comment https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322568 Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Author Share Posted August 13, 2007 I just told you, because this one line of code was bugging so much, im running it in its very own php file for testing purposes... textfile.php $p=$_GET['p']; $filename='C:/Inetpub/wwwroot/'.$p.'/forum/includes/config.php'; I DID NOT MAKE THE RECURSIVE FOLDER SCRIPT, but I have had it work before. ORIGINAL.php <?PHP echo "Please be patient, this is long step..<br /><br />"; $n = $_POST['n']; $p = $_POST['p']; $g_link = mysql_connect( '127.0.0.1', 'root', '') or die('Could not connect to server.' ); mysql_query('CREATE DATABASE ' . $n . ';'); mysql_select_db($n, $g_link) or die('Could not select database.'); $d = "C:/Inetpub/wwroot/" . $p . "/forum"; $s = "C:/Inetpub/VB3.6.7/forum"; COPY_RECURSIVE_DIRS($s,$d); function COPY_RECURSIVE_DIRS($dirsource, $dirdest) { // recursive function to copy // all subdirectories and contents: if(is_dir($dirsource))$dir_handle=opendir($dirsource); mkdir($dirdest."/".$dirsource, 0750); while($file=readdir($dir_handle)) { if($file!="." && $file!="..") { if(!is_dir($dirsource."/".$file)) copy ($dirsource."/".$file, $dirdest."/".$dirsource."/".$file); else COPY_RECURSIVE_DIRS($dirsource."/".$file, $dirdest); } } closedir($dir_handle); return true; } echo "Writing Config..<br /><br />"; $filename="C:/Inetpub/wwwroot/".$p."/forum/includes/config.php"; $somecontent = "$config['Database']['dbname'] = '" . $n . "';$config['Database']['tableprefix'] = '';"; $somecontent = $somecontent . "$config['Database']['technicalemail'] = '';$config['Database']['force_sql_mode'] = true;"; $somecontent = $somecontent . "$config['MasterServer']['servername'] = 'localhost';$config['MasterServer']['port'] = 3306;"; $somecontent = $somecontent . "$config['MasterServer']['username'] = 'root';$config['MasterServer']['password'] = '';"; $somecontent = $somecontent . "$config['MasterServer']['usepconnect'] = 0;$config['Misc']['admincpdir'] = 'admincp';"; $somecontent = $somecontent . "$config['Misc']['modcpdir'] = 'modcp';$config['Misc']['cookieprefix'] = 'bb';"; $somecontent = $somecontent . "$config['Misc']['forumpath'] = '';$config['SpecialUsers']['canviewadminlog'] = '1,2';"; $somecontent = $somecontent . "$config['SpecialUsers']['canpruneadminlog'] = '1';$config['SpecialUsers']['canrunqueries'] = '';"; $somecontent = $somecontent . "$config['SpecialUsers']['undeletableusers'] = '';$config['SpecialUsers']['superadministrators'] = '1,2';"; $somecontent = $somecontent . "$config['Misc']['maxwidth'] = 2592;$config['Misc']['maxheight'] = 1944;"; // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success"; fclose($handle); require('C:\Inetpub\*EDITED OUT*') onesql();echo "sql1 done <br />"; twosql();echo "sql2 done <br />"; thrsql();echo "sql3 done <br />"; fursql();echo "sql4 done <br />"; echo '<br /><br /><br /><br /><a href="http://24.86.150.207/' . $n . '/forum/admincp/index.php">Login to AdminCP</a>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322572 Share on other sites More sharing options...
akitchin Posted August 13, 2007 Share Posted August 13, 2007 i know you're running it in its very own PHP file, but it's still helpful to see the entire thing (even the PHP tags). try commenting out the $filename assignment line and adding an echo to see if it works otherwise. Quote Link to comment https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322575 Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Author Share Posted August 13, 2007 th eoriginal.php code above IS the whole ifle.. and im tryign it... Quote Link to comment https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322576 Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Author Share Posted August 13, 2007 New porblem.. $somecontent = "$config['Database']['dbname'] = '" . $n . "';$config['Database']['tableprefix'] = '';"; its not url or whitespace escaped either..? Maybe I hsould explain waht my script does.. It installs vBulletin by copying a folder, insterintg the SQL and pointing the config.php file to the new databse. It has to write the database name into the config fiile, so I chose to output it on the script. Quote Link to comment https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322577 Share on other sites More sharing options...
akitchin Posted August 13, 2007 Share Posted August 13, 2007 $somecontent = "$config['Database']['dbname'] = '" . $n . "';$config['Database']['tableprefix'] = '';"; are you saying that line does or doesn't work? also i was referring to the textfile.php, which in your post, is missing its PHP tags and as such cannot be the complete script. Quote Link to comment https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322579 Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Author Share Posted August 13, 2007 the line that you quoted, is now the one that doesnt wokr. maybe this might help... syntax highlighting will find open brackets and quotes... [code=php:0] <?PHP echo "Please be patient, this is long step..<br /><br />"; $n = $_POST['n']; $p = $_POST['p']; $g_link = mysql_connect( '127.0.0.1', 'root', '') or die('Could not connect to server.' ); mysql_query('CREATE DATABASE ' . $n . ';'); mysql_select_db($n, $g_link) or die('Could not select database.'); $d = "C:/Inetpub/wwroot/" . $p . "/forum"; $s = "C:/Inetpub/VB3.6.7/forum"; COPY_RECURSIVE_DIRS($s,$d); function COPY_RECURSIVE_DIRS($dirsource, $dirdest) { if(is_dir($dirsource))$dir_handle=opendir($dirsource); mkdir($dirdest."/".$dirsource, 0750); while($file=readdir($dir_handle)) { if($file!="." && $file!="..") { if(!is_dir($dirsource."/".$file)) copy ($dirsource."/".$file, $dirdest."/".$dirsource."/".$file); else COPY_RECURSIVE_DIRS($dirsource."/".$file, $dirdest); } } closedir($dir_handle); return true; } echo "Writing Config..<br /><br />"; $filename='C:/Inetpub/wwwroot/'.$p.'/forum/includes/config.php'; $somecontent = "$config['Database']['dbname'] = '" . $n . "';$config['Database']['tableprefix'] = '';"; $somecontent = $somecontent . "$config['Database']['technicalemail'] = '';$config['Database']['force_sql_mode'] = true;"; $somecontent = $somecontent . "$config['MasterServer']['servername'] = 'localhost';$config['MasterServer']['port'] = 3306;"; $somecontent = $somecontent . "$config['MasterServer']['username'] = 'root';$config['MasterServer']['password'] = '';"; $somecontent = $somecontent . "$config['MasterServer']['usepconnect'] = 0;$config['Misc']['admincpdir'] = 'admincp';"; $somecontent = $somecontent . "$config['Misc']['modcpdir'] = 'modcp';$config['Misc']['cookieprefix'] = 'bb';"; $somecontent = $somecontent . "$config['Misc']['forumpath'] = '';$config['SpecialUsers']['canviewadminlog'] = '1,2';"; $somecontent = $somecontent . "$config['SpecialUsers']['canpruneadminlog'] = '1';$config['SpecialUsers']['canrunqueries'] = '';"; $somecontent = $somecontent . "$config['SpecialUsers']['undeletableusers'] = '';$config['SpecialUsers']['superadministrators'] = '1,2';"; $somecontent = $somecontent . "$config['Misc']['maxwidth'] = 2592;$config['Misc']['maxheight'] = 1944;"; if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success"; fclose($handle); require('C:\Inetpub\VB3.6.7\sql.php') onesql();echo "sql1 done <br />"; twosql();echo "sql2 done <br />"; thrsql();echo "sql3 done <br />"; fursql();echo "sql4 done <br />"; echo '<br /><br /><br /><br /><a href="http://24.86.150.207/' . $n . '/forum/admincp/index.php">Login to AdminCP</a>'; ?> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322580 Share on other sites More sharing options...
akitchin Posted August 13, 2007 Share Posted August 13, 2007 that could be for several reasons. first of all, PHP expects $config to be an actual variable unless you escape the $ to show that you mean a literal dollar sign: $somecontent = "\$config['Database']['dbname'] = '" . $n . "';\$config['Database']['tableprefix'] = '';"; if that doesn't work, then we're back to the issue we were having with the $filename line, in which case we might as well focus on that file. EDIT: just saw your code - you're going to have troubles after all this trying to run a function that isn't yet defined. Quote Link to comment https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322583 Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Author Share Posted August 13, 2007 I forgot to escape all those dollar signs -,- lOL what a stupid mistake. it passes that part now but... Parse error: syntax error, unexpected T_STRING in C:\Inetpub\wwwroot\Registration\vbcreate.php on line 67 FIXED but now I have this: Parse error: syntax error, unexpected T_ECHO in C:\Inetpub\wwwroot\Registration\vbcreate.php on line 72 I fided that but.... YAY!!! I fixed the million errors thing... now only 3... Warning: mkdir() [function.mkdir]: No such file or directory in C:\Inetpub\wwwroot\Registration\vbcreate.php on line 19 Warning: readdir(): supplied argument is not a valid Directory resource in C:\Inetpub\wwwroot\Registration\vbcreate.php on line 20 Warning: closedir(): supplied argument is not a valid Directory resource in C:\Inetpub\wwwroot\Registration\vbcreate.php on line 28 Writing Config.. Warning: fopen(C:/Inetpub/wwwroot/a/forum/includes/config.php) [function.fopen]: failed to open stream: No such file or directory in C:\Inetpub\wwwroot\Registration\vbcreate.php on line 51 Cannot open file (C:/Inetpub/wwwroot/a/forum/includes/config.php) Quote Link to comment https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322584 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.