Guest Posted December 11, 2010 Share Posted December 11, 2010 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 More sharing options...
trq Posted December 11, 2010 Share Posted December 11, 2010 Your host may have file uploads disabled. Check phpinfo. Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1145919 Share on other sites More sharing options...
Guest Posted December 11, 2010 Share Posted December 11, 2010 Your host may have file uploads disabled. Check phpinfo. Yeah it's on, I don't know what could be the problem. Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1145923 Share on other sites More sharing options...
doddsey_65 Posted December 11, 2010 Share Posted December 11, 2010 on a side note move_uploaded_file was added since php version 4.0.3. Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1145924 Share on other sites More sharing options...
BlueSkyIS Posted December 11, 2010 Share Posted December 11, 2010 maybe no help, but could you post the error as it appears? Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1145932 Share on other sites More sharing options...
Guest Posted December 11, 2010 Share Posted December 11, 2010 maybe no help, but could you post the error as it appears? it's just the normal php call to undefined function and says the line Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1145939 Share on other sites More sharing options...
Guest Posted December 12, 2010 Share Posted December 12, 2010 Still nothing Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1145992 Share on other sites More sharing options...
PFMaBiSmAd Posted December 12, 2010 Share Posted December 12, 2010 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 More sharing options...
Guest Posted December 12, 2010 Share Posted December 12, 2010 php info is fine, no disabled functions. and I'll rewrite it.. edit: Still getting Fatal error: Call to undefined function: () in /home2/producy2/public_html/arzania/upload.php on line 24 Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1145998 Share on other sites More sharing options...
Guest Posted December 12, 2010 Share Posted December 12, 2010 It works, yet I get a "fatal error" that's weird.. Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1146007 Share on other sites More sharing options...
Pikachu2000 Posted December 12, 2010 Share Posted December 12, 2010 Post your newly revised code . . . Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1146008 Share on other sites More sharing options...
Guest Posted December 12, 2010 Share Posted December 12, 2010 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 More sharing options...
PFMaBiSmAd Posted December 12, 2010 Share Posted December 12, 2010 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 More sharing options...
Guest Posted December 12, 2010 Share Posted December 12, 2010 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 Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1146016 Share on other sites More sharing options...
BlueSkyIS Posted December 12, 2010 Share Posted December 12, 2010 maybe no help, but could you post the error as it appears? Hey, whaddya know, it would have helped! Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1146051 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.