Spring 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>"; ?> Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1145919 Share on other sites More sharing options...
Spring Posted December 11, 2010 Author 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. Quote 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. Quote 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? Quote Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1145932 Share on other sites More sharing options...
Spring Posted December 11, 2010 Author 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 Quote Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1145939 Share on other sites More sharing options...
Spring Posted December 12, 2010 Author Share Posted December 12, 2010 Still nothing Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1145995 Share on other sites More sharing options...
Spring Posted December 12, 2010 Author 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 Quote Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1145998 Share on other sites More sharing options...
Spring Posted December 12, 2010 Author Share Posted December 12, 2010 It works, yet I get a "fatal error" that's weird.. Quote 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 . . . Quote Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1146008 Share on other sites More sharing options...
Spring Posted December 12, 2010 Author 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"; Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1146014 Share on other sites More sharing options...
Spring Posted December 12, 2010 Author 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 Quote 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! Quote Link to comment https://forums.phpfreaks.com/topic/221348-undefined-function/#findComment-1146051 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.