Greetz folks,
I have 2 question
I have a dump file that someone gave to me to help them with a project, the dump is in a .txt file, i am not sure how one would go about running a php command to load commands from a script file. I know in oracle u do something like @C:\path1\path2\filename.sql and execute this from the sql*plus interface. But in the world of php/mysql how would u go about executing this?
The other thing is this, how should the file itself be formated so that once u run it your capable to create the table and then the records in 1 go..
Im not sure but im thinking something like this.
$connect = mysql_connect("localhost", "root", "chhpdruq")
mysql_select_db ("eve"); to select the db
$cust = "CREATE TABLE customers (customer_id int(20) NOT NULL default '0',
firstname varchar(25) NOT NULL,
lastname varchar(25) NOT NULL,
email varchar(100) NOT NULL,
username char(200) NOT NULL,
password char(200) NOT NULL,
street char(100) NOT NULL,
city char(200) NOT NULL,
PRIMARY KEY (customer_ID)
) TYPE=MyISAM";
$results = mysql_query($cust)
or die (mysql_error());
echo "Table created!";
echo "<BR><BR><BR>";
$file = "C:\mysql5\bin\insert_for_customers.sql";
$contents = file($file);
foreach($contents as $line_num => $line_data) {
mysql_query("INSERT INTO (agtagents) VALUES ('{$line_data}');");
}
$results = mysql_query($line_data)
or die (mysql_error());
echo "Data Inserted!";