SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Feb 2009
    Location
    israel
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql: can't find result of a query (into text file)

    Hi everyone,
    I need the results of a mysql query to be piped unto a text file so i can print it. Problen is: Where is
    the text file ?! Here is the php code to run the query:
    PHP Code:
    <?php
    // Connect to database server
    $con=mysqli_connect("localhost","root","root","mydb");
    if (
    mysqli_connect_errno())
        {
          echo 
    "Failed to connect to MySQL: " mysqli_connect_error();
        }
    $sql1 "SELECT startDate,endDate,intervalTime FROM june2013
        INTO OUTFILE 'xxx.txt'"
    ;
    if (
    mysqli_query($con,$sql1))
        {
         echo 
    "Data added to text file successfully";
        }
    else
       {
        echo 
    "Error transfering data " mysqli_error($con);
        }
      
    mysqli_close($con);
    ?>
    After I had ran the above code I recieved the message:
    Data added to text file successfully
    Which means the code succeeded in creating the desired text file.
    I searched the file in my HD at: xampp/htdocs and couldn't find it ! Then I made a WINDOWS 7 search for
    "xxx.txt" and the search found nothing !
    So I ran again the code and recieved an error message that says:
    Error transfering data File 'xxx.txt' already exists
    If that file exixts, where could it exist if not on my hard disk? If it is on my hard disk why can't I find it?
    Could it be some kind of a "hidden file"?
    Can anyone help me with that?
    Thanks

  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,287
    Mentioned
    182 Post(s)
    Tagged
    4 Thread(s)
    You can locate the Data Directory of MySQL by asking it.
    This requires a command prompt (in Windows) and calling MySQL at the command line.

    Otherwise, modify your command to specify an explicit directory (like the root):
    PHP Code:
    $sql1 "SELECT startDate,endDate,intervalTime FROM june2013
        INTO OUTFILE '/xxx.txt'"

    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  3. #3
    SitePoint Addict
    Join Date
    Feb 2009
    Location
    israel
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ParkinT View Post
    You can locate the Data Directory of MySQL by asking it.
    This requires a command prompt (in Windows) and calling MySQL at the command line.

    Otherwise, modify your command to specify an explicit directory (like the root):
    PHP Code:
    $sql1 "SELECT startDate,endDate,intervalTime FROM june2013
        INTO OUTFILE '/xxx.txt'"

    Thanks ParkinT,
    I added that slash and found my lost file.
    Thanks a lot


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •