php - Extracting Number and Select DB using the extracted Number -


i have php class piping/reading email sent particular email id, , insert database table. code work fine. wanted extract list of number in body of mail start "1011" , use query database. body ($this->body) can have 1 or 10 number start 1011. want use "1011" select database necessary information, , insert same table. not working. if remove select query, i'm able insert "1011" directly table. want first select parameter before inserting "1011". pls me!!!

    $matches = array();     $pieces = explode(php_eol, $this->body);     $matches = preg_grep("/1011/", $pieces);     //$results = implode(" | ",array_values($matches));     //echo "terminal ids: ".$results." ";     foreach ($matches $columns)     {     $select = $this->pdo->query("select * tbl_atm_data1 terminal_id = '$columns' ");     $select = $select->fetchall();     if(count($select) > 0) {     foreach($select $row) {     $this->sol_id =$row['sol_id'];     $this->timers =$row['timers'];     $this->atm_name=$row['atm_name'];     $this->terminal_id =$row['terminal_id'];  $insertfile = $this->pdo->prepare("insert    tbl_request_dump1(terminal_id,sol_id,timers,atm_name) values (:terminal_id,:sol_id,:timers,:atm_name)");  $insertfile ->bindparam(':terminal_id', $columns);  $insertfile ->bindparam(':sol_id', $this->sol_id);  $insertfile ->bindparam(':timers', $this->timers);  $insertfile ->bindparam(':atm_name',  $this->atm_name);              $insertfile->execute();  } }else {             echo "no terminal id need save";             die();         }  } 

i noticed database table terminal_id integer datatype, converted $column integer work fine!

  $term=(int)$columns;    $select = $this->pdo->query("select * tbl_atm_data1 terminal_id = '$term'"); 

thanks!


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -