in reply to problem checking availability

This code has some issues...
  1. if ($PHONE, $ID_NUMBER) - That is equivalent to if ($ID_NUMBER). I guess you want an and or an or instead of the comma, but don't dare to guess.
  2. You assign an arrayref to $P (something like [ 1 ], and then compare this arrayref to the actual phone number. Under no circumstances will this be equal. Probably you want to test if $P->[0].
  3. You test $P eq $PHONE twice. The second test should probably test $ID->[0]
  4. You select from tbl1 and insert into tb11, that are two different tables (lowercase 'L' plus number 1 vs. number 11).
  5. You should always use strict and use warnings.
  6. You should use uppercase variable names only for constants.
  7. You should check for errors after your calls to execute.

Replies are listed 'Best First'.
Re^2: problem checking availability
by bigup401 (Pilgrim) on Sep 03, 2018 at 23:10 UTC

    i tried that already before. bt still was getting same results

    if ($PHONE) { $CHECK_PHONE = $DBH->prepare("SELECT COUNT(*) FROM tbl1 WHERE PHONE = +?"); $CHECK_EMAIL->execute($PHONE); $P = $CHECK_PHONE->fetchrow_arrayref(); if($E->[0]) { $error_phone = "phone exits"; } $CHECK_ID_NUMBER = $DBH->prepare("SELECT COUNT(*) FROM tbl1 WHERE ID_N +UMBER = ?"); $CHECK_ID_NUMBER->execute($ID_NUMBER); $ID = $CHECK_ID_NUMBER->fetchrow_arrayref(); if($ID->[0]) { $error_phone = "id exits"; } }

      Eliminating just one error isn't enough for software to work correctly. You need to eliminate all of them, preferably without introducing new ones. In your recent example I see a number of errors which you might have spotted if you had used use strict:

      1. You prepare a statement to $CHECK_PHONE and then execute it on $CHECK_EMAIL with the phone number as parameter. Calling fetchrow_arrayref on a statement which hasn't been executed will not return an array reference.
      2. Next you test for $E->[0] but $E has never been set.
      3. In both error branches you set the variable $error_phone.

      You should really try to provide a complete example, run it on your database and then post it, together with the result. We are still at a level where I just need to look at the code to spot several - new - problems.

        sorry its $check_phone

        am trying to pest a sample thing. how can it get solved