我有一个9年前建立的网站,从那时起我的专用服务器就有了许多更新,PHP,MYQSL等等......这个数据库驱动的网站现在有一些小问题。我知道我需要重建它,但任何人都可以帮助解决这个问题。当我尝试将产品添加到后端时,我收到以下错误消息:
不正确的整数值:''对于第1行的'Did'列
我在数据库中有一个名为'Did'的列,所以不确定该怎么想。以下是在后端添加产品的代码:
<?
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"> </td>
<td width="549"> </td>
</tr>
<tr>
<td width="252"> </td>
<td width="549"><input type="submit" value="Add Designs" name="Are"></td>
</tr>
</table>
</form>
<?
include("footer.php");
}
?>
答案 0 :(得分:0)
您正在尝试保存一个空字符串”,其中和整数值应为。您可以设置为空,将其从查询中删除或将其设置为默认值