lovephp Posted November 15, 2012 Share Posted November 15, 2012 guys is this the right way to check if a phone number already exist? ////////////////////////////////////Check Phone Exist function phoneNoExist($phoneExist) { $sql = "SELECT * FROM table WHERE homenumber='".$phoneExist."'"; $rs = executeSql($sql); if(mysql_num_rows($rs) == 1) { return true; } else { return false; } } i get a error currently which is, say i have already inserted 9054567894 and when i try to insert another number like 9057445671 i get number already exist why? Quote Link to comment https://forums.phpfreaks.com/topic/270751-check-duplicasy/ Share on other sites More sharing options...
Barand Posted November 15, 2012 Share Posted November 15, 2012 Why don't you try turning error_reporting on? At top of script error_reporting(-1); Quote Link to comment https://forums.phpfreaks.com/topic/270751-check-duplicasy/#findComment-1392748 Share on other sites More sharing options...
lovephp Posted November 15, 2012 Author Share Posted November 15, 2012 its on i think it with the sql query? this happens whn users copy and paste details from notepad and word file. when they submit from error message says phone number already exist for some numbers tho thy do not exist. Quote Link to comment https://forums.phpfreaks.com/topic/270751-check-duplicasy/#findComment-1392752 Share on other sites More sharing options...
JD* Posted November 19, 2012 Share Posted November 19, 2012 Try this: Echo out your SQL statement to the page, then do a die(); Then execute your SQL statement directly into the database (MySQL Workbench is good for this) and see if you get the error there. ////////////////////////////////////Check Phone Exist function phoneNoExist($phoneExist) { $sql = "SELECT * FROM table WHERE homenumber='".$phoneExist."'"; die($sql); $rs = executeSql($sql); if(mysql_num_rows($rs) == 1) { return true; } else { return false; } } Quote Link to comment https://forums.phpfreaks.com/topic/270751-check-duplicasy/#findComment-1393489 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.