Archive | February 2012

You are browsing the site archives by date.

How to import .sql file in mysql using php

<?php          $con = mysql_connect(“localhost”, “root”, “admin”) or die(“Database connection failed: “.mysql_error());     $db = mysql_select_db(“SQL_FILE”, $con) or die(“Database selectio failed: “.mysql_error()); $path = //your file path $sql_filename = ‘wp_options.sql’; $sql_contents = file_get_contents($path.$sql_filename); $sql_contents = explode(“@@”, $sql_contents); foreach($sql_contents as $query){        $result = mysql_query($query) or die(“Database query failed: “.mysql_error()); } ?> Advertisements