search
HomeBackend DevelopmentPHP Tutorialwin7中IIS+php+Sql2008的错误

本人在win7里架设iis服务器,运行一个web系统,数据库用sql server 2008,由于其后台是用asp.net+C#开发,前台是用php5.4开发,因此必须保证iis里也可以运行php页面程序。看了网上很多配置,访问前台的页面跳出的结果如下:sql error!(in function select)

求各位达人怎么解决?


回复讨论(解决方案)

你至少应贴出相关的代码

你至少应贴出相关的代码

那个php前台在Apache作为服务器的时候没问题,但是放在iis里就有问题了。。。貌似不是代码的问题。不过也把代码贴出去吧。

session_start();
require_once 'libs/Smarty.class.php';
require_once 'libs/SqlsrvTools.php';
$smt=new Smarty();
//{获取新闻
$typeInfoConn=new SqlsrvTools("jmgyms", "typeinfo");
$typeRes=$typeInfoConn->where("1=1")->filed("id")->select();
$typeCount=count($typeRes);
$mediaNewsConns=array();
$newsResArr=array();
//   print_r($typeRes);exit;
foreach($typeRes as $k=>$v)
{
$mediaNewsConns[$k]=new SqlsrvTools("jmgyms", "industry_news");

$newsResArr[$v["id"]]=
$mediaNewsConns[$k]
->where("newstype=".$v["id"])
->filed("id,newstitle,newstype,addtime")
->order("addtime desc")
->limit(0,4,"id")
->select();
}
//释放内存
$typeInfoConn=null;
foreach($mediaNewsConns as $k=>$v)
{
$mediaNewsConns[$k]=null;
}
//循环assign
foreach($newsResArr as $k=>$v){
//  echo $k."
";
//  print_r($v);
foreach ($v as $kk=>$vv)
{

foreach ($vv as $kkk=>$vvv)
{
if(!is_object($vvv))
$newsResArr[$k][$kk][$kkk]=iconv("GB2312//IGNORE","UTF-8",$vvv);
else if($kkk=="addtime")
{
$jsonTemp=json_encode($vvv);
$addtimeArr=json_decode($jsonTemp,1);
$newsResArr[$k][$kk]["date"]=substr($addtimeArr['date'],0,10);
//echo $newsResArr[$k][$kk]["date"];
}
}
}
//print_r($v);
$smt->assign("newslist$k",$newsResArr[$k]);
}//exit;
//}
$linkConn=new SqlsrvTools("jmgyms","links");
$links=$linkConn->where(" 1=1 ")->filed("Title,WebUrl")->select();
//  echo $linkConn->getSqlExtends();exit;
foreach ($links as $k=>$v)
{
foreach ($v as $kk=>$vv)
{
$links[$k][$kk]=iconv("GB2312//IGNORE","UTF-8",$vv);
}
}
$loginTips="";
if(isset($_SESSION["username"])){
$isLogin=true;
$loginTips="";
switch ($_SESSION['membertype']){
case 1:{
$loginTips="亲爱的个人会员";
};break;
case 2:{
$loginTips="敬爱的团体会员";
};break;
default:{
$loginTips="欢迎回来";
};
}
$smt->assign("username",$_SESSION["username"]);
}
else{
$isLogin=false;
$loginTips="会员登陆";
}


$smt->assign("links",$links);
$smt->assign("islogin",$isLogin);
$smt->assign("loginTips",$loginTips);
$smt->display('templates/index.html');
?>

那你的错误信息 sql error!(in function select) 是从哪里来的?跟踪了吗?

IIS 下的 php 应该是 FastCGI 方式,你的是吗?
如果是,那么 sqlsrv 扩展也得换吧?

Php就可以后台,你干嘛还要用c#,

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP Performance Tuning for High Traffic WebsitesPHP Performance Tuning for High Traffic WebsitesMay 14, 2025 am 12:13 AM

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

Dependency Injection in PHP: Code Examples for BeginnersDependency Injection in PHP: Code Examples for BeginnersMay 14, 2025 am 12:08 AM

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

PHP Performance: is it possible to optimize the application?PHP Performance: is it possible to optimize the application?May 14, 2025 am 12:04 AM

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

PHP Performance Optimization: The Ultimate GuidePHP Performance Optimization: The Ultimate GuideMay 14, 2025 am 12:02 AM

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.