Mysql Error After Fresh Install
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
This error shows sometimes when you fresh install mysql at linux server… as sock is not present by default you just need to follow the following steps.
- Open Terminal
- cd /var/lib/mysql/
- touch mysql.sock
- chown mysql:mysql mysql.sock
- chmod 1777 mysql.sock
- n -s /var/lib/mysql/mysql.sock /tmp
- chown -R mysql.mysql /var/lib/mysq
- chmod 777 /tmp
- chmod 777 /var/tmp
- su mysql
- killall -s KILL mysqld
- service mysqld restart
It should work fine now.. let me know if you still got any problem
All cities of the world, all countries and country languages tables and data SQL
This mysqli .SQL contains tables with all most complete list of cities, all countries of the world and languages spoken in whole world.
Click Here to Download
Namespaces in PHP 5.3.0
In the broadest definition namespaces are a way of encapsulating items. This can be seen as an abstract concept in many places.
programming world.
- Name collisions between code you create, and internal PHP classes/functions/constants or third-party classes/functions/constants.
- Ability to alias (or shorten) Extra_Long_Names designed to alleviate the first problem, improving readability of source code.
Defining namespaces
Although any valid PHP code can be contained within a namespace, only three types of code are affected by namespaces: classes, functions and constants.
Namespaces are declared using the namespace keyword. A file containing a namespace must declare the namespace at the top of the file before any other code – with one exception: the declare keyword.
<?php
namespace MyProject;
const CONNECT_OK = 1;
class Connection { /* … */ }
function connect() { /* … */ }
?>
The only code construct allowed before a namespace declaration is the declare statement, for defining encoding of a source file. In addition, no non-PHP code may precede a namespace declaration, including extra whitespace:
<html>
<?php
namespace MyProject; // fatal error - namespace must be the first statement in the script
?>
In addition, unlike any other PHP construct, the same namespace may be defined in multiple files, allowing splitting up of a namespace’s contents across the filesystem.
How to accept mutiple lines in a normal textarea tag
Very Simple - no need to do anything in html form tag.
While accepting the posted values just replace new line:
“\n” with “<br/>”
$_POST['address'] = str_replace(“\n”,”<br/>”,$_POST['address']);
and while reading the values from database and putting it back in the textarea for editing/updating just do its reverse.
$comArr['company_address'] = str_replace("<br/>","\n",$comArr['company_address']);
