0

how can i tell in php that

01 is not equal to 1
and
1 not equal to 01

so that i can insert it in the data table

            $startnummer= ($_POST['Startnummer']);

            $query9 = mysql_query("SELECT werkelijkstartnummer,startnummer,turnier_jaar FROM narr_turnier_".$onlyconsonants." UNION ALL SELECT werkelijkstartnummer,startnummer,turnier_jaar FROM narr_turnier_".$onlyconsonants."_ster WHERE turnier_jaar=".$jaarnu." && startnummer = ".$startnummer." ");

            while($row9 = mysql_fetch_array($query9))
            {

            $startnummerdouble = $row9['startnumber'];
            }

            if ($startnummer == $startnummerdubbel)

            {
            give warning that it is the same
            }
            else
            {
            insert into table
            }

Thanks in advice John

4
Contributors
10
Replies
11
Views
4 Years
Discussion Span
Last Post by johnnyd1963
0

Hi,
It may be a typo, but on line 8 you set $row9['startnumber'] as a variable, but you did not select 'startnumber' to be returned by your query.

As integers, 01 IS equal to 1 so you may need to compare them as strings, perhaps count the number of characters.

0

no $row9['startnumber'] is as VARCHAR because otherwise i can not put 01 into the table.

and === or !== dos not work because when i use it and i put again for the second time 01 in the post then i have twice times 01 in the table and i want it only one time in the table even with 2 and 02 and so on.

i tought that 01 and 1 is different in VARCHAR so as i see it is the same

Edited by johnnyd1963

0

@johnnyd1963

and === or !== dos not work because when i use it and i put again for the second time 01 in the post then i have twice times 01 in the table and i want it only one time in the table even with 2 and 02 and so on.

I think pritaeas already mention this:

IF both are assigned as ints, then this will not work.

he meant this you can't used both at the same time:

01 is not equal to 1
and
1 not equal to 01

Then you need to find another way. Your option is very limited.

Just choose one

either

1 not equal to 01

or

01 is not equal to 1

0

oke thanks i made an other way
i make 01 to 0-1
and that works

Thanks for the help

0

i tought that 01 and 1 is different in VARCHAR so as i see it is the same

Just to explain. When comparing varchars "01" with "1" PHP detects that they can be cast to integers and does so (1 == 1). Perhaps the following works (cannot try now):

$a = '1';
$b = '01';
if ((string)$a === (string)$b) 
    echo 'equal';
else
    echo 'not equal';
0

i have a great solution i put a javascript into it

so people can not input 01 02 03 04 05 06 and so on

so they can type 0-1, 0-2 and so on.

here i have it

function copyText() {



    var x=document.getElementById("source1").value;
if (x==01 || x==02 || x==03 || x==04 || x==05 || x==06 || x==07 || x==08 || x==09 || x==010 || x==011 || x==012)
  {

 if(confirm("You can not type 01 or 02 a.s.o.\ninstead of 01, 02 ... type 0-1 or 0-2 a.s.o. ")) document.getElementById("source1").value = '';
 else
 {
 document.getElementById("source1").value = '';
 }

  }

and for the input

<input type="text" id="source1" name="Startnummer" onkeyup="myFunction()">

Edited by johnnyd1963

0

and (x==01 || x==02 || x==03 || x==04 || x==05 || x==06 || x==07 || x==08 || x==09 || x==010 || x==011 || x==012)

must be

(x=='01' || x=='02' || x=='03' || x=='04' || x=='05' || x=='06' || x=='07' || x=='08' || x=='09' || x=='010' || x=='011' || x=='012')

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.