Re: Newbie Question $2

From: Date: Tue, 17 Jun 2014 14:40:50 +0000
Subject: Re: Newbie Question $2
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-48860@lists.php.net to get a copy of this message
Finally figured out what the question was! Here's a better version of your code Ethan: $phn = $_POST['phone']; // note the quotes on the index if (strlen($phn) <> 10) { echo "Error in phone number entry - must be 10 digits"; exit(); } $phn = mysqli_real_escape_string($cxn,$phn); $masked_phone = substr($phn,0,3) . "-".substr($phn,3,3). "-". substr($phn,6,4); $sql1 = "select Lname, Fname from Customers where Phone = '$masked_phone'"; // note use of diff quotes $result1 = mysqli_query($cxn, $sql1); if (mysqli_num_rows($result1) == 0) { echo "Phone number $masked_phone not on file"; exit(); } else { echo "Found {$result1['Fname']} {$result1['Lname']} is on file with number $masked_phone"; exit(); }

« previous php.db (#48860) next »