我正在建立一个新网站,我想在我的MySQLi数据库中输入一些注册信息.
我想保持与数据库的连接,而不是每次都在子页面中建立新的连接.
在主页中,我开始像这样的连接:
$con = MysqLi_connect("localhost","root","","Website");
if (!$con) {
echo "Error: Unable to connect to MysqL.";
exit; }
if($con){ echo "Successful connect";}
<a href="/InsertInDatabase.PHP">Insert</a>
<a href="/SearchDatabase.PHP">Search</a>
<a href="/DeletefromDatabase.PHP">Delete</a>
InsertInDatabase.PHP
$con = MysqLi_connect("localhost","Website");
if (!$con) {
echo "Error: Unable to connect to MysqL.";
exit; }
if($con){ echo "Successful connect";}
SearchDatabase.PHP
$con = MysqLi_connect("localhost","Website");
if (!$con) {
echo "Error: Unable to connect to MysqL.";
exit; }
if($con){ echo "Successful connect";}
最佳答案