odbc_connect to progress database - php

I could use some help determining what is the best way for me as the developer to see what is causing an error as I am trying to connect to a progress openedge database.
All I am seeing is that the connection is failing based on the die message.
In short I am simply looking for more verbose error logging/messaging from the odbc_connect function.
I have a production computer that this is running on just fine, so I would like to know on my new development machine what is missing.
$my_port = "3500";
$my_username = "my_username";
$my_password = "my_password";
$my_database = "my_db";
//0 (READ UNCOMMITTED)
//1 (READ COMMITTED)
//2 (REPEATABLE READ)
//3 (SERIALIZABLE)
$my_dil = 0;
$my_connection = odbc_connect(
"Driver={Progress OpenEdge 11.7 Driver};
HOST=$progress_host;
PORT=$my_port;
DB=$my_database;
UID=$my_username;
PWD=$my_password;
DIL=$my_dil", "", ""
) or die ("ERROR: Could not connect to Progress OpenEdge Database.");

So I figured it out how to connect. I know that doesn't give us error handling, but it does allow us to actually connect.
I added the following to php.ini and validated they were in the ext folder; then restarted iis.
extension=php_pdo_odbc.dll
extension=php_ldap.dll
extension=php_odbc.dll
I needed to install the drivers on my development box. I did this by moving the progressx86 folder from my working server.
I then ran the following file.
C:\Progressx86\OpenEdge\install\odbc\sql-odbc-setup.exe
Note:
There might be other steps that I tried before this one that affected the outcome, but before I did my answer above it didn't work, and after I did my answer above it worked.

Related

Cannot Connect to Google Calendar PHP/API

Good day to you all :)
So I was using the following code to insert events into my Google Calendar. This all worked last week. This week, I have built a new computer and updated all PHP, MySQL and Apache. I am now getting the error "Cannot Connect to Calendar", which you can see is a custom error message at the end of this code example. The rest of the script deals with data processing and insertion.
I've checked the code with examples online and it matches. The username and password are correct and I can login via various browsers. Can anyone help me to get this back up and running and allowing me to connect to the Calendar?
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
$user = 'valid#email.address.com';
$pass = '<removed>';
$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$calendar_user = "valid%40email.address.com"; // Also tried with #
//$calendar_visibility = "private-<removed>";
try {
$client = Zend_Gdata_ClientLogin::getHttpClient($user,$pass,$service);
}
catch(Exception $e) {
// prevent Google username and password from being displayed
// if a problem occurs
echo "Could not connect to calendar.";
die();
}
For reference. It's a clean Windows 7 install now running the lastest (Nov 2012) version of WAMP. I am able to run local PHP scripts that connect, successfully, to remote databases. And the file 'Zend/Loader.php' is present with the correct path.
Any help greatly appreciated. TIA
------ UPDATE ----
Turned off the custom error message and get this:
Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message ' in C:\Program Files (x86)\wamp\www\www.domain.com\subdir\Zend\Gdata\App.php on line 709
Running on the latest WAMP. I've enabled the SSL Module but nothing has changed.
SOLVED
For the benefit of anyone else who finds this...
SSL was showing to be uncommented and fully supported in both PHPinfo() and the WAMP dashboard.
However, it appears that WAMP needed to be explicitly told that it was enabled. After insuring that you actually installed WAMP/PHP with SSL support then...
Click on the WAMP tray - PHP - extensions - [tick/enable] php_openssl.dll
Restart WAMP.
Now all works as it did in the past.
Just a guess but is php_curl enabled ?
I didn't try but I know there was few issues on Windows with some PHP dll (php_curl.dll for instance). You might give a try on a "real" environment (LAMP) if you are able to.

ORA-12154 PHP OCI8 grief

Configured a CentOS 5.6 server with Oracle's 11g XE (the freebie version), installed OCI8 with the help of this guide and got a pre-existing (custom) PHP application communicating with the database with no issues. Called that server Dev and started the next build.
The Prod server that I'm now working on is just like Dev except that Oracle 11G is the Standard edition, not the free version. Everything else, to the very best of my knowledge, identical. Definitely the same OCI RPMs.
Warning: ocilogon() [function.ocilogon]: ORA-12154: TNS:could not
resolve the connect identifier specified in
/var/www/html/blah/blah.php
I'm sure I have an "environmental" issue but I can't figure out how to solve it.
Oracle, Apache, OCI8 and PHP are all on the same box.
What works:
tnsping orcl from the Prod server.
sqlplus user#orcl from the Prod
server.
phpconfig(); shows all the OCI8 stuff. Compared the results on Dev and Prod and they are identical.
I can also connect via Toad from an XP client on the other end of a VPN.
I just can not get PHP to talk to the DB. Driving me mad!
Did a global search on the Prod server, there is only one tnsnames.ora file. Here's what it looks like:
ORCL = (DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
) )
Anything I should provide that would help? Just leave a comment.
I really don't want to flatten and start over on the Prod box... Please help me figure this out!
[edits]
It isn't finding the listener, I guess. Out of curiosity, I stopped the listener service and confirmed that nothing about the error changes.
By request, here's some code.
The code that throws the error I mentioned above:
$dbh = OCILogon($vars[oracle_login], $vars[oracle_pwd], $vars[oracle_instance]);
Variables are set in another file:
...
But we can skip that. While copying and pasting them over to here I took a moment to line up parentheses -- and found an extra.
Typo!
Doh. /facepalm.
While fulfilling a request to show some code, I took a moment to format it and line it all up. At that point, I discovered an extra parentheses.
Fixing that fixed the issue.
Sorry for all the reading!

PHP mysql_connect cannot resolve Host name when sessions are enabled

Crazy right? Sample code:
<?php
session_start();
$hostname="samplehost";
$username="sampleuser";
$password="samplepass";
$dbname="sampledb";
$link = mysql_connect($hostname, $username, $password) or die(mysql_error());
mysql_select_db($dbname, $link);
?>
Will throw Unknown MySQL server host 'samplehost' (2). If we remove the session_start() or just do a session_destroy() before the mysql_connect(), it works correctly. Basically, if we have a session open, its like mysql_connect wont resolve the host name. The host name we use for the server is correctly added to /etc/hosts.
It's a production server running PHP 5.3.2-1ubuntu4.7 - just started happening today. Anyone run into this?
edit: should mention, with or without sessions, we can specify the IP of the DB server, and it works correctly.
If someone comes across this - it turns out to be a an issue with the amount of Virtual Hosts we had in Apache. Appears when you start hitting the limit on file descriptors, you get some odd symptoms - it was finally diagnosed when we started getting a 'Too many open files' error in PHP.
It was a legacy setup in how we were automatically generating vhosts for new domains. Better managed that process, reduce the amount of vhosts and the issues went away.
Why don't you just connect first, then start the session?

php with postgresql database

i wanna to connect to postgresql database using php but it display a blank screen when submit and doesnt execute the query
Thanks in advance
Update: this is my code
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".
The problem is likely a PHP error that’s getting recorded to a log file somewhere. Locate the log file, or enable showing the log errors on your page by using the following at the top of your script:
ini_set('display_errors', '1');
error_reporting(E_ALL | E_STRICT);
This is a short-term solution and can’t be used in deployment (where you want to set display_errors to 0). For a long-term solution, you really want to locate the Apache or PHP error log and tail it.
To try to find the error log, run the following script:
<?php phpinfo(); ?>
In the Configuration > PHP Core section, look for error_log. If that’s not set, you can set it in your php.ini file. All errors will be recorded to that file, even if you have display_errors set to 0.
Add a php file to your server and put this in that file:
<?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
Try checking your web server's error log (for instance, /var/log/apache2/error.log is a common location for the Apache2 log) and see if there is an error reported from PHP there.
You may want to set the php error reporting level in your ini file if this is a local development server.
It seems, that your php does not have postgresql support, cf. 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.

mysql_connect() on localhost

I am trying to implement a little 'intranet' on my home network, but I am an apache/mysql configuration noob...
Running fedora 10, and have apache, mysql, and php set up as well as i know how. However, when I try using a standard form with POST, the php script seems to error out on the mysql_connect(...); line. I don't get an error message, in fact the browser page is blank, even in the view source window. Here is what I have:
$conn = mysql_connect("localhost:1186", "user", "password");
...
I have added the username and password in the mysqladmin tool, and i've tried "localhost" and "localhost:1186", as I saw the 1186 port referenced in my my.cnf file.
Obviously I have something configured wrong, any ideas?
The resulting page is blank when there's an error. One of the more common errors to make in your setup is to forget to install either the php-mysql or mysql-server packages. Verify that they're installed, and if not install either or both and then restart the httpd service, and start the mysql service if not running.
the default for a fresh mysql install would be
$conn = mysql_connect("localhost:3306", "root", "");
or just
$conn = mysql_connect("localhost", "root", "");
This is good for testing purposes but leaving the root account unprotected is a bad habit.

Categories