真正的转义字符串到多个连接

时间:2019-01-29 15:28:46

标签: php mysql connection-string

real_escape_string中的一个变量可能有多个连接吗?

我的问题是我需要将相同的$_POST插入两个不同的数据库中。

请参见此处:

<?php
$con=mysqli_connect("localhost","my_user","my_password","my_db");
$con2=mysqli_connect("localhost2","my_user2","my_password2","my_db2");



// Check connection
if (mysqli_connect_errno()) {
 echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

// escape variables for security
$username = mysqli_real_escape_string($con, $con2, $_POST['username']);
mysqli_close($con, $con2);
?>

0 个答案:

没有答案