Hi Guys
I wrote simple PHP script for get value from URL and check similar values from the database.

This is a code

<?php
include('../../datab.php');
if(!empty($_GET['ip']))
{
    $ip = $_GET['ip'];
    $ipcheck = mysql_query("SELECT * FROM `report` WHERE `ip`='$ip'");
    if(mysql_num_rows($ipcheck)> 0)
    {
        while($row = mysql_fetch_array($ipcheck)){


?>
<body>

<p>Report ID : <?php echo $row['id'] ?></p>
<?php 
        }
        else 
            {
                echo "Nothing Selected";
                }

}} ?>
</body>

But Dreamviewer shows there is a error in elsepart after the

<p>Report ID : <?php echo $row['id'] ?></p>
    <?php 
            }

lines, (see attachment 01)

Whats wrong with my code?

At line 17 you're closing the paranthesis of the while loop, so add another one:

    } // close while loop

} // close if

else {
commented: great +1

Line 21 is a bracket, not a curly one. Line up your curly brackets, then you'll see the problem.

Line 21 is a bracket, not a curly one. Line up your curly brackets, then you'll see the problem.

It corrected it. But still there is a problem :(

At line 17 you're closing the paranthesis of the while loop, so add another one:

} // close while loop
} // close if
else {

This type of answer I looked for.
Dear friend,
can you explain more please?

  <body>
  <?php
      include('../../datab.php');
      if(!empty($_GET['ip'])) {
        $ip = $_GET['ip'];
        $ipcheck = mysql_query("SELECT * FROM `report` WHERE `ip`='$ip'");
        if(mysql_num_rows($ipcheck)> 0) {
            while($row = mysql_fetch_array($ipcheck)){
        ?>
          <p>Report ID : <?php echo $row['id'] ?></p>
        <?php
            }
        }
    } else
      {
        echo "Nothing Selected";
    }
     ?>
    </body>

You are basically trying to do this, just your tags got in the way.

this is wrong in your code.you have to use the folder name.this is only work in css.

include('../../datab.php');

replace

include('your folder/datab.php')

@jKidz

can you explain more please?

ok, if you open a conditional statement, before going to the next condition, you need to declare where you want to stop the execution of the code, you can do this by using a semicolon:

$num = rand(0,1);

if($num == 0)
    echo "empty";
else
    echo "not empty";

But in this case you cannot use more than a line of code for each condition. Then you can use colon:

if($num == 0):
    echo "empty";
else:
    echo "not empty";
endif;

But it's not much used. When you use parentheses it looks like:

if($num == 0)
{
    echo "empty";
}

else
{
    echo "not empty";
}

Now if you add a loop:

if($num == 0)
{
    echo "empty";

    while(true)
    {
        echo " loop";
        break;
    }

} // <-- this was missing in your code

else
{
    echo "not empty";
}

Pritaeas suggested you to align the curly brackets, because indenting correctly your code, helps to read and find problems easily.

Read:

@Sikander

you have to use the folder name.this is only work in css.

Hi, not correct, you can use relative paths in PHP and also with the include() function:

Bye!

commented: amazing bro +0

Nice Cereal.thanks for guidence..

@cereal

Thank you very much bro.
Its great :D
Thanks again

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.