phpmyadmin configuration A relatively simple method in php to import the sql file generated by phpmyadmin

WBOY
Release: 2016-07-29 08:45:50
Original
1096 people have browsed it

We know that many forums or personal blog programs downloaded from the Internet have installation pages. To make such an installation program, you need to use a sql file to create a database.
Only valid for sql files exported by phpmyadmin

Copy the code The code is as follows:


$dbfile="test.sql";
$c
//Get the created data
//Remove the comments
$c /--.*n/iU","",$content);
//Replace prefix
$c
$carr=array();
$iarr=array();
//Extract create
preg_match_all(" /Create table .*(.*).*;/iUs",$content,$carr);
$carr=$carr[0];
foreach($carr as $c)
{
@mysql_query($c ,$link);
}
//Extract insert
preg_match_all("/INSERT INTO .*(.*);/iUs",$content,$iarr);
$iarr=$iarr[0];
// Insert data
foreach($iarr as $c)
{
@mysql_query($c,$link);
}

The above introduces the relatively simple method of phpmyadmin configuration in php to import the sql file generated by phpmyadmin, including the content of phpmyadmin configuration. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!