Query not being executed

Posted by user2385241 on Stack Overflow See other posts from Stack Overflow or by user2385241
Published on 2013-10-28T15:50:17Z Indexed on 2013/10/28 15:53 UTC
Read the original article Hit count: 162

Filed under:
|

I'm trying to create a script that allows me to upload an image, grab the details sent through inputs (a description and chosen project number) and insert this information into a table. I currently have this function:

public function NewEntry() {

        $connect = new dbconnect;


            $_SESSION['rnd'] = substr(number_format(time() * rand(),0,'',''),0,15);

            $allowedExts     = array("gif", "jpeg", "jpg", "png");
            $size            = $_FILES["file"]["size"];

            $path            = $_FILES["file"]["name"];
            $extension       = pathinfo($path, PATHINFO_EXTENSION);
            $pr = $_POST['project'];
            $cl = $_POST['changelog'];

            $file            = $_SESSION['rnd'] . "." . $extension;


            if (in_array($extension, $allowedExts) && $size < 200000000) {
                if ($_FILES["file"]["error"] == 0) {
                    if (!file_exists("../uploads/" . $_SESSION['rnd'])) {
                        move_uploaded_file($_FILES["file"]["tmp_name"], "../uploads/" . $_SESSION['rnd'] . "." . $extension);
                    }
                }    
            } else {
                echo "File validation failed.";
            }

            $row = $connect->queryExecute("INSERT INTO entries(project,file,changelog)VALUES($pr,$file,$cl)");


        header('location:http://www.example.com/admin');

    }

When the form is posted the function runs, the image uploads but the query isn't executed. The dbconnect class isn't at fault as it's untampered and has been used in past projects. The error logs don't give any output and no MySQL errors show. Any ideas?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql