postgresql veritabanı ile php

5 Cevap php

i kullanarak php postgresql veritabanına bağlanmak istiyorum ama göndermek ve sorguyu yürütmek değil zaman boş bir ekran görüntüler

Şimdiden teşekkürler

Güncelleme: Bu benim kodudur

function execute_query($dbName,$query){ 
  $host = "localhost"; 
  $user = "postgres"; 
  $pass = ""; 
  $db = "test"; 
  echo "before create connection"; 
  $con = pg_connect ("host=$host dbname=$db user=$user password=$pass"); 
  echo "After connection is created"; 
  if (!$con) { 
    echo "not connected"; 
//   die('Could not connect: ' . mysql_error());
  } 
  $result = pg_query($con, $query); 
  pg_close($con); 
  return $result; 
}

The output: display the message "before connection" but doesn't display the message "After connection is created" or "not connected".

5 Cevap

Sorun muhtemelen bir yerde bir günlük dosyasına kaydedilir vurmayacak bir PHP hatadır. Günlük dosyasını bulun, ya da komut dosyası üstünde aşağıdakileri kullanarak sayfada günlüğü hatalarını gösteren etkinleştirin:

ini_set('display_errors', '1');
error_reporting(E_ALL | E_STRICT);

Bu kısa vadeli bir çözümdür ve (display_errors 0 olarak ayarlamak istediğiniz yere) dağıtımında kullanılan olamaz. Uzun vadeli bir çözüm için, gerçekten Apache ya da PHP hata günlüğü ve tail onu bulmak istiyorum.

Hata günlüğünü bulmak için, aşağıdaki komut dosyasını çalıştırın:

<?php phpinfo(); ?>

Yapılandırma> PHP Çekirdek bölümünde, error_log arayın. Bu set değil, sizin php.ini dosyasında ayarlayabilirsiniz. Tüm hatalar display_errors 0 olarak ayarlanmış olsa bile, bu dosyaya kaydedilir.

Sunucuya bir php dosya ekleyin ve bu dosyada bu koymak:

<?php
echo phpinfo();
?>

When you open that file from the browser, check if postgres support is setup for php. you should something like this on the page:

pgsql

PostgreSQL Support  enabled
PostgreSQL(libpq) Version   8.2.3
Multibyte character support enabled
SSL support disabled
Active Persistent Links 0
Active Links    0

Web sunucunun hata günlüğünü (örneğin, / var/log/apache2/error.log Apache2 günlüğüne için ortak bir yerdir) kontrol etmeyi deneyin ve orada PHP bildirilen bir hata olup olmadığını görmek.

Bu bir yerel kalkınma sunucusu ise ini dosyasında php hata raporlama düzeyini ayarlamak isteyebilirsiniz.

Bu php postgresql destek, cf yok, görünüyor. http://us.php.net/manual/en/ref.pgsql.php:

Note: Not all functions are supported by all builds. It depends on your libpq (The PostgreSQL C client library) version and how libpq is compiled. If PHP PostgreSQL extensions are missing, then it is because your libpq version does not support them.