Class not initialising? [SOLVED]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mikeeeeeeey
Forum Contributor
Posts: 130
Joined: Mon Jul 03, 2006 4:17 am
Location: Huddersfield, UK

Class not initialising? [SOLVED]

Post 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.
Last edited by mikeeeeeeey on Wed Jul 25, 2007 7:40 am, edited 1 time in total.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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) {
User avatar
mikeeeeeeey
Forum Contributor
Posts: 130
Joined: Mon Jul 03, 2006 4:17 am
Location: Huddersfield, UK

Post 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 :(
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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?
User avatar
mikeeeeeeey
Forum Contributor
Posts: 130
Joined: Mon Jul 03, 2006 4:17 am
Location: Huddersfield, UK

Post 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?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Yes, the actual error message usually does.

Code: Select all

echo "if($imagefile[name] !== $release) { <br />\n";
User avatar
mikeeeeeeey
Forum Contributor
Posts: 130
Joined: Mon Jul 03, 2006 4:17 am
Location: Huddersfield, UK

Post by mikeeeeeeey »

its back to giving me a blank screen.
I think you're right, the foreach is definately not getting initialised.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Code: Select all

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