Who can help me with the following.
a part of my code doesn't work and i do not know wy.

<?php
//from here it is working
$con = mysql_connect("localhost", "bla", "bla");
                if (!$con)
                {
                    die('Could not connect: ' . mysql_error());
                }
                mysql_select_db("wordpress", $con);
$sql1 ="CREATE TABLE IF NOT EXISTS stamboom_landen (
id int(11) NOT NULL auto_increment,
land VARCHAR(150),
PRIMARY KEY (id) )";
        mysql_query($sql1) or die(mysql_error());
if(isset($_POST['land_toevoegen']))
    {   
    $ingevuldland = $_POST['land_text'];
            // Als Post is leeg 
        if($_POST['land_text'] == '')
        {
                    $con = mysql_connect("localhost","bla","bla");
            if (!$con)
            {
              die('Could not connect: ' . mysql_error());
            }

            mysql_select_db("wordpress", $con);

            $result = mysql_query("SELECT * FROM stamboom_landen");
            echo"De volgenede landen bestaan al:<br>";
            while($row = mysql_fetch_array($result))
            {
              echo $row['land'];
              echo "<br>";
            }   
            echo "<br><br>test 2 U heeft niks ingevuld<br><br>";
            ?>
            <form action='landen_toevoegen1.php' method='post' name='landen_toevoegen' enctype='multipart/form-data'>    
            <input type='text' name='land_text' >
            <input type='submit' name='land_toevoegen' value='Land Toevoegen'>
            </form>
            <?php
            die();
        }
            // einde als post is leeg




        // Als post is niet leeg
        if($_POST['land_toevoegen'] != '')
        {   
            $ingevuldland = $_POST['land_text'];

            $connectdatum = mysql_connect("localhost","bla","bla") or die ("Kontrolier bitte ihren server connection.");

            mysql_select_db("wordpress");
            $query = "SELECT land FROM stamboom_landen WHERE land='$ingevuldland'";
            $result = mysql_query($query) or die(mysql_error());
            $row = mysql_fetch_array($result) or die(mysql_error());
             $land = $row['land'];

             // als land al in table staat
                if($land == $ingevuldland)
                {
                    $result = mysql_query("SELECT * FROM stamboom_landen");
                    echo"test 3 De volgenede landen bestaan al:<br>";
                    while($row = mysql_fetch_array($result))
                    {
                    // echo hier de landen die bestaan
                    echo $row['land'];
                    echo "<br />";
                    }   
                    // echo hier het land dat is ingevuld en geef weer vanuit datatabel
                    echo "<br /><br />test1 $land bestaat al";
                        ?>          
            <form action='landen_toevoegen1.php' method='post' name='landen_toevoegen' enctype='multipart/form-data'>    
            <input type='text' name='land_text' >
            <input type='submit' name='land_toevoegen' value='Land Toevoegen'>
            </form>
            <?php    
                die();
            }
// from here to down it is NOT working
            else
            {
                $connectdatum = mysql_connect("localhost","bla","bla") or die ("Kontrolier bitte ihren server connection.");

            mysql_select_db("wordpress");
                $sql="INSERT INTO stamboom_landen (land)
            VALUES ('$ingevuldland')";
            if (!mysql_query($sql))
            {
                die('Error: ' . mysql_error());
            }


            $result = mysql_query("SELECT * FROM stamboom_landen");
                    echo"De volgenede landen bestaan al:<br>";
                    while($row = mysql_fetch_array($result))
                    {
                    // echo hier de landen die bestaan
                    echo $row['land'];
                    echo "<br />";
                    }   
                echo "$ingevuldland";
                        ?>          
                <form action='landen_toevoegen1.php' method='post' name='landen_toevoegen' enctype='multipart/form-data'>    
                <input type='text' name='land_text' >
                <input type='submit' name='land_toevoegen' value='Land Toevoegen'>
                </form>
                <?php    

            }       
            die();
        }           
    }

?>  



//TILL here it is NOT working



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $lang['PAGE_TITLE']; ?></title>
</head>
<body>           
<?php            
$link = mysql_connect("localhost", "bla", "bla");
mysql_select_db("wordpress", $link);
        $result = mysql_query("SELECT * FROM stamboom_landen", $link);
$num_rows = mysql_num_rows($result);
if ($num_rows == 0){
echo "er zijn nog geen landen in uw landen tabel";  
        ?>          
<form action='landen_toevoegen1.php' method='post' name='landen_toevoegen' enctype='multipart/form-data'>    
        <input type='text' name='land_text' >
        <input type='submit' name='land_toevoegen' value='Land Toevoegen'>
        </form>
        <?php
die();  
}
else{           
        $con = mysql_connect("localhost","bla","bla");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("wordpress", $con);

$result = mysql_query("SELECT * FROM stamboom_landen");
echo"test1 De volgenede landen bestaan al:<br>";
while($row = mysql_fetch_array($result))
  {
  echo $row['land'];
  echo "<br />";
  } 


    ?>      




<form action='landen_toevoegen1.php' method='post' name='landen_toevoegen' enctype='multipart/form-data'>    
        <input type='text' name='land_text' >
        <input type='submit' name='land_toevoegen' value='Land Toevoegen'>
        </form>


<?php
}
?>      
</body>
</html>      

Who can help me wy a part is not working
Thanks in advice John

What error does it show? OR Where? What isn't working??

I have no errors
and this part is not working

// from here to down it is NOT working
            else
            {
                $connectdatum = mysql_connect("localhost","bla","bla") or die ("Kontrolier bitte ihren server connection.");
            mysql_select_db("wordpress");
                $sql="INSERT INTO stamboom_landen (land)
            VALUES ('$ingevuldland')";
            if (!mysql_query($sql))
            {
                die('Error: ' . mysql_error());
            }
            $result = mysql_query("SELECT * FROM stamboom_landen");
                    echo"De volgenede landen bestaan al:<br>";
                    while($row = mysql_fetch_array($result))
                    {
                    // echo hier de landen die bestaan
                    echo $row['land'];
                    echo "<br />";
                    }   
                echo "$ingevuldland";
                        ?>          
                <form action='landen_toevoegen1.php' method='post' name='landen_toevoegen' enctype='multipart/form-data'>    
                <input type='text' name='land_text' >
                <input type='submit' name='land_toevoegen' value='Land Toevoegen'>
                </form>
                <?php    
            }       
            die();
        }           

thanks

Try putting mysql_query on line 6....

Hope this works..

even that dosnt work i tried a lot of other ways

i know this might not be of any help but

mysql_select_db("wordpress"); isn't is this supposed to be mysql_select_db("wordpress",$connectdatum); in line 88 ??

and why do you have to declare $con many times or i mean why do you have to connect to the same DB everytime? also where is mysql_close($con);

sorry man, i'm kind of confused by your language

shahbaz13, line 6 doesn't need mysql_query cause it was placed in the next line

if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}

sorry could not responce aerlier
it still dosn't work

<?php

$con = mysql_connect("localhost", "bla", "bla");
                if (!$con)
                {
                    die('Could not connect: ' . mysql_error());
                }
                mysql_select_db("wordpress", $con);
$sql1 ="CREATE TABLE IF NOT EXISTS stamboom_landen (
id int(11) NOT NULL auto_increment,
land VARCHAR(150),
PRIMARY KEY (id) )";
        mysql_query($sql1) or die(mysql_error());


        // als post is gezonden
if(isset($_POST['land_toevoegen']))
    {   
    $ingevuldland = $_POST['land_text'];
            // Als Post is leeg 
        if (empty($_POST['land_text']))
        {

            $result = mysql_query("SELECT * FROM stamboom_landen");
            echo "The following country's are exist:<br>";
            while($row = mysql_fetch_array($result))
            {
              echo $row['land'];
              echo "<br>";
            }   
            echo "<br><br>You have nothing entered<br><br>";
            ?>
            <form action='landen_toevoegen1.php' method='post' name='landen_toevoegen' enctype='multipart/form-data'>    
            <input type='text' name='land_text' >
            <input type='submit' name='land_toevoegen' value='Land Toevoegen'>
            </form>
            <?php
            die();
        }
            // einde als post is leeg




        // Als post is niet leeg
        if($_POST['land_toevoegen'] != '')
        {   
            $ingevuldland = $_POST['land_text'];


            $query = "SELECT land FROM stamboom_landen WHERE land='$ingevuldland'";
            $result = mysql_query($query) or die(mysql_error());
            $row = mysql_fetch_array($result) or die(mysql_error());
             $land = $row['land'];

             // als land al in table staat
                if($land == $ingevuldland)
                {
                    $result = mysql_query("SELECT * FROM stamboom_landen");
                    echo"The following country's are exist:<br>";
                    while($row = mysql_fetch_array($result))
                    {
                    // echo hier de landen die bestaan
                    echo $row['land'];
                    echo "<br />";
                    }   
                    // echo hier het land dat is ingevuld en geef weer vanuit datatabel
                    echo "<br /><br />$land already exist";
                        ?>          
            <form action='landen_toevoegen1.php' method='post' name='landen_toevoegen' enctype='multipart/form-data'>    
            <input type='text' name='land_text' >
            <input type='submit' name='land_toevoegen' value='Land Toevoegen'>
            </form>
            <?php    
                die();
            }
             // als land niet voorkomt toevoegen aan landen tabel en tallen provincie, gemeenten en plaatsen aanmaken
            if($ingevuldland != $land )
            {


                $sql="INSERT INTO stamboom_landen (land) VALUES ('$ingevuldland')";
            if (!mysql_query($sql))
            {
                die('Error: ' . mysql_error());
            }


            $result = mysql_query("SELECT * FROM stamboom_landen");
                    echo"The following country's are exist:<br>";
                    while($row = mysql_fetch_array($result))
                    {
                    // echo hier de landen die bestaan
                    echo $row['land'];
                    echo "<br />";
                    }   

                        ?>          
                <a href="landentoevoegen.php">land toevoegen</a>
                <?php    

            }       
            die();
        }           
    }

?>      

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $lang['PAGE_TITLE']; ?></title>
</head>
<body>           
<?php            
$link = mysql_connect("localhost", "bla", "bla");
mysql_select_db("wordpress", $link);
        $result = mysql_query("SELECT * FROM stamboom_landen", $link);
$num_rows = mysql_num_rows($result);
if ($num_rows == 0){
echo "There are no countries in your countries table."; 
        ?>          
<form action='landen_toevoegen1.php' method='post' name='landen_toevoegen' enctype='multipart/form-data'>    
        <input type='text' name='land_text' >
        <input type='submit' name='land_toevoegen' value='Land Toevoegen'>
        </form>
        <?php
die();  
}
else{   
$result = mysql_query("SELECT * FROM stamboom_landen");
echo"The following country's are exist:<br>";
while($row = mysql_fetch_array($result))
  {
  echo $row['land'];
  echo "<br />";
  }             
    ?>      
<form action='landen_toevoegen1.php' method='post' name='landen_toevoegen' enctype='multipart/form-data'>    
        <input type='text' name='land_text' >
        <input type='submit' name='land_toevoegen' value='Land Toevoegen'>
        </form>


<?php
}
?>      
</body>
</html>      

I would say giv it a try. copy the code and see what's happend.
I give the words i english so you can see wath it does.
thanks

i tried with session even hat doesnt work

sorry man, i'm actually busy myself .. so i don't have time to create the DB and run your program ..

also where is mysql_close($con);

I rewrote the whole code and i have got it to work
I can not place it here because there is something wrong with the code button
thanks for the help
when the code button works i wil replace the new code

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.