Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 用Mysqli或PDO替换MySQL函数_Php_Mysql_Mysqli_Pdo - Fatal编程技术网

Php 用Mysqli或PDO替换MySQL函数

Php 用Mysqli或PDO替换MySQL函数,php,mysql,mysqli,pdo,Php,Mysql,Mysqli,Pdo,当我尝试测试我的再生形式时,这个按摩出现了: “mysql扩展已弃用,将来将被删除:使用mysqli或PDO” 每次我遇到新问题时,我都试图修改我的代码,我对这些东西不是很在行 有谁能帮我,告诉我我到底需要修改什么代码吗 连接代码 <?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_localhost = "localhost"; $database_localhost

当我尝试测试我的再生形式时,这个按摩出现了: “mysql扩展已弃用,将来将被删除:使用mysqli或PDO”

每次我遇到新问题时,我都试图修改我的代码,我对这些东西不是很在行
有谁能帮我,告诉我我到底需要修改什么代码吗

连接代码

    <?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_localhost = "localhost";
$database_localhost = "rsms database";
$username_localhost = "root";
$password_localhost = "";
$localhost = mysql_pconnect($hostname_localhost, $username_localhost, $password_localhost) or trigger_error(mysql_error(),E_USER_ERROR); 
?>

这是我的源代码

    <?php require_once('Connections/localhost.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) {
  $insertSQL = sprintf("INSERT INTO users (email, DateOfBirth) VALUES (%s, %s)",
                       GetSQLValueString($_POST['email'], "text"),
                       GetSQLValueString($_POST['DateOfBirth'], "date"));

  mysql_select_db($database_localhost, $localhost);
  $Result1 = mysql_query($insertSQL, $localhost) or die(mysql_error());

  $insertGoTo = "PageAfterLogin.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_localhost, $localhost);
$query_RegesterUsers = "SELECT * FROM users";
$RegesterUsers = mysql_query($query_RegesterUsers, $localhost) or die(mysql_error());
$row_RegesterUsers = mysql_fetch_assoc($RegesterUsers);
$totalRows_RegesterUsers = mysql_num_rows($RegesterUsers);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>


</head>


<body>

<div class="containerDiv" id="containerDiv">

Regesteration Page





<form method="POST" action="<?php echo $editFormAction; ?>" name="form">



    <table width="600" border="0">
  <tbody>
    <tr>
      <td><label for="email">Email:</label>
        <input type="email" name="email" id="email"></td>
      <td><label for="date">Date:</label>
        <input type="date" name="DateOfBirth" id="DateOfBirth"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="submit" id="submit" value="Submit"></td>
    </tr>
  </tbody>
</table>
    <input type="hidden" name="MM_insert" value="form">





</form>



</div>
</body>
</html>
<?php
mysql_free_result($RegesterUsers);
?>

无标题文件
再酯化页

目前在PHP中,有三种连接MySQL数据库的方法。使用mysql_*函数(您已经使用过)、mysqli_*函数(首选)和PDO

mysql函数不再受支持(并且在PHP7中被删除),您不应该在PHP脚本中再使用它们,您应该将它们作为新的和改进的标准使用

PDO是所有数据库安装的通用标准,如MySQL、SQLite、MS SQL和PostgreSQL


你的信息只是一个通知,您不需要使用PDO或MySQLI,但每次PHP都会告诉您应该更改脚本。

如果您不发布当前代码,而是发布了您尝试的错误代码,这将有助于您更好地理解,这样我们可以帮助您修复这些错误,从而加快项目的进度。“我到底需要改变什么”-所有以
mysql\uuu
OP开头的东西都在尝试切换。那么你的答案有什么帮助呢?他们没有说他们正在尝试切换。他们问他们需要改变什么,这意味着他们不知道MySQLi。