Hi guys,
I have a trouble with error"Access denied for user ''@'localhost' (using password: NO)", Could someone give me some advice. Try to add new user but it does not work. Here is my scirpts:
I have a trouble with error"Access denied for user ''@'localhost' (using password: NO)", Could someone give me some advice. Try to add new user but it does not work. Here is my scirpts:
Code:
function add_product($商品编号, $商品名称, $购买日期, $失效日期, $颜色尺寸规格, $条形码, $购买价格, $税, $折扣, $汇率, $购买成本¥, $实际定价¥, $剩余库存总价¥, $预计运费¥, $参考销售价¥, $原库存, $新购数量, $销售数量, $现有库存, $商品种类, $存放地点, $更新时间, $备注 ) { // add new product information into database // return true or error message // connect to db //global $conn; $conn = db_connect(); // check if product is alreday added in database //mysql_query("SET NAMES GBK"); //来设定MYSQL连接编码,保证页面申明编码与这里设定的连接编码一致(GBK是GB2312的扩展)。如果页面是UTF-8编码的话,可以用: mysql_query("SET NAMES UTF8"); //注意是UTF8而不是一般用的UTF-8。假如页面申明的编码与数据库内部编码一致可以不设定连接编码。 $result = $conn->query("select * from cosmetics where 商品编号='".$商品编号."'"); if (!$result) { throw new Exception('无法校验产品编号是否存在系统,请联系系统管理员。'); } if ($result->num_rows>0) { throw new Exception('相同商品编号已经存在系统,请输入其他商品编号,再次尝试。'); } //$conn = db_connect(); // if ok, put insert the data into database //mysql_query("SET NAMES GBK"); mysql_query("SET NAMES UTF8"); $result = $conn->query("insert into cosmetics (商品编号, 商品名称, 购买日期, 失效日期, 颜色尺寸规格, 条形码, 购买价格, 税, 折扣, 汇率, 购买成本¥, 实际定价¥, 剩余库存总价¥, 预计运费¥, 参考销售价¥, 原库存, 新购数量, 销售数量, 现有库存, 商品种类, 存放地点, 更新时间, 备注) values ('".$商品编号."', '".$商品名称."', '".$购买日期."', '".$失效日期."', '".$颜色尺寸规格."', '".$条形码."', '".$购买价格."', '".$税."', '".$折扣."', '".$汇率."', '".$购买成本¥."', '".$实际定价¥."', '".$剩余库存总价¥."', '".$预计运费¥."', '".$参考销售价¥."', '".$原库存."', '".$新购数量."', '".$销售数量."' '".$现有库存."', '".$商品种类."', '".$存放地点."', '".$更新时间."', '".$备注."' )" ); ini_set('error_reporting', E_ALL|E_STRICT); ini_set('display_errors', 1); mysql_query($result) or die(mysql_error()); if (!$result) { throw new Exception('添加商品失败,请检查输入信息格式正确后,再次尝试。'); } return true; } ?>
Comment