php.de

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

 
 
LinkBack (1) Themen-Optionen Thema bewerten
Alt 29.07.2008, 16:20  
Neuer Benutzer
 
Registriert seit: 29.07.2008
Beiträge: 5
funnx befindet sich auf einem aufstrebenden Ast
Standard Call to a member function ... on a non-object

Hallo, ich bin nicht gerade ein fortgeschrittener PHP-Coder, daher ist meine Frage hier wohl am besten aufgehoben.


Was muss ich ändern, damit der unten beschriebene Fehler nicht auftaucht?
Ich habe eine Funktions und einen Aufruf:

PHP-Code:
if(preg_match("/upload/",getenv('QUERY_STRING')))
{
 
$upload $webdav->file_upload
           array(
"user"=>$user"tmpfile"=>$_FILES['file']['tmp_name'], 
                 
"file" => $_FILES['file']['name']));
 print(
"$upload");

und der Aufruf

PHP-Code:
print("
       <h1>File-Upload</h1>
       <form action=\"index.php?method=file\" method=\"post\">
       <input type=\"file\" name=\"ordner\">
       <input type=\"submit\" value=\"File hochladen\">
       </form>
"
); 
Da erscheint aber der Fehler:
Zitat:
Fatal error: Call to a member function file_upload() on a non-object in D:\xampp\htdocs\backup3\test.php on line ..
Das Script gibt's hier:
HTMLWorld - PHP-Beispiele: WebDav-Client mit PHP

Geändert von funnx (29.07.2008 um 16:22 Uhr).
funnx ist offline  
Sponsor Mitteilung
PHP Code Flüsterer

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

Alt 29.07.2008, 16:28  
Supermoderator HD
 
Benutzerbild von Manko10
 
Registriert seit: 16.03.2008
Beiträge: 8.709
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

Enthält $webdav wirklich ein Objekt?
Manko10 ist offline  
Alt 29.07.2008, 16:53  
Neuer Benutzer
 
Registriert seit: 29.07.2008
Beiträge: 5
funnx befindet sich auf einem aufstrebenden Ast
Standard

Den Quellcode sieht man hier, den habe ich einfach beinahe komplett übernommen:

HTMLWorld - PHP-Beispiele: WebDav-Client mit PHP

Zitat:
Enthält $webdav wirklich ein Objekt?
sry, aber solche gegenfragen verstehe ich noch nicht

PHP-Code:
<?php

function __connect$param = array() )
{
 
$fp fsockopen($server$port$errno$errstr$lifetime);
 if(!
$fp)
 {
  return 
"$errno -> $errstr<br>";
 }
 else
 {
  
fwrite($fp$param['content']);
  
$output_array = array();
  while(!
feof($fp))
  {
   
array_push($output_array,fgets($fp));
  }
  
fclose($fp);
  return 
$output_array;
 }
}
    

function 
check_webdav$param=array() )
{
 
$content "HEAD / HTTP/1.1 \r\n";
 
$content .= "Host: $this->server \r\n";
 
$content .= "Connection: Close\r\n";
 
$content .= "\r\n";
 
$output $this->__connect( array('content'=>$content) );

 foreach(
$output as $line)
 {
  if( 
preg_match("/Server:/",$line) )
  {
   if( !
preg_match("/DAV*/",$line) )
   {
    return 
"1";
   }
  }
 }
}


function 
show_content$param=array() )
{
 
$user $param['user'];

 
$content "PROPFIND /files/$user/ HTTP/1.1 \r\n";
 
$content .= "Host: $this->server \r\n";
 
$content .= "Depth: 1\r\n";
 
$content .= "Content-Type: text/xml\r\n";
 
$content .= "Connection:close\r\n";
 
$content .= "Content-Length: 0\r\n";
 
$content .= "\r\n";
 
$content .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
 
$content .= "<D:propfind xmlns:D=\"DAV:\">\r\n";
 
$content .= "<D:allprop/>\r\n";
 
$content .= "</D:propfind>\r\n";

 
$output $this->__connect( array('content'=>$content) );
 
array_pop($output);
 
$key array_search("\r\n",$output);
 
$output array_slice($output,($key+1));
}

function 
file_upload$param = array() )
{
 
$user $param['user'];
 
$tmp_filename $param['tmpfile'];
 
$filename $param['file'];

 if(
copy($tmp_filename"D:/Webdav/" $user ."/" $filename) )
 {
  
$content "<script type=text/javascript>
  alert(\"Datei $filename wurde hochgeladen\");
  document.location.href=\"index.php\";
 </script>"
;
 }
 else
 {
  
$content "<script type=text/javascript>
  alert(\"Datei $filename konnte nicht hochgeladen werden\");
  document.location.href=\"index.php\";
 </script>"
;
 }
 return 
$content;
}


function 
delete_file$param = array() )
{
 
$query_string $param['query_string'];
 
$query_param split("&",$query_string);

 
$filename split("=",$query_param[1]);
 
$file_tmp str_replace("%3CD:href%3E","",$filename[1]);
 
$file str_replace("%3C/D:href%3E","",$file_tmp);

 
$file_param pathinfo($file);
 
$path $file_param['dirname'] . "/";
 
$file $file_param['basename'];

 
$content "DELETE $path/$file HTTP/1.1 \r\n";
 
$content .= "Host: $this->server \r\n";
 
$content .= "Connection: Close\r\n";
 
$content .= "Content-length:0\r\n";
 
$content .= "Destroy:NoUndelete\r\n";
 
$content .= "\r\n";

 
$output $this->__connect( array('content'=>$content) );

 if(
preg_match("/204/",$output[0]))
 {
  
$content "<script type=text/javascript>
  alert('Datei $file wurde gelöscht');
  document.location.href=\"index.php\";
 </script>"
;
 }
 else
 {
  
$content "<script type=text/javascript>
  alert('Datei $file konnte nicht gelöscht werden');
  document.location.href=\"index.php\";
 </script>"
;
 }
 return 
$content;
}

function 
create_new_folder$param = array() )
{
 
$user $param['user'];
 
$folder $param['folder'];

 
$content "MKCOL /files/$user/$folder HTTP/1.1 \r\n";
 
$content .= "Host: $this->server \r\n";
 
$content .= "Connection: Close\r\n";
 
$content .= "\r\n";

 
$output $this->__connect( array('content'=>$content) );
 if(
preg_match("/201/",$output[0]))
 {
  
$content "<script type=text/javascript>
  alert('Ordner $folder wurde angelegt');
  document.location.href=\"index.php\";
 </script>"
;
 }
 else
 {
  
$content "<script type=text/javascript>
  alert('Der Ordner $folder konnte nicht angelegt werden.');
  document.location.href=\"index.php\";
 </script>"
;
 }
 return 
$content;
}

print(
"
       <h1>File-Upload</h1>
       <form action=\"test.php?method=file\" method=\"post\">
       <input type=\"file\" name=\"ordner\">
       <input type=\"submit\" value=\"File hochladen\">
       </form>
"
);


if(
preg_match("/upload/",getenv('QUERY_STRING')))
{
 
$upload $webdav->file_upload
           array(
"user"=>$user"tmpfile"=>$_FILES['file']['tmp_name'], 
                 
"file" => $_FILES['file']['name']));
 print(
"$upload");
}

Geändert von funnx (29.07.2008 um 16:56 Uhr).
funnx ist offline  
Alt 29.07.2008, 16:55  
Moderator
 
Benutzerbild von cycap
 
Registriert seit: 13.02.2008
Beiträge: 6.816
PHP-Kenntnisse:
Fortgeschritten
cycap ist einfach richtig nettcycap ist einfach richtig nettcycap ist einfach richtig nettcycap ist einfach richtig nettcycap ist einfach richtig nett
Standard

Zitat:
Zitat von funnx Beitrag anzeigen
sry, aber solche gegenfragen verstehe ich noch nicht
var_dump($webdav);

an der Fehlerstelle sagt dir was $webdav ist und enthält
cycap ist offline  
Alt 29.07.2008, 17:02  
Neuer Benutzer
 
Registriert seit: 29.07.2008
Beiträge: 5
funnx befindet sich auf einem aufstrebenden Ast
Standard

lol, ich verstehe die Welt nicht mehr:

also var_dump($webdav); liefert mir: NULL

aber die Fehleranzeige ist weg, nachdem ich zwei vorhergehende Funktionen gelöscht habe (Ordner anlegen und Datei löschen).

Aber mein xampp hat mir eben die Fehlerzeile angezeoigt, wo die upload-Funktion war.

funnx ist offline  
Alt 29.07.2008, 18:02  
da schreibt der ElePHPant
 
Benutzerbild von Flor1an
 
Registriert seit: 18.06.2008
Beiträge: 8.903
PHP-Kenntnisse:
Fortgeschritten
Flor1an ist ein wunderbarer AnblickFlor1an ist ein wunderbarer AnblickFlor1an ist ein wunderbarer AnblickFlor1an ist ein wunderbarer AnblickFlor1an ist ein wunderbarer AnblickFlor1an ist ein wunderbarer AnblickFlor1an ist ein wunderbarer Anblick
Standard

Dann fehlt irgendwo wohl $webdav = new XXX(); Je nachdem was du halt für eine Klasse nutzt.
Flor1an ist offline  
Alt 29.07.2008, 18:08  
moderatives Dielektrikum
 
Benutzerbild von nikosch
 
Registriert seit: 21.05.2008
Beiträge: 35.988
PHP-Kenntnisse:
Fortgeschritten
nikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunft
Standard

Schreib mal error_reporting (E_ALL| E_STRICT); in die zweite Zeile.
__________________
--
One pixel is still too big. Please make it smaller. ASAP.

Initiative Mittelstand.
Die wichtigste Gestaltungsregel im Screendesign ist Pi mal Daumen des Arbeitgebers.
--
nikosch ist gerade online  
 


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

LinkBacks (?)
LinkBack to this Thread: http://www.php.de/php-tipps-2008/46351-call-member-function-non-object.html
Erstellt von For Type Datum
Metacrawler - Die Metasuchmaschine. This thread Refback 27.10.2008 10:07

Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
Fatal error: Call to a member function on a non-object tweek PHP Tipps 2008 13 25.06.2008 12:56
Fatal error: Call to a member function on a non-object atom-dragon PHP Tipps 2007 20 02.12.2007 22:22
Call to a member function on a non-object Riks PHP Tipps 2007 20 10.02.2007 22:59
Fatal error: Call to undefined function mail() PHP Tipps 2005-2 16 04.07.2005 13:24
Problem Call to a member function on a non-object PHP Tipps 2005 5 24.05.2005 19:14
Call to a member function on a non-object PHP Tipps 2005 12 24.05.2005 04:06
Fatal error: Call to a member function on a non-object PHP Tipps 2005 7 13.04.2005 07:24
update auf php 5.0.4 robo47 Server, Hosting und Workstations 6 10.04.2005 19:00
Fatal error: Call to a member function on a non-object PHP Tipps 2005 15 04.02.2005 13:02
Fatal error: Call to undefined function: imagecreatefromjpeg DannyD PHP-Fortgeschrittene 10 05.12.2004 21:59
Call to a member function on a non-object --&amp;gt; WARUM ? PHP Tipps 2004-2 4 25.11.2004 20:16
call to undefined function mail() <- funktionierte bis ge Promaetheus PHP Tipps 2004 9 07.10.2004 11:39
[Erledigt] Call to undefined function highlight() PHP Tipps 2004 1 07.09.2004 09:31
[Erledigt] Call to undefined function mysql_connect() Datenbanken 4 24.08.2004 22:04
[Erledigt] Fatal error: Call to undefined function:... PHP Tipps 2004 8 27.06.2004 12:56

Besucher kamen über folgende Suchanfragen bei Google auf diese Seite
call to a member function on a non-object, call to a member function, call to a member function on a non-object in, call to a member function fetchall() on a non-object, call to a member function attributes() on a non-object, php call to a member function on a non-object, call to a member function attributes() on a non-object in, call to a member function fetchall() on a non-object in, call to a member function attributes(), call to a member function on a non-object php, call to a member function get() on a non-object, call to a member function assign() on a non-object, call to a member function assign(), call to a member function format() on a non-object, php call to a member function, call to a member function assign() on a non-object in, call to a member function get() on a non-object in, \call to a member function\ \on a non-object\, fatal error: call to a member function fetchall() on a non-object in, call to a member function format()

Alle Zeitangaben in WEZ +2. Es ist jetzt 16:47 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