[code=php]
function querydatabase ($query)
{
$db_host = ‘xxx’;
$db_name = ‘xxx’;
$db_user = ‘xxx’;
$db_pass = ‘xxx’;
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+)(sS+)(s.+)(sS+)(sS)/’,’\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.
what am I doing wrong