miércoles, 21 de agosto de 2019

Ignore sqlsrv error

Array ( [0] => Array ( [0] => 01000 [SQLSTATE] => 01000 [1] => 0 [code] => 0 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]We Will Not Show Clicks,CTR and RPC Data For This Partner. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]We Will Not Show Clicks,CTR and RPC Data For This Partner. ) )

When a message, e.g. from a SQL 'print' statement is executed, the sqlsrv driver forwards it through sqlsrv_errors().
The default setting is to treat all warnings as errors, so your query will fail...
Set the feature to treat warning as errors to false like this, so that the messages will not fail your query:
sqlsrv_configure('WarningsReturnAsErrors',0);
Also, don't forget to call sqlsrv_next_result($yourStmt); to scroll through all of the warnings and results.  When sqlsrv_next_result() returns NULL, you have reached the end of all results without any errors.

domingo, 18 de agosto de 2019

passing a function results as argument to other function

<?php
$string="0:1027301|pe_id:1027301|1:ko ben|NAME:ko
 ben|2:0555532963|PHONE2:0555532963|3:07711111|PHONE1:07711111|";

echo $value=preg_replace('/[^0-9]+/', '', stristr(stristr($string, 'PHONE2'),'|',true));

?>
 we use 3 functions  (  2 times stristr()  and preg_replace()

search value of PHONE2:0555532963


sábado, 17 de agosto de 2019

php imap

<?php
/* connect to gmail */

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'oro14k1@gmail.com';
$password = '12231';

/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());

/* grab emails */
$emails = imap_search($inbox,'ALL');

/* if emails are returned, cycle through each... */
if($emails) {
 
 /* begin output var */
 $output = '';
 
 /* put the newest emails on top */
 rsort($emails);
 
 /* for every email... */
 foreach($emails as $email_number) {
  
  /* get information specific to this email */
  $overview = imap_fetch_overview($inbox,$email_number,0);
  $message = imap_fetchbody($inbox,$email_number,2);
  
  /* output the email header information */
  $output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
  $output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
  $output.= '<span class="from">'.$overview[0]->from.'</span>';
  $output.= '<span class="date">on '.$overview[0]->date.'</span>';
  $output.= '</div>';
  
  /* output the email body */
  $output.= '<div class="body">'.$message.'</div>';
 }
 
 echo imap_qprint($output);
} 

/* close the connection */
imap_close($inbox);

?>

viernes, 2 de agosto de 2019

php split

<?php

function clean($data){
$data=preg_replace('/[^0-9]+/', '', $data);
$data = str_split($data);
return $data;
}


$a=clean("812z5124zdd346");

print_r($a[0]);

print_r($a[1]);

print_r($a[2]);


this will only allow numbes and  create  an arrary from the string,   using function mode

php convert string to array str_split()

string
The input string.
split_length
Maximum length of the chunk.

Return Values ¶

If the optional split_length parameter is specified, the returned array will be broken down into chunks with each being split_length in length, otherwise each chunk will be one character in length.
FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string, the entire string is returned as the first (and only) array element.

Examples ¶

Example #1 Example uses of str_split()
<?php

$str 
"Hello Friend";
$arr1 str_split($str);$arr2 str_split($str3);
print_r($arr1);print_r($arr2);
?>
The above example will output:
Array
(
    [0] => H
    [1] => e
    [2] => l
    [3] => l
    [4] => o
    [5] =>
    [6] => F
    [7] => r
    [8] => i
    [9] => e
    [10] => n
    [11] => d
)

Array
(
    [0] => Hel
    [1] => lo
    [2] => Fri
    [3] => end
)