【问题标题】:whats wrong in this query its not deleting此查询有什么问题没有删除
【发布时间】:2014-03-27 04:25:08
【问题描述】:

我正在使用echo $fss它的显示数据

"11-V5703211-V5703211-V5703211-V5703211-V5703211-V5703211-V5703211-V5703211-V5703211-V5703211-V5703211-V5703211-V5703211-V5703211-V5703211-V5703211-V5703211-V5703211-V57032"

但我正在使用此变量的删除查询,但它不起作用

<?php  

 //connect to the database 
 $connect = mysql_connect("localhost","root",""); 
 mysql_select_db("cityshoes",$connect); //select the table 


if ($_FILES[csv][size] > 0) { 

    //get the csv file 
    $file = $_FILES['csv']['tmp_name'];
    $handle = fopen($file,"r"); 



    do { 
        if ($data[0]) { 

 $fss = addslashes($data[1]);
        $result = mysql_query("DELETE from  contacts where articleno = . $fss . ");

        echo $fss;


        } 
    } while ($data = fgetcsv($handle,1000,",","'")); 



} 

?> 

【问题讨论】:

标签: php mysql sql sqlite csv


【解决方案1】:

您以错误的方式在查询中附加变量。尝试:

$result = mysql_query("DELETE from  contacts where articleno = $fss");

$result = mysql_query("DELETE from contacts where articleno ='".$fss ."'");

【讨论】:

    【解决方案2】:

    转这条线

    $result = mysql_query("DELETE from  contacts where articleno = . $fss . ");
    

    到这里

    $result = mysql_query("DELETE from  contacts where articleno =  $fss ");
    

    您必须删除句点。

    【讨论】:

    • $result = mysql_query("delete from contacts where articleno = $fss");我对其进行了更改,但仍然没有删除 do while 循环中的任何错误
    • 您是否将该 sql 命令粘贴到 phpmyadmin 并用示例代码替换 $fss 以测试以确保字符串有效?
    猜你喜欢
    • 2018-09-23
    • 2015-03-21
    • 1970-01-01
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多