php - Checking SQL Database for value -


i trying use php check database see if value exists. main goal use value

$_get['udid'] 

and if equal value in database return

echo 'found'; 

i using code:

<?php  $servername = "*****"; $username = "*****"; $password = "*****"; $dbname = "*****"; $connect = new mysqli($servername, $username, $password, $dbname); if ($connect->connect_error) {     die("connection failed: " . $connect->connect_error); }  $udid = $_get['udid']; $id = mysqli_real_escape_string($connect, $udid);  $result = mysqli_query($connect, "select udid data udid = '$id'");  if($result === false) {    die("error: " . mysqli_error($result)); } else {     while ($row = mysqli_fetch_array($result)) {            if($row['udid'] == $udid) {               $results = 'your device registered on our servers.';               $results2 = 'please click install button below.';               $button = 'install';               $buttonlink = 'https://**link here**';           }           else {               $results = 'your device not registered on our servers';               $results2 = 'please click request access button below.';               $button = 'request access';               $buttonlink = 'https://**link here**';           }     } }  ?> 

but reason not working, sure on looking something. appreciated.

try this:

$sql = mysqli_query($connect, "select udid data udid = '" .$udid. "'"); 

and also, make sure set value 'get' $udid. should this:

$udid = $_get['udid']; 

we can use mysqli_fetch_array() instead result row. include error handling. code must :

$udid = $_get['udid']; $id = mysqli_real_escape_string($connect, $udid);  $result = mysqli_query($connect, "select `udid` `wmaystec_wmt-ss`.`data` = '$id'");  if($result === false) {    die(mysqli_error("error message user")); //error handling } else {     while ($row = mysqli_fetch_array($result)) {            echo "found :" .$row['thefieldnameofudidfromyourdb'];     } } 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -