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

Member Avatar for LastMitch

@johnnyd1963

how can i tell in php that

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

In order to do that you need to used this:

$a === $b Identical TRUE if $a is equal to $b, and they are of the same type.

Read this:

http://php.net/manual/en/language.operators.comparison.php

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

Member Avatar for Zagga

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.

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

Member Avatar for LastMitch

@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

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

Thanks for the help

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';

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()">

onkeyup="myFunction()"> must bee onkeyup="copyText()">

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

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.