Assuming we have the following entry in our database: /go/123456 But we require: go/123456 UPDATE `TABLENAME` SET `FIELDNAME` = SUBSTRING(`FIELDNAME`, 2) WHERE `FIELDNAME` LIKE `/%`;
Replace String In Database Field
The following code will replace a string in a database field UPDATE `TableName` SET `DatabaseField` = REPLACE(`DatabaseField`, ‘OldString’, ‘NewString’) WHERE `DatabaseField` LIKE ‘%OldString%’;
Simple PHP Mailer Function
Send an email with PHP – useful for a simple contact form if (isset($_POST[‘submit’])) // Your submit button or a required form field { $EmailTo […]
Rename SQL Table
If you wish to rename a SQL table use the following code: ALTER TABLE table_name RENAME TO new_table_name;
Add an Index to a MySQL Table
An index speeds up the serving of data by allowing you to quickly find data in a table without having to go row by row […]
Split A Large MySQL Table Into Multiple SQL Files
If you have a large database table that is causing your import to fail, you can split the table out into smaller more manageable chunks […]
Copy MYSQL Table Structure and Import Specific Columns
This code will allow you to copy the table structure from an existing table into a new one and then copy data from specific columns […]
Notepad++ Exclude File Types from Find In Files
Use the following filter to disallow certain file types from being searched when searching multiple files: *.* !*.png !*.jpg !*.jpeg !*.webp !*.bmp !*.gif !*.mp4
Add Custom Image & Thumbnail Upload MetaBox To WordPress
This creates a custom metabox for posts and pages and allows us to upload an image. Copy it into your child theme’s functions.php file NOTE: […]
Add A Primary Key To A Table In MYSQL
Run the following code to amend an existing column into a Primary Key ALTER TABLE `wp_posts` ADD PRIMARY KEY (`ID`), MODIFY `ID` bigint(20) UNSIGNED NOT […]