Php 警告:mysql_fetch_array():提供的参数不是有效的mysql结果资源,未选择任何数据库
你们能帮帮我吗?我还是不明白这个警告,也不知道该怎么解决,尽管我看了所有的解决方案Php 警告:mysql_fetch_array():提供的参数不是有效的mysql结果资源,未选择任何数据库,php,Php,你们能帮帮我吗?我还是不明白这个警告,也不知道该怎么解决,尽管我看了所有的解决方案 <php $hostname = "localhost"; $database= "doctor"; $username = "root"; $password = ""; $doktor = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_err
<php
$hostname = "localhost";
$database= "doctor";
$username = "root";
$password = "";
$doktor = mysql_pconnect($hostname, $username, $password) or
trigger_error(mysql_error(),E_USER_ERROR);
$IdCountry = isset($_POST['IdCountry']);
$Country= isset($_POST['Country']);
$result = mysql_query("SELECT * FROM warganegara WHERE IdWarga = '$IdWarga'");
if(mysql_num_rows($result) >0){
while ($test = mysql_fetch_array($result) or die (mysql_error())){
}
if (!$result)
{
die("Error: Data not found..");
}
$Country=$test['Country'] ;
if(isset($_POST['save']))
{
$Country_save = $_POST['ctry'];
mysql_query("UPDATE country SET Country='$Country_save' WHERE IdCountry = '$IdCountry'")
or die(mysql_error());
echo "Saved!";
header("Location: index.php");
}
mysql_close($doctor);
?>
0){
而($test=mysql\u fetch\u array($result)或die(mysql\u error()){
}
如果(!$result)
{
模具(“错误:未找到数据…”);
}
$Country=$test['Country'];
如果(isset($_POST['save']))
{
$Country\u save=$\u POST['ctry'];
mysql_查询(“更新国家/地区集country='$country_save'其中IdCountry='$IdCountry'))
或者死(mysql_error());
回声“救了!”;
标题(“Location:index.php”);
}
mysql_close($doctor);
?>
问题已经得到了回答,谢谢各位。但是现在我可以编辑任何内容,因为文本字段没有显示任何内容,尽管我单击了对特定国家/地区的编辑isset返回布尔值,所以您的IdCountry等设置为布尔值而不是字符串。不要对结果执行骰子测试,而是对查询执行该测试,您应该会被删除好的。使用函数选择数据库。它会显示一个白色页面……它们不再被维护,并且已经开始了。请参阅?了解,然后使用或-将帮助您决定哪个。如果选择PDO,。您缺少选择数据库行!!添加
mysql\u select\u db($database)
在$IdCountry
变量之前,我试着看看是否仍然存在那个警告或错误我只是把它和你说的一样,但仍然一样。。