php.de

Zurück   php.de > Webentwicklung > PHP Einsteiger > PHP Tipps 2009

 
 
LinkBack Themen-Optionen Thema bewerten
Alt 05.01.2009, 01:44  
Neuer Benutzer
 
Registriert seit: 29.11.2008
Beiträge: 10
SilferSurver befindet sich auf einem aufstrebenden Ast
Standard [Erledigt] Undefined variable Fehler

Hallo!

henge jetzt schon einige stunden über dem script ! Ich find einfach die Fehler nicht! Könnte mir bitte da jemand helfen? Ich dreh noch durch!

Folgendes ich bekomm folgende Fehler wenn ich das Script ausführe:

Notice: Undefined index: PATH_TRANSLATED in /var/www/web3/html/backup/hms_backup.php on line 151

Notice: Undefined variable: newfile in /var/www/web3/html/backup/hms_backup.php on line 43

Notice: Undefined variable: i in /var/www/web3/html/backup/hms_backup.php on line 47 und

Notice: Undefined variable: message in /var/www/web3/html/backup/hms_backup.php on line 95

Nun der CODE:

PHP-Code:
<?php
error_reporting
(E_ALL); ini_set('display_errors'1); // Falls Fehler vorhanden Debugen!


  
$dbhost        'localhost';  // MySQL Server
  
$dbuser        '';      // Username 
  
$dbpass        '';    // Passwort
  
$dbname        '';      // Datenbankname

  
$use_gzip      'yes';        // file packen in.gz yes or no

  
$remove_file   'yes';        // File löschen nach dem senden

  
$use_email     'yes';          // Set to 'yes' if you want the backup to be sent throug email. Fill out next 3 lines.
  
$send_to       '';   // E-mail to send the mail to
  
$send_from     'server_email'// E-mail the mail comes from
  
$subject       "MySQL Database ($dbname) Backup - " date("j F Y"); // Subject in the email to be sent.

  
$use_ftp       'yes'// Do you want this database backup uploaded to an ftp server? Fill out the next 4 lines
  
$ftp_server    '';   // FTP hostname
  
$ftp_user_name '';   // FTP username
  
$ftp_user_pass '';   // FTP password
  
$ftp_path      "/";  // This is the path to upload on your ftp server!

  
$echo_status 'yes';   // Set to 'no' if the script should work silently (no output will be sent to the screen)


# You probably don't need to edit below this line....
#-------------------------------------------------------------------------------

  
$db mysql_connect("$dbhost","$dbuser","$dbpass");
    
mysql_select_db("$dbname",$db);

  
$path make_dir();
  
  if (
$echo_status == 'yes') {
    print 
"Dumpfile will be written to $path<br>";
  }

  
$result mysql_query("show tables from $dbname");
  
  while (list(
$table) = mysql_fetch_row($result)) {
    
$newfile .= get_def($table);              
    
$newfile .= "\n\n";
    
$newfile .= get_content($table);
    
$newfile .= "\n\n";
    
$i++;
    if (
$echo_status == 'yes') {
      print 
"Dumped table $table<br>";
    }
  }

    
$file_name $dbname "-" date("Ymd-Hi") . ".sql";
    
$file_path $path $file_name;

  if (
$use_gzip == "yes") {
    
$file_name .= ".gz";
    
$file_path .= ".gz";
    
$zp gzopen($file_path"wb9");
    
gzwrite($zp,$newfile);
    
gzclose($zp);

    if (
$echo_status == 'yes') {
      print 
"<br>Gzip-file is created...<br>";
    }
  } else {
    
$fp fopen($file_path"w");
    
fwrite($fp$newfile);
    
fclose($fp);

    if (
$echo_status == 'yes') {
      print 
"<br>SQL-file is created...<br>";
    }
  }

  if (
$use_email == 'yes') {
    
$fileatt_type filetype($file_path);
  
    
$headers "From: $send_from";
  
    
// Read the file to be attached ('rb' = read binary)
    
$fp fopen($file_path,'rb');
    
$data fread($fp,filesize($file_path));
    
fclose($fp);
  
    
// Generate a boundary string
    
$semi_rand md5(time());
    
$mime_boundary "==Multipart_Boundary_x{$semi_rand}x";
  
    
// Add the headers for a file attachment
    
$headers .= "\nMIME-Version: 1.0\n" ."Content-Type: multipart/mixed;\n" ." boundary=\"{$mime_boundary}\"";
  
    
// Add a multipart boundary above the plain message
    
$message "This is a multi-part message in MIME format.\n\n" ."--{$mime_boundary}\n" ."Content-Type: text/plain; charset=\"iso-8859-1\"\n" ."Content-Transfer-Encoding: 7bit\n\n" .
    
$message "\n\n";
  
    
// Base64 encode the file data
    
$data chunk_split(base64_encode($data));
  
    
// Add file attachment to the message
    
$message .= "--{$mime_boundary}\n" ."Content-Type: {$fileatt_type};\n" ." name=\"{$file_name}\"\n" ."Content-Disposition: attachment;\n" ." filename=\"{$file_name}\"\n" ."Content-Transfer-Encoding: base64\n\n" .
    
$data "\n\n" ."--{$mime_boundary}--\n";
  
    
// Send the message
    
$ok = @mail($send_to$subject$message$headers);
    
    if (
$echo_status == 'yes') {
      print 
"<br>Mail is sent...<br>";
    }
  }
  
  if (
$use_ftp == 'yes') {
    if (
$use_gzip == 'yes') {
      
$mode FTP_BINARY;
    } else {
      
$mode FTP_ASCII;
    }
    
$ftp_id       ftp_connect($ftp_server);
    
$login_result ftp_login($ftp_id$ftp_user_name$ftp_user_pass);
    
$upload       ftp_put($ftp_id$ftp_path $file_name$file_path$mode);
    
ftp_close($ftp_id);

    if (
$echo_status == 'yes') {
      print 
"<br>Backup is uploaded to $ftp_user_name@$ftp_server...<br>";
    }
  }

  if (
$remove_file == "yes") {
    
unlink($file_name);
    if (
$echo_status == 'yes') {
      print 
"<br>File is deleted...<br>";
    }
  }

  if (
$echo_status == 'yes') {
    print 
"<br>I am done!<br>";
  }


  function 
make_dir() {
    
$page split("/"getenv('SCRIPT_NAME'));
    
$n count($page)-1;
    
$page $page[$n];
    
$page split("\."$page2);
    
$extension $page[1];
    
$page $page[0];
    
$script     "$page.$extension";
    
$base_url     "http://".$_SERVER['SERVER_NAME'];
    
$directory     $_SERVER['PHP_SELF'];
    
$url_base "$base_url$directory";
    
$url_base ereg_replace("$script"''"$_SERVER[PATH_TRANSLATED]");

    
$path $url_base;

    return 
$path;
  }

  function 
get_def($table) {
    
$def "";
    
$def .= "DROP TABLE IF EXISTS $table;\n";
    
$def .= "CREATE TABLE $table (\n";
    
$result mysql_query("SHOW FIELDS FROM $table") or die("Table $table not existing in database");
    while(
$row mysql_fetch_array($result)) {
      
$def .= "    $row[Field] $row[Type]";
      if (
$row["Default"] != ""$def .= " DEFAULT '$row[Default]'";
      if (
$row["Null"] != "YES"$def .= " NOT NULL";
      if (
$row["Extra"] != ""$def .= " $row[Extra]";
      
$def .= ",\n";
    }
    
$def ereg_replace(",\n$",""$def);
    
$result mysql_query("SHOW KEYS FROM $table");
    while(
$row mysql_fetch_array($result)) {
      
$kname=$row["Key_name"];
      if((
$kname != "PRIMARY") && ($row["Non_unique"] == 0)) $kname="UNIQUE|$kname";
      if(!isset(
$index[$kname])) $index[$kname] = array();
      
$index[$kname][] = $row["Column_name"];
    }
    while(list(
$x$columns) = @each($index)) {
      
$def .= ",\n";
      if(
$x == "PRIMARY"$def .= "   PRIMARY KEY (" implode($columns", ") . ")";
      else if (
substr($x,0,6) == "UNIQUE"$def .= "   UNIQUE ".substr($x,7)." (" implode($columns", ") . ")";
      else 
$def .= "   KEY $x (" implode($columns", ") . ")";
    }
    
$def .= "\n);";
    return (
stripslashes($def));
  }

  function 
get_content($table) {
    
$content="";
    
$result mysql_query("SELECT * FROM $table");
    while(
$row mysql_fetch_row($result)) {
      
$insert "INSERT INTO $table VALUES (";
      for(
$j=0$j<mysql_num_fields($result);$j++) {
        if(!isset(
$row[$j])) $insert .= "NULL,";
        else if(
$row[$j] != ""$insert .= "'".addslashes($row[$j])."',";
        else 
$insert .= "'',";
      }
      
$insert ereg_replace(",$","",$insert);
      
$insert .= ");\n";
      
$content .= $insert;
    }
    return 
$content;
  }

  
/* Changelog
  
     Version 1.0 - August 15th, 2003
     ===============================
     Created this beautiful script...

  */
 
?>
Ich bin euch zu tiefst dankbar wenn mir da jemand weiterhelfen könnte!

Gruss

Silfer
SilferSurver ist offline  
Sponsor Mitteilung
PHP Code Flüsterer

Registriert seit: 21.08.2005
Beiträge: 4682
PHP-Kenntnisse:
Fortgeschritten

Alt 05.01.2009, 01:59  
Supermoderator HD
 
Benutzerbild von Manko10
 
Registriert seit: 16.03.2008
Beiträge: 8.425
PHP-Kenntnisse:
Fortgeschritten
Manko10 hat eine strahlende ZukunftManko10 hat eine strahlende ZukunftManko10 hat eine strahlende ZukunftManko10 hat eine strahlende ZukunftManko10 hat eine strahlende ZukunftManko10 hat eine strahlende ZukunftManko10 hat eine strahlende ZukunftManko10 hat eine strahlende ZukunftManko10 hat eine strahlende ZukunftManko10 hat eine strahlende ZukunftManko10 hat eine strahlende Zukunft
Standard

PHP-Code:
$newfile .= get_def($table); 
Beim ersten Mal existiert $newfile noch nicht. Du musst also ein $newfiile = ''; davorsetzen.

PHP-Code:
$i++; 
Auch hier wieder: $i existiert zunächst nicht, also ist es auch Unfug, es zu inkrementieren. Usw. usf. Bitte Grundlagen lernen!

Was soll eigentlich so ein Kram?
PHP-Code:
$url_base ereg_replace("$script"''"$_SERVER[PATH_TRANSLATED]"); 
Wieso setzt du die Variablen in Quotes?
__________________
Refining Linux Advent Calendar series “24 Outstanding ZSH Gems
Manko10 ist offline  
Alt 05.01.2009, 02:07  
Neuer Benutzer
 
Registriert seit: 29.11.2008
Beiträge: 10
SilferSurver befindet sich auf einem aufstrebenden Ast
Standard

Zitat:
Zitat von Manko10 Beitrag anzeigen
PHP-Code:
$newfile .= get_def($table); 
Beim ersten Mal existiert $newfile noch nicht. Du musst also ein $newfiile = ''; davorsetzen.

PHP-Code:
$i++; 
Auch hier wieder: $i existiert zunächst nicht, also ist es auch Unfug, es zu inkrementieren. Usw. usf. Bitte Grundlagen lernen!

Was soll eigentlich so ein Kram?
PHP-Code:
$url_base ereg_replace("$script"''"$_SERVER[PATH_TRANSLATED]"); 
Wieso setzt du die Variablen in Quotes?
Danke erstmal für die schnelle Hilfe!

Das script ist nicht von mir!

Ich werd das alles mal ändern!

Gruss Silfer
SilferSurver ist offline  
 


Themen-Optionen
Thema bewerten
Thema bewerten:

Forumregeln
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are an
Gehe zu

Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
php datei löschen djscaleo PHP Tipps 2008 21 14.11.2008 15:47
thumbnails erstellen dom PHP Tipps 2008 39 21.07.2008 21:28
Daten mit Masql ausgeben ohne while PHP Tipps 2005 25 22.05.2005 01:25
[Erledigt] Problem mit Scirts Gbook + Seitenanzeiger PHP Tipps 2005 12 09.05.2005 15:27
Fehlermeldung undefined index: 14 Niedi PHP Tipps 2005 2 22.04.2005 11:40
Fehler beim Update PHP Tipps 2005 1 21.04.2005 19:08
Fehlermeldung - aber kein fehler... Tschuu HTML, Usability und Barrierefreiheit 16 14.03.2005 15:56
Variable in einer Variable Beatbox PHP Tipps 2005 7 15.01.2005 15:55
Warum wird Variable nicht übergeben??? Anuschka PHP Tipps 2005 2 06.01.2005 13:22
Undefined variable duerov PHP Tipps 2004 5 07.10.2004 12:10
Undefined variable offlin aber nicht online PHP Tipps 2004 2 24.09.2004 14:58
[Erledigt] Notice: Undefined variable und wie man das wegbekommt PHP-Fortgeschrittene 2 19.08.2004 11:50
[Erledigt] Fehler im Eingabe Formular PHP Tipps 2004 10 05.08.2004 21:04
Undefined variable: ... PHP Tipps 2004 3 22.07.2004 14:08
undefined Variable trotz global_register on PHP Tipps 2004 4 27.06.2004 16:51

Besucher kamen über folgende Suchanfragen bei Google auf diese Seite
undefined variable, http://www.php.de/php-tipps-2009/50328-erledigt-undefined-variable-fehler.html, notice: undefined variable: row in, notice: undefined variable: result in, undefined variable:, php undefined variable, undefined index: path_translated, if($fehler != \\) index.php undefined variable, notice: undefined variable: row, notice: undefined variable: page in, undefined variable fehlermeldung, undefined variable: _server, undefined variable: row, variable fehler, notice: undefined variable: sql, notice: undefined variable: results in, notice: undefined variable: rows in, php notice: undefined variable: result in, notice: undefined variable: output, notice undefined variable result in

Alle Zeitangaben in WEZ +1. Es ist jetzt 13:44 Uhr.




Powered by vBulletin® Version 3.7.2 (Deutsch)
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Aprilia-Forum, Aquaristik-Forum, Liebeskummer-Forum, Zierfisch-Forum, Geizkragen-Forum