Looking for some help with this please.
The code below worked fine until the website was moved to a new web server.
The file structure is set up exactly the same but the version of php is higher on the new server. The code below is set up so that it reads data from a .txt file into a mysql table. Proble is its now not working and keeps returning an error saying "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near "
Really needing some help with this as I don’t know whats wrong with it. As always any help greatly appreciated, thanks in advance.
$myFile = "data.txt";
$fh = fopen($myFile, 'r');
while(!feof($fh))
{
$data = fgets($fh);
list($data1,$data2) = explode('"',$data,2);
$data2 = str_replace(array("'", '*', '£', 'é'),array('#', '', '£', 'é'),$data2);//replaces comma's with hash mark to insert into db correctly
//$data2 = str_replace(array("'",'"'),array('*',''),$data2);//replaces apostrophe with star to insert into db correctly
$data = explode('","',$data1.$data2);
print_r ($data);
//foreach($data as $row){
$query = "INSERT INTO Used_Stock ('Feed_Id', 'Vehicle_Id', 'Full_Registration', 'Colour', 'Fuel_Type', 'Year', 'Mileage', 'Body_Type', 'Doors', 'Make', 'Model', 'Variant', 'Engine_Size', 'Price', 'Transmission', 'Picture_Refs', 'Service_History', 'Previous_Owner', 'Category', 'Four_Wheel_Drive', 'Options', 'Comments', 'New', 'Used', 'Site', 'Origin', 'V5', 'Condition', 'ExDemo', 'Franchise_Approved', 'Trade_Price', 'Trade_Price_Extra', 'Service_History_Text', 'Cap_Id', 'Type') VALUES ('".$data[0]."', '".$data[1]."', '".$data[2]."' , '".$data[3]."', '".$data[4]."', '".$data[5]."', '".$data[6]."', '".$data[7]."', '".$data[8]."', '".$data[9]."', '".$data[10]."', '".$data[11]."', '".$data[12]."', '".$data[13]."', '".$data[14]."', '".$data[15]."', '".$data[16]."', '".$data[17]."', '".$data[18]."', '".$data[19]."', '".$data[20]."', '".$data[21]."', '".$data[22]."', '".$data[23]."', '".$data[24]."', '".$data[25]."', '".$data[26]."', '".$data[27]."', '".$data[28]."', '".$data[29]."', '".$data[30]."', '".$data[31]."', '".$data[32]."', '".$data[33]."','2')";
mysql_query($query) or die(mysql_error());
print_r ($row);
//}
//echo 'What a Success';
}