PHP – Use glob() to search for specific file-names in a directory

PHP – Use glob() to search for specific file-names in a directory
/*
Folder with image files contains:

../test_images_folder/21548.JPG
../test_images_folder/21548_1.JPG
../test_images_folder/21548_2.JPG
../test_images_folder/21548_3.JPG
../test_images_folder/21548_4.JPG
../test_images_folder/21548_5.JPG
../test_images_folder/21548_6.JPG
../test_images_folder/22222_5.JPG

*/



$image = "21548";// string to match image file name

foreach(glob("../test_images_folder/*".$image."*") as $filename){

     echo "$filename";

}

/*
Above ‘glob() usage will return:

../test_images_folder/21548.JPG
../test_images_folder/21548_1.JPG
../test_images_folder/21548_2.JPG
../test_images_folder/21548_3.JPG
../test_images_folder/21548_4.JPG
../test_images_folder/21548_5.JPG
../test_images_folder/21548_6.JPG

*/
[SHORTCODE_Insert_Google_Adsence_Here]
 

Regards,

Ken

MySQL said: Incorrect integer value: ” for column ‘your_column’

Later versions of MySQL (my current version MySQL 5.6) will throw an error, if attempting to insert empty (i.e. '') values into a row with INT settings - even with NULL set to "YES"
ERROR: "MySQL said: Incorrect integer value: '' for column 'your_column'"

[SHORTCODE_Insert_Google_Adsence_Here]
You can prevent this error with PHP/MySQL, with a disable of  “STRICT_TRANS_TABLES" - which is triggering the error, on the empty string, you are trying to insert.

$My_Query = " SET SESSION sql_mode= 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; ";
 *No spaces between the commas

Set it back after if you like… Although I belive it is automatically set back.

SET SESSION sql_mode= 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' 


*No spaces between the commas

See what your MySQL says about the current settings via phpMyAdmin:

SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.sql_mode;

Multiple Javascript .replace(), Regular Expression – String Replace Instances – In One Call, On Multiple Lines

Multiple Javascript .replace(), Regular Expression – String Replace Instances – In One Call, On Multiple Lines

[code]

for(var i=0; i<Open_Client_Files_Tabs_Cookie_Arr_G.length; i++){

 

My_Add_New_Open_Client_Files_Tab_Prototype = Add_New_Open_File_Tab_Prototype_G.replace(/~FLUCTUATING_COUNT~/g, i).
replace(/~FLUCTUATING_LAST_NAME~/g, Open_Client_Files_Tabs_Cookie_Arr_G[i].split(“~”)[0]).
replace(/~FLUCTUATING_FIRST_NAME~/g, Open_Client_Files_Tabs_Cookie_Arr_G[i].split(“~”)[1]);

 

}

[/code]
[SHORTCODE_Insert_Google_Adsence_Here]

CodeIgniter PHP $this->db->where() Multiple AND Conditions

CodeIgniter multiple AND conditions

Trying to achieve the basic PHP/MySQL call of multiple conditions with ‘AND’ ? i.e:

[code]UPDATE `MY_TABLE` SET `NAME` = ‘Frank’ WHERE `ID` =  ‘557’ AND `OWNER_ID` = ’22’;[/code]

This can be achieved in code igniter with multiple ‘$this->db->where()‘ functions preceding the ‘$this->db->update()‘ call – like this:

[code]$My_New_Data_Array = array(‘NAME’ => ‘Frank’);

$this->db->where(‘ID’, ‘557’);

$this->db->where(‘OWNER_ID’, ’22’);

$this->db->update(‘MY_TABLE’, $My_New_Data_Array);[/code]

——-
[SHORTCODE_Insert_Google_Adsence_Here]
OR, you can pass the multiple conditions to the ‘$this->db->where()‘ function in an array – like this:

[code]$My_New_Data_Array = array(‘NAME’ => ‘Frank’);

$My_Multiple_Statements_Array = array(‘ID’ => ‘ 557’, ‘OWNER_ID’ => ’22’);

$this->db->where($My_Multiple_Statements_Array);

$this->db->update(‘MY_TABLE’, $My_New_Data_Array);[/code]