3
<?php
    require('config.php');
    if(isset($_POST['upload'])){
        if(getimagesize($_FILES['image']['tmp_name'])==FALSE){
            $first_ul_status = "Please select an image";
        }else{
            $image = addslashes($_FILES['image']['tmp_name']);
            $name = addslashes($_FILES['image']['name']);
            $image = file_get_contents($image);
            $image = base64_encode($image);
            saveimage($name,$image);
        }
        function saveimage($name,$image){
            $first_ul_query = "UPDATE `users` SET `Photo Name`='$name',`Photo`='$image' WHERE `ID`='$UserSession'";
            $first_ul_result = mysql_query($first_ul_query);
            if($first_ul_result){
                $first_ul_status = "Image uploaded";
            }else{
                $first_ul_status = "Image not uploaded";
            }
        }
    }

?>

I just got this code from the web I don't remember where I got this code. But I have the video tutorial of this thats why I have this code right now. Last time this code is working to me but now my problem is that I cant call the saveimage($name,$image);

Can somebody help me out there? Thanks in advance pros :)

2 Answers 2

3

Be sure your saveimage() function is declared when call that. Put the function forward in your code as you call!

Sign up to request clarification or add additional context in comments.

Comments

3

You added function within the script..I have fixed it..the function is out of the code now. It is an independent snippet now, you can call it now..

<?php
require('config.php');


 function saveimage($name,$image){
        $first_ul_query = "UPDATE `users` SET `Photo Name`='$name',`Photo`='$image' WHERE `ID`='$UserSession'";
        $first_ul_result = mysql_query($first_ul_query);
        if($first_ul_result){
            $first_ul_status = "Image uploaded";
        }else{
            $first_ul_status = "Image not uploaded";
        }
    }


if(isset($_POST['upload'])){
    if(getimagesize($_FILES['image']['tmp_name'])==FALSE){
        $first_ul_status = "Please select an image";
    }else{
        $image = addslashes($_FILES['image']['tmp_name']);
        $name = addslashes($_FILES['image']['name']);
        $image = file_get_contents($image);
        $image = base64_encode($image);
        saveimage($name,$image);
    }

}


 ?>

7 Comments

still cant Fatal error: Call to undefined function saveimage()
a quick fix...replace the saveimage($name,$image); with the code within the function.. try then.
still cant. i tried to remove and separate but nothing happen, still same error
what the error..if you remove saveimage.,,it wont work
no error but can't save if i'll remove the saveimage()
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.