Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases

Parse error for php database

I'm trying to upload an image to my locally created database with phpmyadmin. When I try to upload it using Postman I get a parse error and some other ones. I know it's a permission problem, but I'm struggling to find a way to assign the permissions. Also could anyone let me know if there are problems I have to deal with?

<?php



 if(isset($_POST["encoded_string"])){



    $encoded_string = $_POST["encoded_string"];

    $image_name = $_POST["image_name"];



    $decoded_string = base64_decode($encoded_string);



    $path = 'MyUploadImages/'.$image_name;



    $file = fopen($path, 'wb');



    $is_written = fwrite($file, $decoded_string);

    fclose($file);



    if($is_written > 0) {



        $connection = mysqli_connect('localhost', 'root', '','employees101');

        $query = "INSERT INTO photos(name,path) values('$image_name','$path');";



        $result = mysqli_query($connection, $query) ;



        if($result){

            echo "success";

        }else{

            echo "failed";

        }



        mysqli_close($connection);

    }

 }

?>