function querydatabase ($query)
{
$db_host = 'localhost';
$db_name = 'localhost';
$db_user = 'localhost';
$db_pass = 'localhost';
mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db($db_name);
$result = mysql_query($query) or die(mysql_error());
mysql_close();
return $result;
}
$fp = fopen('./car.txt','r') or die ("it wont open");
while (!feof($fp) )
{
$line = fgets($fp);
$fred = preg_replace('/(\S+)(\s\S+)(\s.+)(\s\S+)(\s\S)/','\\1,\\2,\\3,\\4,\\5',$line);
$pieces = explode(",", $fred);
$query = "insert into cars(year, make, model, zeroToSixty, querterMile) values ('".trim($pieces[0])."','".trim($pieces[1])."','".trim($pieces[2])."',".trim($pieces[3]).",".trim($pieces[4]).")";
echo $query;
$result = querydatabase ($query) or die(echo mysql_error());
}
fclose($fp);
runs once then stops. Never inserts data. I know the query is good so I must have something wrong somewhere. Are the dies in the right place? I am recieveing no errors.
I know the query is good, what am I doing wrong