Jump to content

Undefined function?


Guest

Recommended Posts

I get an error saying call to undefined function. Shouldn't move_uploaded_file() work?

(I know I didn't set the size and etc, it's just a practice test) Also, my host's php version is 4.4.9 could that be a problem?

 

<?php
session_start();
include "functions.php";
include "database.php";


if(($_POST['upload'])){
    $uploadname = $_FILES['avatar']['name'];
    $tmp_name = $_FILES['avatar']['tmp_name'];

  if($uploadname){
     echo "...";
    }
   
  else{
     die("Please select a file numb nuts!");
    }

   if($uploadname) {
        $location = "avatars/$name";
        move_uploaded_file($tmp_name,"$location");
          
        $query = mysql_query("UPDATE narutorpg SET imagelocation = '$location' WHERE username = '$name'");
        $die("Your avatar is uploaded. <a href = 'character.php'> home </a>");

      }
}



echo " <form action = '' method = 'POST' enctype = 'multipart/form-data'>
File:<input type = 'file' name = 'avatar'> <input type = 'submit' name = 'upload' Value = 'upload'> 
</form>";





?>

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/221348-undefined-function/
Share on other sites

Either -

 

1)  Your source file is corrupted or contains some encoded characters as part of that line (perhaps you are using a non-English keyboard or you copy/pasted code that had some of the characters encoded), or

 

2) Your web host has disabled that function (the phpinfo() output would list it under disable_functions.)

 

For #1, delete and retype the line and/or copy and paste the code into a completely new file.

 

For #2, check the phpinfo() output and/or check with your web host.

 

Given the that php version that your web host is using is about 4 years out of date, I'll guess this is a free/cheep host and they have probably disabled several functions.

Link to comment
https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1145995
Share on other sites

I posted too soon, it goes into the avatars folder, but doesn't store in the database.

 

<?php
session_start();
include "functions.php";
include "database.php";


if(($_POST['upload'])){
    $uploadname = $_FILES['avatar']['name'];
    $tmp_name = $_FILES['avatar']['tmp_name'];

  if($uploadname){
     echo "...";
    }
   
  else{
     die("Please select a file numb nuts!");
    }

   if($uploadname) {
        [b]$location = "avatars/$uploadname";[/b]
        move_uploaded_file($tmp_name,"$location");
          
        $query = mysql_query("UPDATE narutorpg SET imagelocation = '$location' WHERE username = '$name'") . mysql_error();
        $die("Your avatar is uploaded. <a href = 'character.php'> home </a>");

      }
}



echo " <form action = '' method = 'POST' enctype = 'multipart/form-data'>
File:<input type = 'file' name = 'avatar'> <input type = 'submit' name = 'upload' Value = 'upload'> 
</form>";



?>

 

 

This was the change I made:$location = "avatars/$uploadname";

 

 

Link to comment
https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1146013
Share on other sites

If you actually look at the line where the error is being reported, you will see it is the following code, where you have a $ in front of the die() statement -

 $die("Your avatar is uploaded. <a href = 'character.php'> home </a>");

 

It always helps to post actual errors, like someone had to ask you to do.

Link to comment
https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1146014
Share on other sites

If you actually look at the line where the error is being reported, you will see it is the following code, where you have a $ in front of the die() statement -

 $die("Your avatar is uploaded. <a href = 'character.php'> home </a>");

 

It always helps to post actual errors, like someone had to ask you to do.

 

Oh i see, I'll do that from now on, thanks  :P

Link to comment
https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1146016
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.