PDA

View Full Version : uploading sql files via phpmyadmin problems


jeff132
10-11-05, 09:06 PM
i have a sql text file that i would like to upload into a table...when i select the file and click go i get this message "Your SQL query has been executed successfully:
The content of your file has been inserted. (xag.sql: 5923 Instructions) "...however when i browse the table it is completely empty...if i copy a few lines of the file directly into the web browser then it will insert the objects correctly...if i copy a few lines of the file into another file and upload the new file it will insert correctly...the file is a direct export from another mysql database in regular sql format...what could be the problem?

bnizzie
10-11-05, 11:38 PM
Here's a little PHP code I wrote to load mysqldump files into a database. I was having a problem moving a particularly large amount of data from the old host, and created this to assist with the loading of the data. Simply upload your SQL, adjust the USER/PASS/HOST/DATABASE and FILE params, and whammo.

Good luck! Hope it helps!

Go Go Go<br />
<?php
function query($sql) {
print substr($sql,0,20)." &lt;...&gt; ".substr($sql, -20, 20)."<br />";
mysql_query($sql) or die(mysql_error());
ob_flush();
flush();
}
$DB = mysql_connect('mysql13.powweb.com', 'USERNAME', 'PASSWORD') or die('suxor!');
mysql_select_db('DATABASE_NAME') or die ('database suxor!');
$file = fopen('../SQL_FILE.sql','r') or die('file suxor!');

$buffer = '';
while($line=fgets($file))
{
if (preg_match('/;\w*$/', $line))
{
query($buffer.$line);
$buffer = '';
}
else
$buffer .= $line;
}
if ($buffer != '')
{
query($buffer);
}
?>