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: - 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;
-
}
-
-
?>
3 2396 - require('header.php');
-
require_once('product_fns.php');
-
-
-
-
//create short variable name
-
$商品编号=$_POST['商品编号'];
-
$商品名称=$_POST['商品名称'];
-
$购买日期=$_POST['购买日期'];
-
$失效日期=$_POST['失效日期'];
-
$颜色尺寸规格=$_POST['颜色尺寸规格'];
-
$条形码=$_POST['条形码'];
-
$购买价格=$_POST['购买价格'];
-
$税=$_POST['税'];
-
$折扣=$_POST['折扣'];
-
$汇率=$_POST['汇率'];
-
$购买成本=$_POST['购买成本'];
-
$实际定价=$_POST['实际定价'];
-
$剩余库存总价=$_POST['剩余库存总价'];
-
$预计运费=$_POST['预计运费'];
-
$参考销售价=$_POST['参考销售价'];
-
$原库存=$_POST['原库存'];
-
$新购数量=$_POST['新购数量'];
-
$销售数量=$_POST['销售数量'];
-
$现有库存=$_POST['现有库存'];
-
$商品种类=$_POST['商品种类'];
-
$存放地点=$_POST['存放地点'];
-
$更新时间=$_POST['更新时间'];
-
$备注=$_POST['备注'];
-
-
// start session which may be needed later
-
// start it now because it must go before headers
-
session_start();
-
try {
-
// check forms filled in
-
if (!filled_out($_POST)) {
-
throw new Exception('输入信息不完整,请返回重新尝试。');
-
}
-
-
// attempt to indsert product information into database
-
// this function can also throw an exception
-
-
add_product($商品编号,
-
$商品名称,
-
$购买日期,
-
$失效日期,
-
$颜色尺寸规格,
-
$条形码,
-
$购买价格,
-
$税,
-
$折扣,
-
$汇率,
-
$购买成本,
-
$实际定价,
-
$剩余库存总价,
-
$预计运费,
-
$参考销售价,
-
$原库存,
-
$新购数量,
-
$销售数量,
-
$现有库存,
-
$商品种类,
-
$存放地点,
-
$更新时间,
-
$备注
-
);
-
-
-
// end page
-
do_html_footer();
-
}
-
catch (Exception $e) {
-
do_html_header('错误:');
-
echo $e->getMessage();
-
exit;
-
}
-
-
// provide link to members page
-
do_html_header('恭喜');
-
echo '新商品添加成功。';
-
do_html_product('member.php', 'Go to members page');
-
-
require('footer.php');
-
-
-
?>
Set password for user localhost and use password while connecting to database.
Luuk 1,047
Expert 1GB
i did not know that php could read chinese?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ike_strong |
last post by:
Can anyone help me to figure out why each time I
try to access my database using:
c:\mysql\bin\inmysql -root -p
and afterwards:(i.e. after inputting my at the password prompt)
Enter...
|
by: |
last post by:
I get Access Denied
(System.Runtime.InteropServices.COMException) When trying
to
use DirectoryEntry on IIS via ASP.NET application. The
same code I use is not generating this Exception while...
|
by: SKB |
last post by:
Hi,
I am absolutely new to this area. I am getting the following difficulty
:
Access denied for user 'ODBC'@'localhost' (using password: NO)
when I try the mysql command from within the...
|
by: rajbala.3399 |
last post by:
Hi ,
I want to download sql in my linux system...........
# rpm -ivh
MySQL-server-5.0.24a-0.glibc23.i386.rpm MySQL-cl
ient-5.0.24a-0.glibc23.i386.rpm
Preparing... ...
|
by: usafshah |
last post by:
Hi
I'm using linux with mysql , when i type mysql in terminal it says like:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
i'm logged in as root
but...
|
by: ajos |
last post by:
hi frnds,
im trying to convert my servlets database configuration from ms access to mysql database.however im getting some error like no driver found exception.
to verify this error ive...
|
by: whitey |
last post by:
hi all,
is there any other reason for this message to be displayed? other than incorrect username, password, database name?
|
by: pearl15 |
last post by:
Hello All
I have successfully installed the following
IIS ver 6
php ver 4.4.9
MYSQL ver 5.0.67
when i tested through command line i get no error and i am view the php pages on the browser...
|
by: pearl15 |
last post by:
Hello All
I have successfully installed the following
IIS ver 6
php ver 4.4.9
MYSQL ver 5.0.67
when i tested through command line i get no error and i am view the php pages on the browser...
|
by: vasf |
last post by:
when i am trying to back up the TE(Application)config file and TE database back (MySql 5.6)i got this error message
C:\Program Files\Tripwire\TE\Server\bin>tetool backup --passphrase 'pass'...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |