我正在尝试运行 MySQL PDO 查询。我不确定为什么会出现致命错误。我检查了其他帖子,但他们的答案似乎并没有解决我的问题。
该脚本与数据库的连接正常。用户名和密码是正确的,我已在下面的脚本中将其删除。
我的输出:
Connected to database
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[28000] [1045] Access denied for user 'nobody'@'localhost' (using password: NO)' in /home/a/public_html/d/inc/header.php:34 Stack trace: #0 /home/a/public_html/d/inc/header.php(34): PDO->__construct('mysql:host=;dbn...', NULL, NULL) #1 /home/a/public_html/d/inc/header.php(43): testdb_connect() #2 /home/a/public_html/d/article.php(3): include('/home/a/p...') #3 {main} thrown in /home/a/public_html/d/inc/header.php on line 34
Run Code Online (Sandbox Code Playgroud)
我的代码:
<?php
/*** MySQL hostname ***/
$hostname = 'localhost';
/*** MySQL username ***/
$username = 'removed';
/*** MySQL password ***/
$password = 'removed';
try {
function testdb_connect(){
$dbh = new PDO("mysql:host=$hostname;dbname=removed", …Run Code Online (Sandbox Code Playgroud) 我有一个带有多个提交按钮的表单。
每个提交按钮都是一个IMG SRC垃圾桶,表示基于Web的邮件收发信箱中邮件的删除图标
找出单击哪个“提交”按钮图标的最佳方法是什么,这样我就可以编写PHP / MySQL代码来删除消息了?
if(!empty($_POST)){
// How do I figure out which submit button has been clicked to get the ID of the message to delete?
}
<form method="POST">
<input src="http://www.foo.com/img.png" id="button_1">
<input src="http://www.foo.com/img.png" id="button_2">
<input src="http://www.foo.com/img.png" id="button_3">
<input src="http://www.foo.com/img.png" id="button_4">
...
<input src="http://www.foo.com/img.png" id="button_100">
</form>
Run Code Online (Sandbox Code Playgroud)