I store sms received from twilio in the database, so I can use them later. When I did this in the sandbox, it worked. However, when I updated to my regular phone number, the received number matches the one that was sent, but +1 (or for xxxxxxxxxx, where x is the original number, it looks more like 1xxxxxxxxxx +)
So I changed mysql_query to the following: but it still doesn't work. What can be done to recognize that this is the original phone number?
<?php $starttime = time(); $number = $_POST['number']; $number1 = "1" . $number; $number2 = $number . "1"; $number3 = "+1" . $number; $number4 = $number . "+1"; $number5 = "+" . $number . "1"; $number6 = "1" . $number . "+"; $number7 = $number."1+"; $received = mysql_query("SELECT * FROM sms_received WHERE (responder='$number' OR responder='$number1' OR responder='$number2' OR responder='$number3' OR responder='$number4' OR responder='$number5' OR responder='$number6' OR responder='$number6') AND (body='y' OR body='yes' OR body='Y' OR body='Yes' OR 'yea' OR 'Yea') AND timestamp BETWEEN ".date('Ymd H:i:s', strtotime($starttime))." AND NOW()"); ?>
But still nothing was received. Any ideas, how else can I check if sms is received from the user? I see in the database that it is there ... but mysql does not find it. It worked earlier when the number sent was identical to the quantity received from it, but with the added +1 it twists it. (the code before it was only WHERE responder = '$number' , and it worked, but the additional variables did not help him). Does this code have too much OR? Is that even a problem?
UPDATE:
Thank you, here is the function I use to split the number to xxxxxxxxxx format before storing it in the database:
function checkPhone($responder){ $items = Array('/\ /', '/\+/', '/\-/', '/\./', '/\,/', '/\(/', '/\)/', '/[a-zA-Z]/'); $clean = preg_replace($items, '', $responder); if (substr($clean, 0, 1) == "1") { return substr($clean, 1, 10); } else { return substr($clean, 0, 10); } } $number = checkPhone($responder);