Syntax fehler

Alles, was MariaDB und MySQL betrifft, kann hier besprochen werden.

Syntax fehler

Postby rufus » 18. March 2004 13:35

Wer kann mir helfen?

Irgendwas muss mit " und ' falsch sein aber ich weis nicht was ich bei meiner db-abfrage ändern muss!

Fehlermeldung:
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\php5xampp-dev\htdocs\leisys\infile.php on line 46


<?
class odbc
{

var $connid;
var $erg;

//This is the Constructor for Class ODBC
function odbc()
{
$U = "root";
$DB = "leisys";
$P = "pw";
$Srv = "localhost";
$DSN = "Driver=MySQL;Server=$Srv;Database=$DB";

if(!$this->connid = odbc_connect ("$DSN","$U","$P",SQL_CUR_USE_ODBC))
{
echo odbc_errormsg();
}
else
{
echo "ODBC Ok";
return $this->connid;
}

}

//With this Function you can create SQL_Queries
function f_sql($sql)
{
if (!$this->erg = odbc_exec($this->connid, $sql))
{
echo "Fehler beim Senden der Abfrage...";
}
return $this->erg;
}


}//End of Class ODBC

$db = new odbc();

$db->f_sql(" LOAD DATA INFILE 'C:\\WINNT\\TEMP\\test.csv'
INTO TABLE `before_extracting` FIELDS TERMINATED BY ';'
ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\r\n'
");
?>
rufus
 
Posts: 10
Joined: 17. March 2004 14:42

Re: Syntax fehler

Postby Roach » 18. March 2004 14:04

rufus wrote:LOAD DATA INFILE 'C:\\WINNT\\TEMP\\test.csv'
INTO TABLE `before_extracting` FIELDS TERMINATED BY ';'
ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED


Bei ENCLOSED BY ' " ' ist vermutlich der Fehler.
Mit " beendest du die Variablen Definition.
Schreibe " wenn du innerhalb einer variablen das " verwenden möchtest.
Roach
 
Posts: 34
Joined: 18. March 2004 13:41

Postby rufus » 18. March 2004 14:38

danke, das wars (-:
rufus
 
Posts: 10
Joined: 17. March 2004 14:42

Postby rufus » 18. March 2004 14:51

zu früh gefreut!

weis jemant was das zu bedeuten hat?

ODBC Ok
Warning: odbc_exec() [function.odbc-exec]: SQL error: [TCX][MyODBC]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 4, SQL state 42000 in SQLExecDirect in C:\php5xampp-dev\htdocs\leisys\infile.php on line 32

SQL-ErrorMessage:[TCX][MyODBC]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 4
rufus
 
Posts: 10
Joined: 17. March 2004 14:42

Postby Roach » 18. March 2004 18:41

weiß es nicht, aber probier mal am Schluss:

statt
LINES TERMINATED BY '\r\n'


das:
Code: Select all
 LINES TERMINATED BY '\\r\\n'


Gruß
Roach
 
Posts: 34
Joined: 18. March 2004 13:41


Return to MariaDB - MySQL

Who is online

Users browsing this forum: No registered users and 2 guests