Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322561
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322565
Share on other sites

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>';

?>

Link to comment
https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322572
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322577
Share on other sites

$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.

Link to comment
https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322579
Share on other sites

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]

Link to comment
https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322580
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322583
Share on other sites

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)

Link to comment
https://forums.phpfreaks.com/topic/64690-picky-variable/#findComment-322584
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.