Question: I'm trying to connect my html/css/js web app on my localhost to a separate redshift database. I don't have access to the key/secret, so the [SDK for PHP](http://docs.aws.amazon.com/aws-sdk-php/v3/guide/getting-started/basic-usage.html) won't work for me.

Are there alternative options? I feel like I'm on the wrong track. I'm trying to query the redshift database and build some html/css graphics on my localhost.

**Attempted code, per Ketan**

`$dbconn = pg_connect("host=endpoint dbname=name user=UN password=PW")
 or die('Could not connect: ' . pg_last_error());`

**And error...**

Warning: pg\_connect(): Unable to connect to PostgreSQL server: could not connect to server: Connection timed out (0x0000274C/10060) Is the server running on host "endpoint" and accepting TCP/IP connections on port ####? in results.php on line 38

Answer: 
you can use `try` to do the `nil` judge: `<%= ride.pickup_at.try(:strftime, '%x') %>` .Or I think you should figure out what to do if `ride.pickup_at` is `nil`
You can add a if condition like this before your code like this.
 <%if !ride.pickup\_at.nil? %>
 <%= ride.pickup\_at.strftime('%x') %>
 <% end %>
This might be because of some record having nil value for pickup\_at