0

My mysqli_query isn't working but no error is displayed. Can anyone see what's wrong?

<?php

    include 'includes/config.php';
    include_once 'includes/database.php';

    if(@$_POST['submit']){
        $tempdir=@$_FILES['picture']['tmp_name'];
        $file=@$_FILES['picture']['name'];
        move_uploaded_file($tempdir, "../upload/".$file );
        echo $insert="insert into ararticles set title ='".@$_POST['title']."',text'".@$_POST['text']."',date'".@$_POST['date']."',article_pic='".$file."'";
        $run=mysqli_query($connection,$insert);
        if($run){
            header("location:varticle.php");
        }
    }

Config file

define("DB_SERVER","localhost");
define("DB_USERNAME","root");
define("DB_PASS","");
define("DB_NAME","firstfullwebsite");

Database file

$connection = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASS,DB_NAME);
Peter Gordon
  • 1,075
  • 1
  • 18
  • 38
  • Have you checked error_log for error-messages from PHP? Not all PHP errors will appear as messages in the browser window. – Brian A. Henning Jun 20 '16 at 16:36
  • Have you tried `echo $insert;` to see what SQL is actually being sent? You're not sanitizing/preparing anything so you're wide open to [SQL injection](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) – Machavity Jun 20 '16 at 16:36
  • i have tried to echo $insert but it does not works out for me it is working properly – Himanshu Bishnoi Jun 20 '16 at 16:41
  • `insert into ararticles`. Could it be a simple spelling mistake? – Aroic Jun 20 '16 at 16:54
  • 1
    Your repeated use of the `@` error-suppression operator might well have hidden some error messages from you. Rewrite your code without it and see what happens. – Darwin von Corax Jun 20 '16 at 17:32

0 Answers0