Showing posts with label Database. Show all posts
Showing posts with label Database. Show all posts
Monday, February 27, 2012
Import CVS , Excel or XML file into MySQL with php
When we want to insert data into MYSQL which is already present in .CVS (comma separated values) or XML or Excel files. Reading the file row by row (say in PHP) and inserting into MYSQL is very poor style of coding which is inefficient and takes a lot of time. MYSQL has an inbuilt query and I will be elaborating about this.
Convert Unix Timestamp To MySQL Timestamp
PHP date functions such as strtotime() and time() and date() all return a value as a UNIX TIMESTAMP. This is great for date manipulation but becomes a problem when we need a date to INSERT into a MySQL database. The format of a MySQL TIMESTAMP is yyyy-mm-dd hh:mm:ss and to meet this need a simple PHP can be utilized to convert any UNIX TIMESTAMP into a MySQL TIMESTAMP.
Code and use of function is:
Code and use of function is:
Thursday, December 22, 2011
Connect localhost with php
We use php language to connect sarver with MySql.
Code:
[php]
<?php
$con = mysql_connect("hostname","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
?>
[/php]
In apache sarver host name is "localhost", username is "root" and password is null ("") but in zend sarver host name is "localhost", username is "root" and password is "root123" what you have set.
Code:
[php]
<?php
$con = mysql_connect("hostname","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
?>
[/php]
In apache sarver host name is "localhost", username is "root" and password is null ("") but in zend sarver host name is "localhost", username is "root" and password is "root123" what you have set.
Subscribe to:
Posts (Atom)