-2

can u guys help me..i still don't understand about the warning and how to fix although i look all the solution

    <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);

    ?>

the question have been answer n thanks guys..but now the i can edit anything because the textfield come out with nothing although i click the edit for certain country

ollo
  • 24,797
  • 14
  • 106
  • 155
  • Use [mysql_select_db($database)](http://php.net/manual/en/function.mysql-select-db.php) function to select a database. – Arjun Abhynav Dec 03 '12 at 06:36
  • it come out with white page... – Nixsham B Mohamad Dec 03 '12 at 06:38
  • 1
    [**Please, don't use `mysql_*` functions in new code**](http://bit.ly/phpmsql). They are no longer maintained and the [deprecation process](http://j.mp/Rj2iVR) has begun on it. See the [**red box**](http://j.mp/Te9zIL)? Learn about [*prepared statements*](http://j.mp/T9hLWi) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://j.mp/QEx8IB) will help you decide which. If you choose PDO, [here is a good tutorial](http://j.mp/PoWehJ). – NullPoiиteя Dec 03 '12 at 06:39
  • you are missing selecting database line !! add `mysql_select_db($database);` before `$IdCountry` variable – Pankit Kapadia Dec 03 '12 at 06:43
  • ok i try to see if still hv that warning or error – Nixsham B Mohamad Dec 03 '12 at 06:46

1 Answers1

0

isset returns booleans, so your IdCountry and the like are being set to booleans not strings. Do not do the die test on result, instead do it on the query and you should be okay.

mroytman
  • 41
  • 2