#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    2
    Rep Power
    0

    Code help to query database


    I am very new to Postgresql and I have a bit of code which I can't see any problem with but it doesn't return anything, hope someone can tell me where I am going wrong.

    PHP Code:
    $conn pg_pconnect ("host=localhost port=5433 dbname=timetrex user=timetrex password=password");
    if (!
    $conn) {      echo "An error occured.\n";
    exit;

    $result pg_query ($conn"SELECT * FROM users");
    if (!
    $result) {      echo "An error occured.\n";
    exit;
    }
     
    $arr pg_fetch_all ($result0PGSQL_NUM);
    var_dump($arr); 
    I have checked the port, username, password etc and all is fine, it does appear to connect to the database but doesn't return the result of the query.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    9
    Rep Power
    0
    Anything in the webserver error log?
    Try setting your php error reporting to E_ALL.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    2
    Rep Power
    0
    I got it working after this small change

    PHP Code:
    $arr pg_fetch_all ($result); 
    Not what I read in the manual but it works

IMN logo majestic logo threadwatch logo seochat tools logo