Md.muzahidul islam tanveer Md.muzahidul islam tanveer - 2 years ago 85
SQL Question

Mysqli update data if data exactly match with database

Already i successful to Insert data from sms and my sms content[$text_utf8] inserted by two columns[$p_n and $msg]. Now my question is

When the customer send a sms with a code[$p_n] [which was i provided]. The sms script find out the code[$p_n] from database if code[$p_n] exactly match with customer sms pin [$text_utf8, $p_n]. then update some columns like $msg and $phone.

$phone = $_GET["phone"];

$ix=strpos($text_utf8,' ');
if($ix!==false) {
$p_n=trim(substr($text_utf8, 0, $ix));
$msg=trim(substr($text_utf8, $ix+1));

if(strlen($p_n)!=0 && strlen($msg)!=0) {

$p_n = mysqli_real_escape_string($con, $p_n);
$msg = mysqli_real_escape_string($con, $msg);

// creating an sql statement to insert the message into the pin_man table
$sql="UPDATE smss SET msg='$msg' AND phone='$phone' WHERE p_n='$p_n'";
// executing the sql statement

Answer Source

query should be like this use , insted of and

$sql="UPDATE smss SET msg='$msg', phone='$phone' WHERE p_n='$p_n'";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download