简体   繁体   English

第1行的'Did'列的整数值不正确:''

[英]Incorrect integer value: '' for column 'Did' at row 1

I have a site that was built 9 years ago and since then my dedicated server has had many updates, PHP, MYQSL, ect... and this database driven site is now having some small issues. 我有一个建于9年前的站点,此后,我的专用服务器进行了许多更新,包括PHP,MYQSL等。此数据库驱动的站点现在遇到了一些小问题。 I know I need to rebuild it, but can anyone help with this issues. 我知道我需要重建它,但是任何人都可以帮助解决此问题。 When i try to add a product to backend, I get this error message: 当我尝试将产品添加到后端时,出现以下错误消息:

Incorrect integer value: '' for column 'Did' at row 1 第1行的'Did'列的整数值不正确:''

I do have a column in the database called 'Did' so not sure what to think. 我在数据库中确实有一个名为“ Did”的列,所以不确定要怎么想。 Here is the code to add a product on backend: 以下是在后端添加产品的代码:

<?

include("../config.php");

if(isset($_POST[Are]))

{

$Cid                        = $_POST[Cid];
$Sid                        = $_POST[Sid];
$Design_Image               = $_FILES[Design_Image][name];
$DimensionW                 = $_POST[DimensionW];
$DimensionY                 = $_POST[DimensionY];
$Model_Number               = $_POST[Model_Number];
$New_Design                 = $_POST[New_Design];
$t                          = time();



    function getFileExtension($str) {

        $i = strrpos($str,".");

        if (!$i) { return ""; }

        $l = strlen($str) - $i;

        $ext = substr($str,$i+1,$l);

        $ext = strtolower($ext);

        if($ext == jpg || $ext == jpeg || $ext == gif || $ext == png)

        {

        }

        else

        {

        echo"<strong>$ext</strong> type is not accepted.Please upload only JPG, Gif and PNG Extenstions";

        exit();

        }

        return $ext;

        }



      function CopyImageFileGD($name,$ext,$path_thumbs,$path_big,$newwidth,$newheight) {

        $t       = time();

        $tempname = strtolower($name);

        $Newname = "$tempname$t.$ext";

        $Temp_type = $_FILES[$name]['type'];

        $Temp_name = $_FILES[$name]['name'];

        $Temp_size = $_FILES[$name]['size'];

        $Temp_tmp = $_FILES[$name]['tmp_name'];



        if($Temp_size){

          if($Temp_type == "image/pjpeg" || $Temp_type == "image/jpeg"){

               $new_img = imagecreatefromjpeg($Temp_tmp);

           }elseif($Temp_type == "image/x-png" || $Temp_type == "image/png"){

               $new_img = imagecreatefrompng($Temp_tmp);

           }elseif($Temp_type == "image/gif"){

               $new_img = imagecreatefromgif($Temp_tmp);

           }       



           list($width, $height) = getimagesize($Temp_tmp);



           if (function_exists(imagecreatetruecolor)){

           $resized_img = imagecreatetruecolor($newwidth,$newheight);

           }

           imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

           $tempname = strtolower($name);

           $Newname = "$tempname$t.$ext";          

           ImageJpeg ($resized_img,"$path_thumbs/$Newname");

           ImageDestroy ($resized_img);

           ImageDestroy ($new_img);


            }

             return $Newname;           

            }











        $ExtDesign_Image = getFileExtension($Design_Image);








    if(!empty($Design_Image))

        {

        $NewDesign_Image = CopyImageFileGD("Design_Image","$ExtDesign_Image","../designs_files/thumbs","../designs_files","150","160");

        }











$q1 = "INSERT INTO `designs` (`Did` , `Cid` , `Sid` , `Design_Image` , `DimensionW` , `DimensionY` , `Model_Number` , `Order` , `New_Design` ) VALUES ( '', '$Cid', '$_POST[Sid]', '$NewDesign_Image', '$DimensionW', '$DimensionY', '$Model_Number', '', '$New_Design')";
mysql_query($q1) or die(mysql_error());



    $qp = "select last_insert_id()";
    $rp = mysql_query($qp) or die(mysql_error());
    $ap = mysql_fetch_array($rp);




        $q1 = "update `designs` set
           `Order`          = '$ap[0]'
           where `Did`          = '$ap[0]'";
        mysql_query($q1) or die(mysql_error());


header("location:designs.php");

}

else

{

include("header.php");

include("designsnav.php");


        $qCid = "select * from `categories` Order by Title";
        $rCid = mysql_query($qCid) or die(mysql_error());
        if(mysql_num_rows($rCid) == '0')
        {

            echo "<br><center><b>No Category found in database.</b></center>";
            include"footer.php";
            exit();
        }

                else
        {
        $CidOption .='<select size="1" name="Cid" id="Cid" onchange="selectChange(this, form.Sid, arrItems1, arrItemsGrp1);">
        <option value="0" selected>[ SELECT ONE ]</option>
        ';
        while($aCid = mysql_fetch_array($rCid))
        {

         $CidOption .="\t<option value=\"$aCid[Cid]\">$aCid[Title]</option>\n";
        }

        $CidOption .='</select>';       
        }


        ?>

        <script type="text/javascript">

var arrItems1 = new Array();
var arrItemsGrp1 = new Array();
function selectChange(control, controlToPopulate, ItemArray, GroupArray) {
alert("hello");
  var myEle ;
  var x ;
  // Empty the second drop down box of any choices
  for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;

  // ADD Default Choice - in case there are no values
  myEle = document.createElement("option") ;
  myEle.value = 0 ;
  myEle.text = "[ SELECT ONE ]" ;
  // controlToPopulate.add(myEle) ;
  controlToPopulate.appendChild(myEle)
  // Now loop through the array of individual items
  // Any containing the same child id are added to
  // the second dropdown box
  for ( x = 0 ; x < ItemArray.length  ; x++ ) {
    if ( GroupArray[x] == control.value ) {
      myEle = document.createElement("option") ;
      //myEle.value = x ;
      myEle.setAttribute('value',x);
      // myEle.text = ItemArray[x] ;
      var txt = document.createTextNode(ItemArray[x]);
      myEle.appendChild(txt)
      // controlToPopulate.add(myEle) ;
      controlToPopulate.appendChild(myEle)
    }
  }
}


        </script>


        <?php
        $qSid = "select * from `subcategories` Order by Cid";
        $rSid = mysql_query($qSid) or die(mysql_error());
        if(mysql_num_rows($rSid) == '0')
        {

            echo "<br><center><b>No Category found in database.</b></center>";
            include"footer.php";
            exit();
        }

                else
        {
        while($aSid = mysql_fetch_array($rSid))
        {

         $SidOption .="
         arrItems1[$aSid[Sid]] = \"$aSid[Title]\";
         arrItemsGrp1[$aSid[Sid]] = \"$aSid[Cid]\";
         ";
        }


        }       



?>
<script type="text/javascript">



<?echo $SidOption;?>



/* function selectChange(control, controlToPopulate, ItemArray, GroupArray) {
  var myEle ;
  var x ;
  // Empty the second drop down box of any choices
  for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;
  if (control.name == "Cid") {
    // Empty the third drop down box of any choices
  }
  // ADD Default Choice - in case there are no values
  myEle=document.createElement("option");
  theText=document.createTextNode("[ SELECT ONE ]");
  myEle.appendChild(theText);
  myEle.setAttribute("value","0");
  controlToPopulate.appendChild(myEle);
  // Now loop through the array of individual items
  // Any containing the same child id are added to
  // the second dropdown box
  for ( x = 0 ; x < ItemArray.length  ; x++ ) {
    if ( GroupArray[x] == control.value ) {
      myEle = document.createElement("option") ;
      //myEle.value = x ;
      myEle.setAttribute("value",x);
      // myEle.text = ItemArray[x] ;
      var txt = document.createTextNode(ItemArray[x]);
      myEle.appendChild(txt)
      // controlToPopulate.add(myEle) ;
      controlToPopulate.appendChild(myEle)
    }
  }
} */

</script>



<form name="form" method="POST" enctype="multipart/form-data" action="adddesigns.php">

<table border="0" width="600">

<tr>
<td width="252">Categories:</td>
<td width="549"><?echo $CidOption;?>    
</td>
</tr>

<tr>
<td width="252">Sub Categories:</td>
<td width="549">
      <select id="Sid" name="Sid">
      </select>
</td>
</tr>

<tr>
<td width="252">Design Image:</td>
<td width="549"><input type="file" name="Design_Image" size="20"></td>
</tr>

<tr>
<td width="252">Dimensions:</td>
<td width="549"><input type="text" name="DimensionW" size="3" maxlength="15">  Width  <input type="text" name="DimensionY" size="3" maxlength="15"> Height </td>
</tr>


<tr>
<td width="252">Model Number:</td>
<td width="549"><input type="text" name="Model_Number" size="15" maxlength="50"></td>
</tr>

<tr>
<td width="252">New Design:</td>
<td width="549"><input type="checkbox" name="New_Design" value="Yes"></td>
</tr>



    <tr> 

      <td width="252">&nbsp;</td>

      <td width="549">&nbsp;</td>

    </tr>

    <tr> 

      <td width="252">&nbsp;</td>

      <td width="549"><input type="submit" value="Add Designs" name="Are"></td>

    </tr>

</table>

</form>

<?

include("footer.php");

}

?>

You are trying to save an empty string '' where and integer value should be. 您正在尝试保存一个空字符串”,其中和整数值应为。 You can , it the value is empty, remove it from the query or set it to a default value 您可以,如果该值为空,则将其从查询中删除或将其设置为默认值

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

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