Professional Web Applications Themes

php mysql trouble - MySQL

What is wrong with this code? mysql_query("LOAD DATA LOCAL INFILE '/usr/home/wei/dealerinv' INTO TABLE `inv` FIELDS TERMINATED BY '\t' ESCAPED BY '\' LINES TERMINATED BY '\r\n'")or die(mysql_error()); It's driving me nuts, It is obviously my quotes, But I can't figure it out... You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' at line 2 All help is appreciated...

  1. #1

    Default php mysql trouble

    What is wrong with this code?

    mysql_query("LOAD DATA LOCAL INFILE '/usr/home/wei/dealerinv' INTO TABLE
    `inv` FIELDS TERMINATED BY '\t' ESCAPED BY '\\' LINES TERMINATED BY
    '\r\n'")or die(mysql_error());

    It's driving me nuts, It is obviously my quotes, But I can't figure it
    out...

    You have an error in your SQL syntax; check the manual that corresponds to
    your MySQL server version for the right syntax to use near ''' at line 2


    All help is appreciated


    DBLEXPOSURE Guest

  2. #2

    Default Re: php mysql trouble

    Peter H. Coffin wrote:
    > On Tue, 15 Nov 2005 14:35:07 -0600, DBLEXPOSURE wrote:
    >
    >>What is wrong with this code?
    >>
    >>mysql_query("LOAD DATA LOCAL INFILE '/usr/home/wei/dealerinv' INTO TABLE
    >>`inv` FIELDS TERMINATED BY '\t' ESCAPED BY '\\' LINES TERMINATED BY
    >
    > ^ ^ What are those supposed to be?
    >
    >>'\r\n'")or die(mysql_error());
    >>
    >>It's driving me nuts, It is obviously my quotes, But I can't figure it
    >>out...
    >>
    >>You have an error in your SQL syntax; check the manual that corresponds to
    >>your MySQL server version for the right syntax to use near ''' at line 2
    >
    >
    > Table names don't generally need to be quoted.
    >
    Look at ESCAPED BY '\\'
    It is inside a string that is sent to the database server. The first
    slash escapes the second, so what is actually sent to the server is:
    ESCAPED BY '\'
    In this string the slash escapes the quote, so anything that follows is
    seen as part of the string, until another quote is reached. I think four
    slashes do what you mean here.

    Best regards
    Dikkie Dik Guest

  3. #3

    Default Re: php mysql trouble


    "DBLEXPOSURE" <celstuffhotmail.com> wrote in message
    news:laednbQok6gv2-feRVn-pAmidco.net...
    > What is wrong with this code?
    >
    > mysql_query("LOAD DATA LOCAL INFILE '/usr/home/wei/dealerinv' INTO TABLE
    > `inv` FIELDS TERMINATED BY '\t' ESCAPED BY '\\' LINES TERMINATED BY
    > '\r\n'")or die(mysql_error());
    >
    > It's driving me nuts, It is obviously my quotes, But I can't figure it
    > out...
    >
    > You have an error in your SQL syntax; check the manual that corresponds to
    > your MySQL server version for the right syntax to use near ''' at line 2
    >
    >
    > All help is appreciated
    >
    >
    Thanks for all your input

    The solution

    mysql_query("LOAD DATA INFILE '/usr/home/wei/dealerinv' INTO TABLE inv
    FIELDS TERMINATED BY '\t' ESCAPED BY '\\\' LINES TERMINATED BY '\\n' ") or
    die(mysql_error());

    got rid of the \r was not needed



    DBLEXPOSURE Guest

Similar Threads

  1. Trouble with PHP DMX2004 MySql
    By ctorley in forum Macromedia Dynamic HTML
    Replies: 1
    Last Post: February 19th, 09:59 PM
  2. MySQL datasource connection trouble
    By pieround in forum Coldfusion Database Access
    Replies: 1
    Last Post: June 22nd, 08:27 PM
  3. Trouble connecting to MySQL
    By gwnh in forum Dreamweaver AppDev
    Replies: 5
    Last Post: May 9th, 08:55 PM
  4. trouble retrieving data from mysql db. Help pls
    By Tw|chie in forum Dreamweaver AppDev
    Replies: 3
    Last Post: May 4th, 10:58 AM
  5. MySQL trouble shooting
    By FER in forum Macromedia Dreamweaver
    Replies: 2
    Last Post: July 9th, 08:51 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139