search
HomeBackend DevelopmentPHP Tutorial thinkphp3.1如何都连不下mysql数据库 请帮忙

thinkphp3.1怎么都连不上mysql数据库 请大虾帮忙啊
thinkphp 3.1 怎么都连不上mysql数据库 请大虾帮忙啊!!!

项目配置文件config.php:

return array(
  'APP_STATUS' => 'debug',
  'DB_TYPE' => 'mysql', // 数据库类型
  'DB_HOST' => 'localhost', // 服务器地址
  'DB_NAME' => 'thinkphp', // 数据库名
  'DB_USER' => 'root', // 用户名
  'DB_PWD' => '123456', // 密码
  'DB_PORT' => '3306', // 端口
  'DB_PREFIX' =>'think_', // 数据库表前缀
  'DB_FIELDTYPE_CHECK' => false, // 是否进行字段类型检查
  'DB_FIELDS_CACHE' => true, // 启用字段缓存
  'DB_CHARSET' => 'gb2312', // 数据库编码默认采用utf8
  'DB_DEPLOY_TYPE' => 0, // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)

  'DB_RW_SEPARATE' => false, // 数据库读写是否分离 主从式有效
  'DB_MASTER_NUM' => 1, // 读写分离后 主服务器数量
  'DB_SLAVE_NO' => '', // 指定从服务器序号
  'DB_SQL_BUILD_CACHE' => false, // 数据库查询的SQL创建缓存
  'DB_SQL_BUILD_QUEUE' => 'file', // SQL缓存队列的缓存方式 支持 file xcache和apc
  'DB_SQL_BUILD_LENGTH' => 20, // SQL缓存的队列长度
  'DB_SQL_LOG' => false, // SQL执行日志记录

);
?>

MYSQL里面有个thinkphp数据库、think_abc的表 表有id int primary key auto_increment,name varchar(20),age int,sex bool字段

控制器文件 IndexAction.class.php:

class IndexAction extends Action {
  public function index(){
  $data=array(
  'name'=>'dong',
  'age'=>21,
  'sex'=>1
  );
  M('Abc')->add($data);
  }
}
?>

在浏览器输入http://localhost/app/index.php 后浏览器显示‘页面错误,请稍后再试’ http://localhost/app/index.php/index/也试过哈 在这里面定义其它不连接mysql的函数就运行正常 本人初学者 实在没办法弄了 请高手指点

------解决方案--------------------
删除 app 下的 Runtime 目录,再试!

如仍不行,请发话

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

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor