Php Can';t使用简单的HTML表单更改MySQL变量

Php Can';t使用简单的HTML表单更改MySQL变量,php,mysql,database,variables,webforms,Php,Mysql,Database,Variables,Webforms,当我尝试这段代码时,我得到一个错误,如 Warning: mysql_select_db() [function.mysql-select-db]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/28/10527728/html/TestSite/page.php on line 20 Warning: mysql_select_db() [f

当我尝试这段代码时,我得到一个错误,如

Warning: mysql_select_db() [function.mysql-select-db]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/28/10527728/html/TestSite/page.php on line 20
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/content/28/10527728/html/TestSite/page.php on line 20
Warning: mysql_query() expects parameter 2 to be resource, null given in /home/content/28/10527728/html/TestSite/page.php on line 21
Could not update data: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
代码:


用于在数据库finalform中编辑成员表用户名的HTML

  <form method="post" action="<?php $_PHP_SELF ?>">
  <table width="400" border="0" cellspacing="1" cellpadding="2">
  <tr>
  <td width="100">Name</td>
  <td><input name="Username" type="text" id="Username"></td>
  </tr>

  <td width="100"> </td>
  <td>
  <input name="update" type="submit" id="update" value="Update">
  </td>
  </tr>

  </table>
  </form>

  <?php
  } //Curly bracket close from the else from the begining
  ?>

  </body>
  </html>
您缺少该函数。您正在关闭
$conn
,因此让我们使用它:

$conn = mysql_connect('localhost', 'user', 'pass');
也就是说,你真的应该尝试使用或类似的替代方案

  $conn = mysql_connect( server, username, password );
i、 e:

  $conn = mysql_connect( 'localhost', 'userName', 'yourPassword' );

我同意尝试PDO,要获得立即生效的解决方案,请尝试我的解决方案。

您的
mysql\u connect
在哪里?此外,您可能还需要查看
mysqli\uucode>或
PDO
mysql\uz
已弃用。若要展开。。。mysql的
mysql.*
函数将被删除。不建议编写新代码,因为它将在将来被删除。请阅读描述link\u identifier参数的部分-您可以不调用mysql\u connect,但只能在您可能不满足的非常特定的条件下使用。一旦完成并理解了这一点,请返回并阅读关于mysql_uu函数被弃用(即将退出)的大红色警告。它已经包含在标题中,当我将括号中的参数切换到我之前声明的变量名时,错误状态为。我不确定你说的PDO是什么意思?或者,如果您可以从members表中建议任何其他简单的方法来更改finalform数据库给定Memberid(如用户名)的变量。PDO是开发人员首选的新标准,是最新的数据库交互方式,看看这个网站,它展示了如何进行简单的pdo,这正是您所需要的:它也在connect.php中初始化
  $conn = mysql_connect( 'localhost', 'userName', 'yourPassword' );