Php 脚本不会写入数据库
您好,最近我安装了linux并安装了lamp+phpmyadmin,当我使用win时,这个脚本在xampp上运行良好,但现在它不会执行,我更改了dbconnect.php文件中的信息,如果我手动插入行,它会正常显示。谁能告诉我问题出在哪里 php问题脚本:Php 脚本不会写入数据库,php,mysql,lamp,Php,Mysql,Lamp,您好,最近我安装了linux并安装了lamp+phpmyadmin,当我使用win时,这个脚本在xampp上运行良好,但现在它不会执行,我更改了dbconnect.php文件中的信息,如果我手动插入行,它会正常显示。谁能告诉我问题出在哪里 php问题脚本: <?php include ("dbc.php"); session_start(); function GetImageExtension($imagetype) { if(empty($imagety
<?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");
}
}
?>
使用mysqli_查询或PDO::query在PHP5.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,数据值“balega”,“xxx.xxx/”,“admin”,'images/30-09-2015-1443623562.jpg','2015-09-30'===-->p.s.我用x代替了错误中的真实地址,因为它在这里转换为链接。请做一个屏幕截图或复制准确的错误,在你给我的代码中没有。这个脚本现在运行得很好idk出了什么问题,脚本中的某个内容发生了变化,而不是恢复了变化,而且它运行得很好,不管怎样,可能是pc的问题,很奇怪