0

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?

Edited by jKidz

Attachments vYb5z.jpg 74.68 KB
5
Contributors
9
Replies
35
Views
3 Years
Discussion Span
Last Post by jKidz
1

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

    } // close while loop

} // close if

else {
Votes + Comments
great
0

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 :(

0

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?

0
  <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.

0

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')
2

@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!

Votes + Comments
amazing bro
0

@cereal

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.