Hello there....i am using the LOAD DATA INFILE to load from a txt file. Although it works fine with the MySQL command it does NOT work with Script...does anybody know why?

    maybe your apache is running in a different user-space than your personal account

    in linux, i'd suggest that u chmod all "load data infile" files ....
    in the windows-world, i'd guess, that u change the properties of the dir and file, so that
    everybody can read the file

      Can we see some of your code, and are you escaping the file name before you put it into the script query? That's a right popular mistake to make.

        $grantPriv = "GRANT ALL ON test2.* TO 'root'@'localhost' IDENTIFIED BY '323232'";
        $popStud2 = "LOAD DATA INFILE 'C:/Program Files/MySQL/MySQL Server 4.1/data/test2/stud.txt' INTO TABLE student FIELDS TERMINATED BY '|' ESCAPED BY '\' LINES TERMINATED BY '\r\n'";

        	$popStaff = "LOAD DATA INFILE 'staff2.txt' INTO TABLE `staff` FIELDS TERMINATED BY '|' ESCAPED BY '\\' LINES TERMINATED BY '\r\n'";
        	//LOAD DATA INFILE '\test\stud.txt' INTO TABLE `student` FIELDS TERMINATED BY '|' ESCAPED BY '\\' LINES TERMINATED BY '\r\n';
        	$res_grt = $db->query($grantPriv);						
        	$res_pop = $db->query($popStud2);						
        	$res_pop2 = $db->query($popStaff);		
        	echo '<p class = status> You have successfully populated the database. </p>';				
        }
        else if (isset($_POST['bt5']))
        {
        	echo '<p class = status> You have successfully extracted information about students and superivosrs. <br> (students.txt and supervisors.txt) </p>';				
        	$stud_txt = "SELECT * INTO OUTFILE '/webs/test/students.text' FIELDS TERMINATED BY '|' ESCAPED BY '\\' LINES TERMINATED BY '\r\n' FROM student";
        	$staff_txt = "SELECT * INTO OUTFILE 'supervisors.text' FIELDS TERMINATED BY '|' ESCAPED BY '\\' LINES TERMINATED BY '\r\n' FROM staff";
        	$res_stud = $db->query($stud_txt);						
        	$res_staff = $db->query($staff_txt);						
        }

        here it is....the outfile does not work either....i guess its about the file properties because the MySQL executes the queries and the result is the desired

        thank you guys

          when i did your "grant" statement( on the "test"-table ) it resulted in sth. like
          "USAGE"

          after that, i checked the privileges on that account and there was no "file"-priv.

          maybe, you can change that on "whateverDB.*" to grant a "global" priv.

            mmmmm what do u mean to change the whatever db? change the database? do u know how to change the file permission for the windowns?

              GRANT FILE ON test2.* TO 'root'@'localhost' IDENTIFIED BY '323232'

                Write a Reply...