脚本不会写入数据库LAMP

时间:2015-09-28 22:18:12

标签: php mysql lamp

您好我最近安装了linux并安装了灯+ phpmyadmin,这个脚在xampp上运行正常但我使用了win,但是现在它不会执行,我已经在dbconnect.php文件中更改了信息,并且如果我手动插入行,它会正常显示。那么有谁能告诉我问题出在哪里......?

php有问题的脚本:

<?php
include ("dbc.php");
session_start();
    function GetImageExtension($imagetype)
     {
       if(empty($imagetype)) return false;
       switch($imagetype)
       {
           case 'image/bmp': return '.bmp';
           case 'image/gif': return '.gif';
           case 'image/jpeg': return '.jpg';
           case 'image/png': return '.png';
           default: return false;
       }
     }
if (!empty($_FILES["uploadedimage"]["name"])) {
    $file_name=$_FILES["uploadedimage"]["name"];
    $temp_name=$_FILES["uploadedimage"]["tmp_name"];
    $imgtype=$_FILES["uploadedimage"]["type"];
    $ime=$_FILES["ime"];
    $link=$_FILES["link"];
    $ext= GetImageExtension($imgtype);
    $imagename=date("d-m-Y")."-".time().$ext;
    $target_path = "images/".$imagename;
    $postavio=$_SESSION['user_name'];
if(move_uploaded_file($temp_name, $target_path)) {
    $query_upload="INSERT into linkovi ( ime , link , postavio , slika , datum ) VALUES ('".$_POST["ime"]."','".$_POST["link"]."','".$postavio."','".$target_path."','".date("Y-m-d")."')";
    mysql_query($query_upload) or die("error in $query_upload == ----> ".mysql_error()); 
    header("Location:dodaj-film.php?uploaded=1");
}else{
   exit("Error While uploading image on the server");
   header("Location:dodaj-film.php?uploaded=0");
}
}
?>

1 个答案:

答案 0 :(得分:0)

在PHP 5.5中使用mysqli_query()PDO::query()mysql_query已过时

如果这不起作用,请添加此内容并向我们报告错误。

<?php

ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);

include ("dbc.php");
//Rest of your code...