Pdo get column names

March 1st, 2010 § 0

PHP’s Pdo doesnt have a default columnname function. After searching Google I found that many people seem to be looking for this function. You can get the columnnames with an easy query to the schema:

$querystring = “SELECT * FROM INFORMATION_SCHEMA.Columns where TABLE_NAME = $table”;

Related Blogs

  • Related Blogs on

searching mysql for a columnname

February 27th, 2009 § 0

SELECT table_name,column_name
FROM  information_schema.COLUMNS
WHERE table_schema = ‘your database here’
and column_name = ‘your columname here’

Mysql: find wrong emailadres

December 11th, 2008 § 0

SELECT  Email FROM Emails where Email not REGEXP ‘^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}$’ and Email != “”

PHPMyAdmin: Table specific privileges

November 14th, 2008 § 0

If you like to grant a user special privileges, like for example, only run select queries on a table, then PHPMyAdmin is your friend.

1. Go to the user settings
2. leave the global settings blank
3. under database specific, choose your database.
4. in the table specific, opt for the table you wish to add.
5. in the select column, select all fields that can be used for select queries.
6. check show_view and Create_view

That’s all :)

PHP, MySQL and utf-8

October 27th, 2008 § 0

When creating forms with french content, I got strange characters in my database.
The solution was to put some utf-8 declaration at the top of the php pages and to add some extra code for mysql.

php:

<?
php header(’content-type: text/html; charset: utf-8′);
mb_internal_encoding( ‘UTF-8′ );
?>

MySQL:
add the following code after you make a connection and before you run a query
mysql_query(”SET NAMES ‘utf8′”);
mysql_query(”SET CHARACTER SET utf8″);

Additionally you could also add accept-charset=”utf-8″ to your form tags.

Where Am I?

You are currently browsing the MySQL category at westworld: a webmasters best friend.