【问题标题】:Script won't write into database LAMP脚本不会写入数据库 LAMP
【发布时间】:2015-09-28 22:18:12
【问题描述】:

嗨,最近我安装了 linux 并安装了 lamp + phpmyadmin,这个脚本在我使用 win 时在 xampp 上运行良好,但现在它不会执行,我已经更改了 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");
}
}
?>

【问题讨论】:

  • 如果您让我们知道您遇到了什么具体错误,我们会更容易帮助您
  • 我刚刚得到这个文本:在服务器上上传图片时出错

标签: php mysql lamp


【解决方案1】:

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

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

<?php

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

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

【讨论】:

  • 这里是错误代码,如果我猜到了你想要什么错误:) 插入 linkovi (ime,link,postavio,slika,datum) 中的错误 VALUES ('balega','xxx. xxx/','admin','images/30-09-2015-1443623562.jpg','2015-09-30') == ----> p.s.我错误地使用了 x insted 的真实地址,因为它在此处转换为链接
  • 请截屏或复制确切的错误,在你给我的代码中没有。并将它添加到您的答案中。
  • 这个脚本现在可以完美运行了,知道问题出在哪里,脚本中的某些内容发生了更改,而不是恢复了更改,并且它可以正常工作,但无论如何,可能是电脑的问题,很奇怪
猜你喜欢
  • 1970-01-01
  • 2020-01-16
  • 1970-01-01
  • 2020-07-10
  • 2011-11-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-05
相关资源
最近更新 更多