Forums
This topic is locked
error
Posted 03 Aug 2001 20:27:22
1
has voted
03 Aug 2001 20:27:22 Keith Slater posted:
I get this error when I try to run my php. I started a new page on this one. I'm using an access database so I'm not sure as to why its even trying to do all thid SQL stuff. Warning: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in C:\Inetpub\wwwroot\cedarcreek\adodb\adodb-odbc.inc.php on line 65
thanks
Keith Slater
Word Pro Systems
www.wordprosys.com
Replies
Replied 03 Aug 2001 22:07:09
03 Aug 2001 22:07:09 Keith Slater replied:
I actually did get that error fixed.. I've done all this stuff before but now I keep getting errors. In updating a field I get this error
[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.
this is my update field:
?php
// *** Update Record: construct a sql update statement and execute it
if (isset($MM_update) && (isset($MM_recordId))) {
// create the sql update statement
$MM_editQuery = "update " . $MM_editTable . " set ";
for ( $i=0; $i+1 < sizeof($MM_fields); ($i=$i+2))
{
$formVal = $MM_fields[$i+1];
$MM_typesArray = Explode(",", $MM_columns[$i+1]);
$delim = ($MM_typesArray[0] != "none" ? $MM_typesArray[0] : "";
$altVal = ($MM_typesArray[1] != "none" ? $MM_typesArray[1] : "";
$emptyVal = ($MM_typesArray[2] != "none" ? $MM_typesArray[2] : "";
if ($formVal == "" || !isset($formVal))
{
$formVal = $emptyVal;
}
else
{
if ($altVal != ""
{
$formVal = $altVal;
}
else if ($delim == "'"
{ // do not escape quotes in PHP4
$formVal = "'" .$formVal . "'";
}
else
{
$formVal = $delim . $formVal . $delim;
}
}
if ($i != 0)
{
$MM_editQuery = $MM_editQuery . ", " . $MM_columns[$i] . " = " . $formVal;
}
else
{
$MM_editQuery = $MM_editQuery . $MM_columns[$i] . " = " . $formVal;
}
}
$MM_editQuery = $MM_editQuery . " where " . $MM_editColumn . " = " . $MM_recordId;
if ($MM_abortEdit != 1)
{
// execute the insert
$queryrs = $cedarcreek->Execute($MM_editQuery) or DIE($cedarcreek->ErrorMsg());
if ($MM_editRedirectUrl)
{
header ("Location: $MM_editRedirectUrl"
}
}
}
?>
thanks
Keith Slater
[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.
this is my update field:
?php
// *** Update Record: construct a sql update statement and execute it
if (isset($MM_update) && (isset($MM_recordId))) {
// create the sql update statement
$MM_editQuery = "update " . $MM_editTable . " set ";
for ( $i=0; $i+1 < sizeof($MM_fields); ($i=$i+2))
{
$formVal = $MM_fields[$i+1];
$MM_typesArray = Explode(",", $MM_columns[$i+1]);
$delim = ($MM_typesArray[0] != "none" ? $MM_typesArray[0] : "";
$altVal = ($MM_typesArray[1] != "none" ? $MM_typesArray[1] : "";
$emptyVal = ($MM_typesArray[2] != "none" ? $MM_typesArray[2] : "";
if ($formVal == "" || !isset($formVal))
{
$formVal = $emptyVal;
}
else
{
if ($altVal != ""
{
$formVal = $altVal;
}
else if ($delim == "'"
{ // do not escape quotes in PHP4
$formVal = "'" .$formVal . "'";
}
else
{
$formVal = $delim . $formVal . $delim;
}
}
if ($i != 0)
{
$MM_editQuery = $MM_editQuery . ", " . $MM_columns[$i] . " = " . $formVal;
}
else
{
$MM_editQuery = $MM_editQuery . $MM_columns[$i] . " = " . $formVal;
}
}
$MM_editQuery = $MM_editQuery . " where " . $MM_editColumn . " = " . $MM_recordId;
if ($MM_abortEdit != 1)
{
// execute the insert
$queryrs = $cedarcreek->Execute($MM_editQuery) or DIE($cedarcreek->ErrorMsg());
if ($MM_editRedirectUrl)
{
header ("Location: $MM_editRedirectUrl"
}
}
}
?>
thanks
Keith Slater
Replied 04 Aug 2001 02:09:41
04 Aug 2001 02:09:41 Tim Green replied:
So that you know, SQL is the language of databases. Whether it is a simple CSV file, or a Major Database System like SQL Server or Oracle, SQL is a semi-standardized set of commands that communicate with the database.
In access, the majority of this is transparent to you, but SQL is there in the background doing it's work.
If ever you design a query, you have the option of switching to SQL View, and this reveals the hidden commands to you.
Unfortunately, though, the code that you have posted is of little use as a diagnostic tool, as you have attached only an excerpt of the code, which so happens to be the standard set of UD commands for handling an Update transaction.
However, I suspect that what is happening is that certain text fields haven't been mapped to columns, or that some of the columns could have 'reserved words'.
What do I mean by 'reserved words' ? Well, SQL like any other language has a set of commands that are specific to it. These words must not be used anywhere else in the database, otherwise things won't work as expected.
The most common mistake is to call a column that will hold Date information 'DATE' (upper or lower case, it doesn't matter). This is a reserved SQL word.
The Syntax error means one of two things. Either, a reserved word has been encountered where it shouldn't be, or indeed there could be some form of punctuation etc that shouldn't be there.
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
In access, the majority of this is transparent to you, but SQL is there in the background doing it's work.
If ever you design a query, you have the option of switching to SQL View, and this reveals the hidden commands to you.
Unfortunately, though, the code that you have posted is of little use as a diagnostic tool, as you have attached only an excerpt of the code, which so happens to be the standard set of UD commands for handling an Update transaction.
However, I suspect that what is happening is that certain text fields haven't been mapped to columns, or that some of the columns could have 'reserved words'.
What do I mean by 'reserved words' ? Well, SQL like any other language has a set of commands that are specific to it. These words must not be used anywhere else in the database, otherwise things won't work as expected.
The most common mistake is to call a column that will hold Date information 'DATE' (upper or lower case, it doesn't matter). This is a reserved SQL word.
The Syntax error means one of two things. Either, a reserved word has been encountered where it shouldn't be, or indeed there could be some form of punctuation etc that shouldn't be there.
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>