douti9253
2013-04-17 13:34
浏览 195
已采纳

得到致命错误:调用未定义的函数pg_connect

I'm developing my first program with php. I searched a lot of forums and about 3 or 4 hours, but got nothing.

Here is my index.php code:

<html>
<head>
   <title>first program</title>
</head>
<body>
    <h1> program loaded successfully</h1>
    <?php
        echo extension_loaded('pgsql') ? 'yes':'no';
        echo pg_connect("host=localhost port=5432 dbname=test user=postgres password=root");
    ?>
</body>

When I load this page I see this:

program loaded successfully

no

Fatal error: Call to undefined function pg_connect() in D:\courses\web programing\hw2\cinema\index.php on line 9

I installed php-5.4.14-Win32-VC9-x86 on my windows and run my project with this comment:

php.exe" -S localhost:80 -t "D:\courses\web programing\hw2\cinema"

I have php.ini-development and php.ini-production in php folder and Uncommented extension=php_pgsql.dll, extension=php_pdo_pgsql.dll in both files. I'm using postgresql 9.2

So where is my mistake?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douzao5487 2013-04-17 15:06
    已采纳

    Solved It's wired but the problem was that php try to load php.ini from Windows folder and no php.ini exist there. So I copied one of my php.ini files in Windows folder and problem solved. It seems like a bug.

    打赏 评论
  • douxuanling6523 2013-04-17 13:37

    postgreSQL should be activates in the php.ini to activate these functions.

    打赏 评论

相关推荐 更多相似问题