PHP Classes

Please help me

Recommend this page to a friend!

      MySQL Backup  >  All threads  >  Please help me  >  (Un) Subscribe thread alerts  
Subject:Please help me
Summary:Generated sql file contain html code...
Messages:5
Author:Sin Kronix
Date:2008-09-18 15:04:57
Update:2008-09-24 18:30:44
 

  1. Please help me   Reply   Report abuse  
Picture of Sin Kronix Sin Kronix - 2008-09-18 15:04:57
Hi, this is an absolute excelent class.
Unfortunatelly, I'm newbee coder and I have a big-big problem.
I have a .php file with few case statements.
When the page is loaded, a button DUMP DS is displayed in a form, targeted to page itself, with a hidden case=dump field.
I placed this code there:
require_once 'mysql_backup.class.php';
$backup_obj = new MySQL_Backup();
$backup_obj->server = 'localhost';
$backup_obj->port = 3306;
$backup_obj->username = 'myusername';
$backup_obj->password = 'mypass';
$backup_obj->database = 'mydb';
$backup_obj->tables = array();
$backup_obj->drop_tables = true;
$backup_obj->struct_only = false;
$backup_obj->comments = true;
$backup_obj->backup_dir = '/';
$backup_obj->fname_format = 'm_d_Y';
$task = MSB_DOWNLOAD;
$filename = '';
$use_gzip = false;
if (!$backup_obj->Execute($task, $filename, $use_gzip))
{
$output = $backup_obj->error;
}
else
{
$output = 'Operation Completed Successfully At: <b>' . date('g:i:s A') . '</b><i> ( Local Server Time )</i>';
}

echo $output;

The .sql file is created, I downloaded it, and it looks like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ro" lang="ro">

<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>

<body>


</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ro" lang="ro">

<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Admin</title>
<link href="includes/styles.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="includes/swfobject.js"></script>
</head>

<body>
.... then my divs
.......
......
then MySql dump
....
....
.... then my divs
</body>
</html>

It is useful anyway, but restoring colud be made only after manually clean the mess.
Would you tell me what I did wrong?

Thank you, u r great!

  2. Re: Please help me   Reply   Report abuse  
Picture of Vagharshak Tozalakyan Vagharshak Tozalakyan - 2008-09-19 05:45:43 - In reply to message 1 from Sin Kronix
Hello,

Just be sure that no output was sending to the browser before and after outputting the backup.

For example, you may check at the top of your script (before outputting the header part of HTML markup) "if ($_POST['case'] == 'dump') {" then process backup and call "die();" after "echo $output;".

I didn't know how your page is constructed to give you more specific answer.

Regards,
Vagharsh

  3. Re: Please help me   Reply   Report abuse  
Picture of Sin Kronix Sin Kronix - 2008-09-22 08:42:27 - In reply to message 2 from Vagharshak Tozalakyan
First of all, thank you very much for your support. I have made the changes that you suggested, but I've still got a problem.
This is the script in front of my page:
<?php
session_start();
include("includes/connection.inc.php");
include("admin_check_session.php");

require_once("ws_config.php");
define( 'VALID_IP', 1 );

$lang = "ro";
if (isset($_SESSION['lang'])) {
$lang = $_SESSION['lang'];
}
include("includes/$lang.php");

$case = "display";
if(isset($_POST['case'])) {
$case = $_POST['case']; }

if ($case == 'dump') {
require_once 'mysql_backup.class.php';
$backup_obj = new MySQL_Backup();
$backup_obj->server = 'localhost';
$backup_obj->port = 3306;
$backup_obj->username = 'web16u1';
$backup_obj->password = 'mysqlfr33acc3ss';
$backup_obj->database = 'web16db1';
$backup_obj->tables = array();
$backup_obj->drop_tables = true;
$backup_obj->struct_only = false;
$backup_obj->comments = true;
$backup_obj->backup_dir = '/';
$backup_obj->fname_format = 'm_d_Y';
$task = MSB_DOWNLOAD;
$filename = '';
$use_gzip = false;
if (!$backup_obj->Execute($task, $filename, $use_gzip))
{
$output = $backup_obj->error;
}
else
{
$output = 'Operation Completed Successfully At: <b>' . date('g:i:s A') . '</b><i> ( Local Server Time )</i>';
}
echo $output;
die();
header ("Location: admin.php");
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ro" lang="ro">

<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>

<body>

............... then layout divs till the end.

The generated .sql file is now more as it should be, but it still contains in front of mysql commands these html tags:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ro" lang="ro">

<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>

<body>

</body>
</html>
Could I get rid of this extra-text?

  4. Re: Please help me   Reply   Report abuse  
Picture of Vagharshak Tozalakyan Vagharshak Tozalakyan - 2008-09-22 16:21:05 - In reply to message 3 from Sin Kronix
Check if something is outputted (without any interaction) in the following files:

includes/connection.inc.php
admin_check_session.php
ws_config.php
includes/$lang.php

  5. Re: Please help me   Reply   Report abuse  
Picture of Sin Kronix Sin Kronix - 2008-09-24 18:30:44 - In reply to message 4 from Vagharshak Tozalakyan
You are absolutely right, that was the cause! :)
Thank you for your great help.
I wish you all the best!