Hello, I am having an issue here. I am trying to get my script to read a txt file one line at a time and import it into my mySQL database. I have been at it for hours and I know it's something silly. Here are the errors:
Warning: filesize() [function.filesize]: stat failed for Resource id #5459 in /home/innoparc/public_html/dev/member/loaddb.php on line 14
Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/innoparc/public_html/dev/member/loaddb.php on line 14
& Here is my code:
<?php
$con = mysql_connect("localhost","user","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$dbu = 'site_'.$siteuser;
mysql_select_db( $dbu ) or die('Cannot select database');
$fp = fopen("default.txt", "r");
while(! feof($fp))
{
$query = fread($fp, filesize($fp));
}
fclose($fp);
$result = mysql_query($query);
mysql_close($con);
echo $result;
?>
What am I doing wrong?? Thanks in advance.