php select error

来源:百度知道 编辑:UC知道 时间:2024/06/23 16:26:21
$conn=$access->query("select * from admin where id='".$_GET['id']."'");
我这句话哪里错了,好象没错吧,结果报了这么个错误:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] ��׼����ʽ���������Ͳ�ƥ�䡣, SQL state 22005 in SQLExecDirect in D:\php\AppServ\www\mysite1\admin\connect\class.php on line 186
SQL ERROR:'select * from admin where id='24'
是的

odbc_exec
(PHP 3 >= 3.0.6, PHP 4, PHP 5)

odbc_exec -- Prepare and execute a SQL statement

你没有连接上数据库
所以才会报错的
测试一下看看

<?php
// - This is a complete working dynamic example of using:
// odbc_connect, odbc_exec, getting col Names,
// odbc_fetch_row and no of rows. hope it helps
// - your driver should point to your MS access file

$conn = odbc_connect('MSAccessDriver','','');

$nrows=0;

if ($conn)
{
$sql = "select * from $month";
//this function will execute the sql satament
$result=odbc_exec($conn, $sql);

echo "<table align=\"center\" border=\"1\" borderColor=\"\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr> ";
// -- print field name
$colName = odbc_num_fields($r