Quote:
Originally Posted by movieking81
Hello All-
I need help on a Select statement. I have this...
-
<?php
-
-
$conn=odbc_connect('databasename','','');
-
if (!$conn)
-
{exit("Connection Failed: " . $conn);}
-
-
$sql="SELECT * FROM tablename where id = '" . $_REQUEST['id'] . "'";
-
-
echo "$sql";
-
$rs=odbc_exec($conn,$sql);
-
?>
-
When I run the page I get this...
-
-
PHP Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression., SQL state 22005 in SQLExecDirect in C:\yada\yada\yada.php on line 27
-
-
What am I doing wrong? I have printed the Select statement and it does get a value like so...
-
SELECT * FROM tablename where id = '99999'
-
Do I have to wrap a convert function around the requested id? I'm not really a PHP person, I concentrate mainly on ASP so I'm a little confused. Do I have the syntax correct? Any help would be great.
Also, as far as the Access Database goes the "id" field is set as "Autonumber" to increment and is the primary key of the table.
Hi,
Try the following code:
[php]
<?php
$conn=odbc_connect('databasename','','');
if (!$conn)
{exit("Connection Failed: " . $conn);}
$lnID = $_REQUEST['id'] ;
$sql="SELECT * FROM tablename where id = $lnID";
echo "$sql";
$rs=odbc_exec($conn,$sql);
?>
[/php]
That works for me in MySQL and I beleive it should work in Access also.
Cheers
nathj