简体   繁体   English

mysql查询不再起作用

[英]mysql query no longer works

I am trying to make it so that you can upload a ppt and it will split into a pdf for each slide. 我正在尝试制作它,以便您可以上传ppt,并且每张幻灯片都会拆分为pdf。 i have already made a shell script to do the ppt splitting and that works, however i am having trouble with my sql query to update my database. 我已经制作了一个Shell脚本来进行ppt拆分,并且可以运行,但是我在使用SQL查询更新数据库时遇到了麻烦。 I had it working at one point and then all of a sudden it stopped working, not sure what i did to mess it up but it looks fine to me. 我让它在某一时间工作,然后突然停止工作,不确定我是怎么做的,但是对我来说看起来还不错。 Here is some of the code: 这是一些代码:

if(isset($_POST['title'])){

$admin_id = $_SESSION['user_id'];
$name = $_POST['title'];

if(isset($_FILES["file"]["name"]) && !empty($_FILES["file"]["name"])){
    $fname = $_FILES["file"]["name"];
    $tmp_name = $_FILES["file"]["tmp_name"];
    $dir = "powerpoints/".$name;
    $ispdf = "1";
    echo $tmp_name."----------------".$dir;

    echo $admin_id.':'.$name.':'.$dir.':'.$ispdf;

    $query = mysql_query("INSERT INTO problem (admin_id,topic,image,is_pdf) VALUES ('$admin_id','$name','$dir','$ispdf')");
    //$output = shell_exec('mkdir '.$dir);
    //echo $output;
    if($query && move_uploaded_file($tmp_name, $dir.$fname)){
        //$cmd = 'importppt.sh '.str_replace(".pdf", "", $name);
        $message = "Powerpoint uploaded";
    }elseif($query){
        $message = "move_uploaded_file() Failed";
    }else{
        $message = "Database Error";
    }`

when i try to use the script Database Error is printed which means it skipped over "elseif($query)" also note that there are more columns in my database that i am not updating, however it should just leave them blank for the new entry like it has before it stopped working. 当我尝试使用脚本时,将显示数据库错误,这意味着它跳过了“ elseif($ query)”,还请注意,我的数据库中还有许多我没有更新的列,但是对于新条目,应该将它们留空就像它停止工作之前一样。 all of the names are spelled correctly and the data being put into the query is printed correctly by my echo statement 我的echo语句正确拼写了所有名称,并正确打印了要查询的数据

Update your Query For testing 更新您的查询以进行测试

error_reporting(-1) ;
$query = mysql_query("INSERT INTO problem (admin_id,topic,image,is_pdf) VALUES 
('admin_id','name','dir','ispdf')");

$temp = false;
if(move_uploaded_file($tmp_name, $dir.$fname)){
    $temp = true;
}

if($query && $temp){
    $message = "Powerpoint uploaded,";
}
else if($query){
    $message = "Problem Find In your TITLE, Or Duplicate Data, OR Use mySqli";
}else if(!$temp){
      $message = "Problem Find In your mov directory, Check manually";
}
else{
        $message = "Hope This Else Will not work";
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM