Please help me with this.
I have a php code which search first for the records that will be needed to inserted to another table
here is my code:
//search for split values (capacitors)
$capacitance =mysql_query("SELECT itemno, wwpn, SUBSTR(val, 1, LENGTH(val) / 2) as capacitor,
SUBSTR(val, LENGTH(val) / 2+1) as capasitance
FROM bom_csv WHERE boardnumber ='$board' and bom_csv.qty<>'' and bom_csv.qty !='qty';");
while($row =mysql_fetch_array($capacitance))
{
echo "<pre>";
echo $row['itemno'];
echo $row['capacitor'];
echo $row['capasitance'];
echo $row['wwpn'];
echo "</pre>";
$capacitor = $row['capacitor'];
$capacity =$row['capasitance'];
$adi_pn=$row['adi_pn'];
$itemno=$row['itemno'];
//insert into via update
$update =@mysql_query ("UPDATE bom_crunching SET capacitor ='$capacitor', capacitance ='$capacity' WHERE boardmodel ='$board' and adi_pn ='$adi_pn'");
if ($update)
{
echo "OKAY!";
}
else
{
echo "NOT OKAY!";
}
}
While executing it, I am not getting any errors. However, when I look at my query browser it doesn't have any data inserted. The result I want is to insert all the records in the table via update statement because it has a default value of null.
Thanks in advance!
First step, change the line:
$update =@mysql_query ("UPDATE bom_crunching SET capacitor ='$capacitor', capacitance ='$capacity' WHERE boardmodel ='$board' and adi_pn ='$adi_pn'");
to:
$update =mysql_query ("UPDATE bom_crunching SET capacitor ='$capacitor', capacitance ='$capacity' WHERE boardmodel ='$board' and adi_pn ='$adi_pn'") or die( mysql_error() );
So NOW you will be informed what is the problem, than we can help you better.
;)