Page 1 of 1

Class not initialising? [SOLVED]

Posted: Wed Jul 25, 2007 4:51 am
by mikeeeeeeey
Hi guys,

Can anyone see why this wouldn't be outputting?

The class...

Code: Select all

class myFunctions{

    function myFunctions(){
    }

    function uploadImg($tmp, $name, $client){
	  echo "this doesnt even output";
	  if(!move_uploaded_file($tmp, "press/" . $client . "/images/" . $name)){
	    echo "press/" . $client . "/images/" . $name . " has not been uploaded.<br/>";
	  }else{
	    echo "press/" . $client . "/images/" . $name . " has been uploaded.<br/>";
	  }
    }
	
  }
instantiating the class...

Code: Select all

require('press.class.php');
    $imgs = new myFunctions();
	foreach($_FILES as $imagefile){
	  $name = $imagefile['name'];
	  $tmp  = $imagefile['tmp'];
	  if($imagefile['name'] !== $release){
	    $imgs->uploadImg($tmp, $name, $client);
	  }
	}
Thanks in advance you beautiful people.

Posted: Wed Jul 25, 2007 5:00 am
by volka
Is error_reporting set to E_ALL? display_errors on?
Also try

Code: Select all

echo "if($imagefile['name'] !== $release) { <br />\n";
  if($imagefile['name'] !== $release) {

Posted: Wed Jul 25, 2007 5:07 am
by mikeeeeeeey
Yeah, error_reporting is set to E_ALL and display_errors are turned on.

Its weird as hell! Nothing looks to be wrong with the code...

Also I tried that code volka, chucked a mega mega whitespace error at me :(

Posted: Wed Jul 25, 2007 5:20 am
by volka
mikeeeeeeey wrote:Also I tried that code volka, chucked a mega mega whitespace error at me :(
meaning it doens't print anything meaning the foreach loop is never executed?

Posted: Wed Jul 25, 2007 5:29 am
by mikeeeeeeey
Here's the modified code...

Code: Select all

require('press.class.php');
    $imgs = new myFunctions();
	foreach($_FILES as $imagefile){
	  $name = $imagefile['name'];
	  $tmp  = $imagefile['tmp'];
      echo "if($imagefile['name'] !== $release) { <br />\n"; 
      if($imagefile['name'] !== $release) {
	    $imgs->uploadImg($tmp, $name);
	  }
	}
and here's the error...

Code: Select all

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\projects\pressRoom.php on line 38
if this helps?

Posted: Wed Jul 25, 2007 5:33 am
by volka
Yes, the actual error message usually does.

Code: Select all

echo "if($imagefile[name] !== $release) { <br />\n";

Posted: Wed Jul 25, 2007 6:31 am
by mikeeeeeeey
its back to giving me a blank screen.
I think you're right, the foreach is definately not getting initialised.

Posted: Wed Jul 25, 2007 6:43 am
by volka

Code: Select all

print_r($_FILES);
foreach($_FILES as $imagefile) {