Category : PHP

Change MYSQL table column type while in relationship

Some times, You will find yourself trapped into a situation where you need to change a column datatype or length, But this column is already used in PK-FK relationship and the solution for this is disable the SET foreign_key_checks = 0; then change the datatype and then re-enable it after you finish the update.

French characters encoding

Some times you will face a problem with french?other language characters in your web page that are not being displayed correctly. Such as instead of apostrophe.. And the solution lies in sing the meta charset='utf-8' in your page header. and also to convert the encoding of this piece of data to utf. Sometimes you might find our this is encoded twice, then you will need to decode it or convert to iso then to utf-8 again. Here are some few suggestions

MYSQL Get column names concatenated

If you want to get a table column names from mysql database as a concatenated string, you can use the following code

Data scraping using guzzle HTTP

This snippet will teach you how to scrape data from any website using guzzle http with php

MYSQL swap two fileds values in mySql

If you have a table and want to swap two field values together, here is a simple snippet.

From Excel to SQL Query

If you have data in an Excel sheet and would like to create a sql query to add/insert data here is the way,

disable dates before today in input type date

this snippet will teach you how to disable dates before today in input type date

Get unique values from multi-dimensional array

Sometimes you have a multi-dimensional array and you only need the unique arrays in it. here is a simple solution using pure php function

Increase memory size or execution time

In case you wanted to increase memory size or loading or execution time here is this small snippet

Mysql timestamp to date

To convert a mysql date to an ordinary date you can use the following snippet