Php 数据库连接函数错误
在我的dbconnect函数中的某个地方,它不在正确的位置。我一遍又一遍地找,但还是找不到。 以下是我的dbconnect函数:Php 数据库连接函数错误,php,Php,在我的dbconnect函数中的某个地方,它不在正确的位置。我一遍又一遍地找,但还是找不到。 以下是我的dbconnect函数: function dbConnect(){ // Connect to the database: $hostname="localhost"; $database="tblFile"; $mysql_login="valerie2_shuawna"; $mysql_password="norris";
function dbConnect(){
// Connect to the database:
$hostname="localhost";
$database="tblFile";
$mysql_login="valerie2_shuawna";
$mysql_password="norris";
if(!($db=mysql_connect($hostname, $mysql_login, $mysql_password))){
echo"error on connect";
}
else{
if(!(mysql_select_db($database,$db))){
echo mysql_error();
echo "<br />error on database connection. Check your settings.";
}
else{
echo "I have successfully made a connection to my database and everything
is working as it should.";
}
}
我找不到它应该关闭的地方。在代码的第一部分,您缺少一个括号 我建议你们使用这种形式的if语句
function dbConnect()
{
// Connect to the database:
$hostname="localhost";
$database="tblFile";
$mysql_login="valerie2_shuawna";
$mysql_password="norris";
if(!($db=mysql_connect($hostname, $mysql_login, $mysql_password))):
echo"error on connect";
else:
if(!(mysql_select_db($database,$db))):
echo mysql_error();
echo "<br />error on database connection. Check your settings.";
else:
echo "I have successfully made a connection to my database and everything is working as it should.";
endif;
endif;
}
函数dbConnect()
{
//连接到数据库:
$hostname=“localhost”;
$database=“tblFile”;
$mysql\u login=“valerie2\u shuawna”;
$mysql\u password=“norris”;
如果(!($db=mysql\u connect($hostname,$mysql\u login,$mysql\u password)):
回显“连接错误”;
其他:
如果(!(mysql\u select\u db($database,$db)):
echo mysql_error();
echo“
数据库连接错误。请检查您的设置。”;
其他:
echo“我已成功连接到我的数据库,一切正常。”;
endif;
endif;
}
告诉我结果出现了什么错误?数据库没有任何问题。我被告知dbconnect函数在正确的位置没有关闭。我已经讨论了一整天,找不到它。我建议在示例代码中删除您的用户/通行证OK现在就是这样做的…0文件上载选择文件:然后您有浏览按钮,然后是上载按钮,但仍然没有任何内容。用户B你知道我已经做了好几天了。我一点也不知道我做错了什么。我在数据库区域中的名称是错误的,所以我做了更正。但我不知道还能做什么。因为它仍然没有做我需要它做的事情。你到底想要的是将一个文件上载到文件夹并将其名称分配给数据库?
function dbConnect()
{
// Connect to the database:
$hostname="localhost";
$database="tblFile";
$mysql_login="valerie2_shuawna";
$mysql_password="norris";
if(!($db=mysql_connect($hostname, $mysql_login, $mysql_password))):
echo"error on connect";
else:
if(!(mysql_select_db($database,$db))):
echo mysql_error();
echo "<br />error on database connection. Check your settings.";
else:
echo "I have successfully made a connection to my database and everything is working as it should.";
endif;
endif;
}