odbc连接成功 php如何使用,一个php通过odbc调用数据库的示例

php调用odbc函数演示

这个例程简单演示了 php 通过 odbc 访问数据库.

只需要通过 控制面板->ODBC 数据源->添加数据源(WebTest)即可.

">
操作
操作
编号(数字)
名称(字符串

)

if(strcmp($verb,"")!=0){

if(strcmp($verb,"Create Table")==0){$sql_string="create table testtb (n integer, name char(40))";$err_msg="创建数据表时出错, 该表已经存在?";

}else if(strcmp($verb,"Drop Table")==0){$sql_string="drop table testtb";$err_msg="Drop数据表时出错, 该表不存在?";

}else if(strcmp($verb,"Insert")==0){$sql_string="insert into testtb values ($n,'$name')";$err_msg="添加新记录时出错, 请检查您填写的数据.";

}else if(strcmp($verb,"Delete")==0){$sql_string="delete from testtb where n = $n";$err_msg="删除记录时出错, 请检查您填写的数据.";

}else if(strcmp($verb,"Update")==0){$sql_string="update testtb set name = '$name' where n = $n";$err_msg="更新记录时出错, 请检查您填写的数据.";$err_msg="更新记录时出错, 请检查您填写的数据.";

}

print$sql_string;

if(!odbc_exec($con_id,$sql_string))

echo$err_msg;

}

if($result=odbc_exec($con_id,"select n, name from testtb")){?>


查询结果
编号名称

,odbc_result($result,2));?>

printf("

%d%sn",odbc_result($result,1)

}else

echo"查询失败, 请确认正确数据表存在.";odbc_close($con_id);

}else

echo"连接数据库失败, 请检查您是否正确的配置了 ODBC 数据源.";?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值