Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
HI Friends,
This is my first post and i am just learning PHP, i developed a code which dump data from datafiles into mysql but i geting errors here i am giving the some codeCode: Select all
$fp=fopen("datafile.txt","r");
$c=0;
$numrows=0;
while(!feof($fp))
{
$buffer=fgets($fp,4096);
$fields=explode("|",$buffer);
$sql = "INSERT INTO ianhotels VALUES ('".$fields[0]."','".$fields[1]."', '".$fields[2]."', '".$fields[3]."', '".$fields[4]."', '".$fields[5]."', '".$fields[6]."', '".$fields[7]."','".$fields[8]."', '".$fields[9]."', '".$fields[10]."', '".$fields[11]."', '".$fields[12]."', '".$fields[13]."', '".$fields[14]."', '".$fields[15]."', '".$fields[16]."', '".$fields[17]."', '".$fields[18]."', '".$fields[19]."', '".$fields[20]."', '".$fields[21]."', '".$fields[22]."', '".$fields[23]."')";
if($fields[0] <> "HotelID" && $fields[0] <> "")
{
if(mysql_query($sql))
{
$numrows++;
}
}
}
echo $numrows."\n";
?>Notice: Undefined offset: 3 in c:\program files\easyphp1-8\www\hotels\s\load.php on line 13
Notice: Undefined offset: 4 in c:\program files\easyphp1-8\www\hotels\s\load.php on line 13
Notice: Undefined offset: 5 in c:\program files\easyphp1-8\www\hotels\s\load.php on line 13
Notice: Undefined offset: 6 in c:\program files\easyphp1-8\www\hotels\s\load.php on line 13
Notice: Undefined offset: 7 in c:\program files\easyphp1-8\www\hotels\s\load.php on line 13
Notice: Undefined offset: 8 in c:\program files\easyphp1-8\www\hotels\s\load.php on line 13
Notice: Undefined offset: 9 in c:\program files\easyphp1-8\www\hotels\s\load.php on line 13
Notice: Undefined offset: 10 in c:\program files\easyphp1-8\www\hotels\s\load.php on line 13
Notice: Undefined offset: 11 in c:\program files\easyphp1-8\www\hotels\s\load.php on line 13
Notice: Undefined offset: 12 in c:\program files\easyphp1-8\www\hotels\s\load.php on line 13
Please help me to slove this problem
Everah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]