If statement problem

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

ashz
New php-forum User
New php-forum User
Posts: 14
Joined: Thu Oct 31, 2002 7:40 am

If statement problem

Postby ashz » Sun Nov 17, 2002 2:06 am

Hi,

The script described below receive the following input (output in the browser address windows: http://localhost/select1.php?nam=gate&num=+&desginer=+)

Script:
<html>
<head>
<title>Results</title>
</head>
<body>

<?php
if (($_GET['nam'] != "+") && ($_GET['num'] == "+") && ($_GET['designer'] == "+")) {
$d=$_GET['nam'];
$sen="name='$d'";
}

if (($_GET['nam'] == "+") && ($_GET['num'] != '+') && ($_GET['designer'] == '+')) {
$d=$_GET['num'];
$sen="no='$d'";
}

if (($_GET['nam'] == "+") && ($_GET['num'] == '+') && ($_GET['designer'] != '+')) {
$d=$_GET['designer'];
$sen="design='$d'";
}

print $sen;
?>

</body>
</html>

After running the script it seems to be that I have no output, is it a problem with the if statement? And how can I fix it.

Thanks.

User avatar
WiZARD
Moderator
Moderator
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Re: If statement problem

Postby WiZARD » Sun Nov 17, 2002 5:50 am

ashz wrote:Hi,

The script described below receive the following input (output in the browser address windows: http://localhost/select1.php?nam=gate&num=+&desginer=+)

Script:
<html>
<head>
<title>Results</title>
</head>
<body>

<?php
if (($_GET['nam'] != "+") && ($_GET['num'] == "+") && ($_GET['designer'] == "+")) {
$d=$_GET['nam'];
$sen="name='$d'";
}

if (($_GET['nam'] == "+") && ($_GET['num'] != '+') && ($_GET['designer'] == '+')) {
$d=$_GET['num'];
$sen="no='$d'";
}

if (($_GET['nam'] == "+") && ($_GET['num'] == '+') && ($_GET['designer'] != '+')) {
$d=$_GET['designer'];
$sen="design='$d'";
}

print $sen;
?>

</body>
</html>

After running the script it seems to be that I have no output, is it a problem with the if statement? And how can I fix it.

Thanks.


Change

Code: Select all

<?php
if (($_GET['nam'] != "+") && ($_GET['num'] == "+") && ($_GET['designer'] == "+")) {
$d=$_GET['nam'];
$sen="name='$d'";
}

if (($_GET['nam'] == "+") && ($_GET['num'] != '+') && ($_GET['designer'] == '+')) {
$d=$_GET['num'];
$sen="no='$d'";
}

if (($_GET['nam'] == "+") && ($_GET['num'] == '+') && ($_GET['designer'] != '+')) {
$d=$_GET['designer'];
$sen="design='$d'";
}

at

Code: Select all

<?php
if (($_GET['nam'] !== "+") && ($_GET['num'] == "+") && ($_GET['designer'] == "+")) {
$d=$_GET['nam'];
$sen="name='$d'";
}

if (($_GET['nam'] == "+") && ($_GET['num'] !== '+') && ($_GET['designer'] == '+')) {
$d=$_GET['num'];
$sen="no='$d'";
}

if (($_GET['nam'] == "+") && ($_GET['num'] == '+') && ($_GET['designer'] != '+')) {
$d=$_GET['designer'];
$sen="design='$d'";
}


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot] and 2 guests