Jump to content

Undefined function?


Spring

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
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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.