Jump to content

How to load the sql file in mysql in PHP


phpmady

Recommended Posts

Hi,

 

I want to load the sample sql file in mysql, how to do in php

 

Thank you

 

something like this.

 

 

$sql = file_get_contents($_FILES['file']);

$sql = trim($sql);

 

mysql_connect('localhost','root','');

mysql_select_db('test');

mysql_query($sql);

 

 

Hi,

 

I want to load the sample sql file in mysql, how to do in php

 

Thank you

 

something like this.

 

 

$sql = file_get_contents($_FILES['file']);

$sql = trim($sql);

 

mysql_connect('localhost','root','');

mysql_select_db('test');

mysql_query($sql);

 

Hi,

 

this one creating db but not creating tables in db, whats am doing wrong

Hi,

 

I want to load the sample sql file in mysql, how to do in php

 

Thank you

 

something like this.

 

 

$sql = file_get_contents($_FILES['file']);

$sql = trim($sql);

 

mysql_connect('localhost','root','');

mysql_select_db('test');

mysql_query($sql);

 

Hi,

 

this one creating db but not creating tables in db, whats am doing wrong

 

thank You for ur hand, solved

Hi,

 

I want to load the sample sql file in mysql, how to do in php

 

Thank you

 

something like this.

 

 

$sql = file_get_contents($_FILES['file']);

$sql = trim($sql);

 

mysql_connect('localhost','root','');

mysql_select_db('test');

mysql_query($sql);

 

Hi,

 

this one creating db but not creating tables in db, whats am doing wrong

 

thank You for ur hand, solved

 

Hi,

 

I thought it was solved but still persists, i cannot load the file in mysql database,, pls give me ur hand whats am doing wrong, below is the code am using

 

mysql_connect($hostname,$username,$password) or die(mysql_error());

	//create the database here and pass down the statement


	$query  = "CREATE DATABASE $dbname";
	$result = mysql_query($query);

	mysql_select_db($dbname) or die(mysql_error());	


	$queryFile = 'cmstouch2.sql';




	$sql1 = file_get_contents($queryFile); 
	$sql = trim($sql1); 

	$result = mysql_query($sql);


	if($result)
		{
	echo "sucess";
	}
	else
	{
	echo "failed";
	}

 

 

thank You

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.