Page 1 of 1
'trivial' problem
Posted: Sun Jan 11, 2004 12:44 pm
by iano
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 (";
Posted: Sun Jan 11, 2004 2:45 pm
by DuFF
Theres no end parentheses
Code: Select all
$sqlline = "INSERT INTO `iptoc` (`IP_FROM` , `IP_TO` , `country_code` , `country_code2` , `country_name` ) VALUES (");
Posted: Sun Jan 11, 2004 2:57 pm
by basdog22
$sqlline = "INSERT INTO `iptoc` (`IP_FROM` , `IP_TO` , `country_code` , `country_code2` , `country_name` ) VALUES (";
Do you want to use it like that:
mysql_query($sqlline '$ip','$ip_to','$code');
????

Posted: Sun Jan 11, 2004 4:11 pm
by Bennettman
That line works fine for me. Must be a different line.
Re: 'trivial' problem
Posted: Sun Jan 11, 2004 4:15 pm
by scorphus
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.
Posted: Sun Jan 11, 2004 7:14 pm
by iano
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"
?>
Posted: Sun Jan 11, 2004 7:33 pm
by scorphus
The error is at line 8. Correction:
Code: Select all
$filewrite=fopen("/iptocountry/".$filename.".txt", "a"); // $filename instead of #filename
[edit="Scorphus"]
Also below on line 24:
Code: Select all
fwrite($filewrite,")"); // $ instead of #
[/edit]
Posted: Sun Jan 11, 2004 7:48 pm
by iano
thanks mate
you legend!