dongshang1768 2012-05-31 00:00
浏览 14
已采纳

无法在mySQL中通过php更新部件号字段

I'm using a script to update my record via php in mySQL. All of the fields can be updated except $part_no.

I can't figure out why "part_no" will not update.

Appreciate any help.

<?php session_start();


$type=$_POST['type'];
$part_no=$_POST['part_no'];
$description=$_POST['description'];
$artwork=$_POST['artwork'];
$min=$_POST['min'];
$max=$_POST['max'];

$db="naturan8_hero";

$link = mysql_connect("localhost", "XXXXXXX", "XXXXXX");
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
$query = mysql_query(" UPDATE cartons_current SET type='$type' , part_no='$part_no',     description='$description',artwork='$artwork', min='$min' , max='$max' WHERE part_no='$part_no' ");

if($query) {
header("location: inv_fc_edit_success.php?part_no=" . urlencode($part_no));
}else{
header("location: inv_fc_edit_fail.php");
}

?>

Here is the form for editing:

<?php
$record = $_POST['part_no'];


mysql_connect("$host", "$username", "$password") or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$result=mysql_query(" SELECT * FROM cartons_current WHERE part_no='$record'");
$num=mysql_num_rows($result);
$i=0;
while ($i < $num) {

$type=mysql_result($result,$i,"type");
$part_no=mysql_result($result,$i,"part_no");
$description=mysql_result($result,$i,"description");
$artwork=mysql_result($result,$i,"artwork");
$min=mysql_result($result,$i,"min");
$max=mysql_result($result,$i,"max");
?>


<div id="fcICON">Hero</div>
<div id="titleWRAP">
<div id="newTITLE">Edit Part Number</div>
<div id="newINS">This area is designated for editing a part number. Please <b>be careful and alert </b>to your changes, because they are immediately posted.</div>
</div>
<div class="form_hero_new">
<form id="form_editX" method="POST" action="inv_fc_edit2.php"   onfocus="this.value=''">
  <input type="hidden" name="type" type="text" value="FC">
  <input type="hidden" name="part_no" value="<? echo "$record" ?>">
  <div style="width: 500px; height:63px;float:left;">
    <div style="width: 165px; height:65px;float:left;">
      <div id="heroLABEL" style="width:150px">Part Number</div>
      <div id="newPN">
        <textarea name="part_no"  maxlength="20" minlength="6" type="text" style="width: 130px;color:#FFFF00"><? echo "$part_no"?></textarea>
      </div>
  • 写回答

2条回答 默认 最新

  • douchen4534 2012-05-31 00:03
    关注

    You are setting part_no to its existing value, which will make no change:

    UPDATE cartons_current SET part_no='$part_no' WHERE part_no='$part_no'
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器