Any idea why the * works but a list of field names in the SELECT 
statement does not?  This is using ODBC to pull from an Access table.

This does not work:

$SQLStr = "SELECT dteModifiedLast, fldNoticeName, intNoticeNumber, 
fldFieldx, fldNote1, fldNote2
                FROM tblNotices
                WHERE intNoticeNumber=$id";

This does work:

$SQLStr = "SELECT *
              FROM tblNotices
              WHERE intNoticeNumber=$id";

I get the error response:

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft]
[ODBC Microsoft Access Driver] Too few parameters. Expected 4., SQL 
state 07001 in SQLExecDirect in 
c:\Inetpub\wwwroot\acs_svc\Notices\test\nglance.php on line 50

This error usually means there is some sytax or spelling error in the 
SQL statement.  Unless it is specific to PHP ODBC, there is nothing 
unusual about this very simple statement with field names.


The code snipit:

$rs = odbc_exec ($conn, $SQLStr);
$id = 1;
if (isset($_GET["c"])) { $id = $_GET["c"]; }

$SQLStr = "SELECT dteModifiedLast, fldNoticeName,              
intNoticeNumber, fldFieldx, fldNote1, fldNote2
        FROM tblNotices
        WHERE intNoticeNumber=$id";
$rs = odbc_exec($conn, $SQLStr);
if (!$rs) { exit("Error in SQL Statement 2"); }

$fldModLast     = odbc_result($rs, 1);
$fldNoticeName  = odbc_result($rs, 2);
$fldNoticeNo    = odbc_result($rs, 3);
$fldFieldx      = odbc_result($rs, 4);
$fldNote1       = odbc_result($rs, 5);
$fldNote2       = odbc_result($rs, 6);


echo "<td align='left'  width='80%' valign='top'>";
echo "$fldNoticeNo:  $fldNoticeName <br />";
echo "$fldModLast <br /> \n";
echo "$fldFieldx  <br /> \n";
echo "$fldNote1   <br /> \n";
echo "$fldNote2   <br /> \n";

Thanks






Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to