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
mikeeeeeeey
Forum Contributor
Posts: 130 Joined: Mon Jul 03, 2006 4:17 am
Location: Huddersfield, UK
Post
by mikeeeeeeey » Wed Jul 25, 2007 4:51 am
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.
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Wed Jul 25, 2007 5:00 am
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) {
mikeeeeeeey
Forum Contributor
Posts: 130 Joined: Mon Jul 03, 2006 4:17 am
Location: Huddersfield, UK
Post
by mikeeeeeeey » Wed Jul 25, 2007 5:07 am
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
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Wed Jul 25, 2007 5:20 am
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?
mikeeeeeeey
Forum Contributor
Posts: 130 Joined: Mon Jul 03, 2006 4:17 am
Location: Huddersfield, UK
Post
by mikeeeeeeey » Wed Jul 25, 2007 5:29 am
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?
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Wed Jul 25, 2007 5:33 am
Yes, the actual error message usually does.
Code: Select all
echo "if($imagefile[name] !== $release) { <br />\n";
mikeeeeeeey
Forum Contributor
Posts: 130 Joined: Mon Jul 03, 2006 4:17 am
Location: Huddersfield, UK
Post
by mikeeeeeeey » Wed Jul 25, 2007 6:31 am
its back to giving me a blank screen.
I think you're right, the foreach is definately not getting initialised.
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Wed Jul 25, 2007 6:43 am
Code: Select all
print_r($_FILES);
foreach($_FILES as $imagefile) {