$sqlline = "INSERT INTO `iptoc` (`IP_FROM` , `IP_TO` , `country_code` , `country_code2` , `country_name` ) VALUES (";
'trivial' problem
Moderator: General Moderators
'trivial' problem
why wont the following line parse? I'm just trying to define a string 
$sqlline = "INSERT INTO `iptoc` (`IP_FROM` , `IP_TO` , `country_code` , `country_code2` , `country_name` ) VALUES (";
$sqlline = "INSERT INTO `iptoc` (`IP_FROM` , `IP_TO` , `country_code` , `country_code2` , `country_name` ) VALUES (";
Theres no end parentheses
Code: Select all
$sqlline = "INSERT INTO `iptoc` (`IP_FROM` , `IP_TO` , `country_code` , `country_code2` , `country_name` ) VALUES (");-
Bennettman
- Forum Contributor
- Posts: 130
- Joined: Sat Jun 15, 2002 3:58 pm
- scorphus
- Forum Regular
- Posts: 589
- Joined: Fri May 09, 2003 11:53 pm
- Location: Belo Horizonte, Brazil
- Contact:
Re: 'trivial' problem
What is rising the parse error, PHP or MySQL? What is the parse error message? Should not be PHP because there is no problem with PHP parsing this string. Maybe it is another line just as Bennettman said. Please post the error message.
here is the whole file. I'm trying to read one file line by line and output it into many other files each with the same quote inserted at the beginning. You were right, there isn't a problem with that line, I moved it out of the for loop and it works fine. The parse error is on the print line (line 11)
the error message is:
Parse error: parse error in changedata.php on line 11
this is the file:
<?
$fileread=fopen("/iptocountry/ip-to-country.csv","r+");
$sqlline= "INSERT INTO `iptoc` (`IP_FROM` , `IP_TO` , `country_code` , `country_code2` , `country_name` ) VALUES (";
for($filename=0;!feof($fileread);$filename++){
//open a new file to store the next 600 lines in
$filewrite=fopen("/iptocountry/".#filename.".txt", "a");
//insert the first line of mysql
print $sqlline;
fwrite($filewrite, $sqlline);
//read and insert the first line of data
$line=fgets($fileread);
fwrite($filewrite,"),(".$line);
//read and write the next 599
for($linenumber=2;$linenumber<601;$linenumber++){
$line=fgets($fileread);
fwrite($filewrite,"),(".$line);
}
//put the closing ) in for mysql use
fwrite(#filewrite,")");
fclose($filewrite);
}
fclose($fileread);
echo "done"
?>
the error message is:
Parse error: parse error in changedata.php on line 11
this is the file:
<?
$fileread=fopen("/iptocountry/ip-to-country.csv","r+");
$sqlline= "INSERT INTO `iptoc` (`IP_FROM` , `IP_TO` , `country_code` , `country_code2` , `country_name` ) VALUES (";
for($filename=0;!feof($fileread);$filename++){
//open a new file to store the next 600 lines in
$filewrite=fopen("/iptocountry/".#filename.".txt", "a");
//insert the first line of mysql
print $sqlline;
fwrite($filewrite, $sqlline);
//read and insert the first line of data
$line=fgets($fileread);
fwrite($filewrite,"),(".$line);
//read and write the next 599
for($linenumber=2;$linenumber<601;$linenumber++){
$line=fgets($fileread);
fwrite($filewrite,"),(".$line);
}
//put the closing ) in for mysql use
fwrite(#filewrite,")");
fclose($filewrite);
}
fclose($fileread);
echo "done"
?>
- scorphus
- Forum Regular
- Posts: 589
- Joined: Fri May 09, 2003 11:53 pm
- Location: Belo Horizonte, Brazil
- Contact:
The error is at line 8. Correction:
[edit="Scorphus"]
Also below on line 24:[/edit]
Code: Select all
$filewrite=fopen("/iptocountry/".$filename.".txt", "a"); // $filename instead of #filenameAlso below on line 24:
Code: Select all
fwrite($filewrite,")"); // $ instead of #