Jump to content

[SOLVED] passing variable prob with bigdump


pcw

Recommended Posts

Hi, I am using bigdump to restore mysql databases. I have shortened the script down quite a lot.

 

I have this script which allows me to select the database to backup, from a drop down menu.

 

<?php

$backupFileDir = "backup/";
$handle = opendir($backupFileDir);

while ($sqlfile = readdir($handle))
{
$sqlfiles[] = $sqlfile;
}

closedir($handle);
sort($sqlfiles);

print "<form action='bigdump.php?' method='POST'>";
print "<select name='sqlfile'>";
print "<option>Choose Database Backup</option>";
foreach ($sqlfiles as $sqlfile) {
if (($sqlfile != ".") And ($sqlfile != "..")) {
print sprintf("<option value='$backupFile%s'>%s</option>", $sqlfile, $sqlfile);
}
}
print "</select>";
print "<input type='submit' name='submit' value='submit'>";
print "</form>";
print "</center>";

print '
</td>
        </tr>
      </table>';	
?>

 

I then pass sqlfile to the bigdump.php script.

 

I have this:

 

<?php
$filename = $_POST['sqlfile']; 
if (!$error && !isset ($_REQUEST["fn"]) && $filename!="")
{ echo ("<p><a href=\"".$_SERVER["PHP_SELF"]."?start=1&fn=".urlencode($filename)."&foffset=0&totalqueries=0\">Are you sure you would like to restore this database?</a></p>\n");
}

 

But when I submit the form, and then click the link to confirm the restoration, I get this error:

 

Can't open mysql_moveitho_sitebuilder_22_Mar_2009_time_18_41_26.sql.gz for import

 

Please, check that your dump file name contains only alphanumerical characters, and rename it accordingly, for example: mysql_moveitho_sitebuilder_22_Mar_2009_time_18_41_26.sql.gz.

Or, specify $filename in bigdump.php with the full filename.

 

I have printed $filename in bigdump.php and it prints the whole filename, so i think the problem is something to do with $filename not being assigned the full filename, but a $_POST

 

How can I fix this?

 

Thanks

Hi WolfRage, thanks for your reply.

 

If I assign the variable $filename like this:

 

$filename = 'mysql_moveitho_sitebuilder_22_Mar_2009_time_18_41_26.sql.gz';

 

Then it works. If I assign $filename like this

 

$filename = $_POST['sqlfile'];

 

it doesnt work.

 

I am not certain that this error is because the file is not unzipped, as it works fine the first way :(

Try echoing $_POST['sqlfile'] make sure that it is exactly what it is susposed to be, I see extra characters in your script and I am guessing that it will not be what you expect.

Remember always double check your input with an echo, if it is not doing what you expect then it is probably not what you think it is.

Nope it is in another folder called backup lol, I overlooked that part.

 

Now I have another prob:

 

$filename = "backup/$_POST['sqlfile']";

 

I get this error:

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/moveitho/public_html/sitebuilder/bigdump.php on line 12

 

How can I assign a directory and the posted file to $filename?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.