2015-10-06 83 views
1

我開發了一個小腳本來更新兩個表中的一些字段。查詢運行時沒有錯誤,但由於任何原因,這些字段上沒有任何事情發生。我肯定有些東西被我忽略了,但我不知道是什麼。任何想法?在mysql上運行php查詢

<?php 
//connection to the database 
$connect=mysql_connect("localhost","xxxxxx","xxxxxxxxx") or 
die("Unable to Connect"); echo ("Connected to server<br>"); 

//select a database to work with 
mysql_select_db("xxxxxxxx") or die("Could not open the db"); echo  ("Connected to database<br>"); 

//execute the SQL query tu update Price taxes on Products 
$sql= "UPDATE pslpn_product SET id_tax_rules_group='68'"; 
$sql= "UPDATE pslpn_product_shop SET id_tax_rules_group='68'"; 
or die ('Could not update data: ' . mysql_error()); 

//close the connection 
echo ("Finalizado<br>") 
?> 

回答

0

如果您忘記添加WHERE子句,它將更新表中的所有行。

UPDATE表名SET字段=值WHERE ID =東西 - 要不然