Page 1 of 1
connectio problem with php5&oracle 8i
Posted: Thu Jul 05, 2007 4:01 am
by paudelvikash
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hi all
i tried to establish a connectio with oracle 8i using oci_connect() function
but it throws following error:
Fatal error: Call to undefined function oci_connect() in C:\Program Files\xampp\htdocs\conn.php on line 6
i have uncomment php_oci8.dll
i am using xampp 1.5.2
Code looks like something
Code: Select all
<?php
$user="test";
$password="test";
$dbname="students";
$conn = oci_connect($user, $password,'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.202)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=students))');
if (!$conn)
echo "could not connect to server";
else
echo"Connection successful";
?>
any suggestion?
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Thu Jul 05, 2007 7:23 am
by feyd
Run the following in a new file and tell us the results please.
Code: Select all
<?php
$neg = array('off', 0, false, '', null);
$flags = array(
'Register Globals' => 'register_globals',
'Short Tags' => 'short_open_tag',
'Display Errors' => 'display_errors',
'Magic Quotes GPC' => 'magic_quotes_gpc',
'Magic Quotes Runtime' => 'magic_quotes_runtime',
'Magic Quotes Sybase' => 'magic_quotes_sybase',
);
$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
foreach ($flags as $n => $v)
{
$flags[$n] = (in_array(strtolower(ini_get($v)), $neg) ? 'Off' : 'On');
}
$flags['Config file'] = get_cfg_var('cfg_file_path');
if (empty($flags['Config file']))
{
$flags['Config file'] = '-';
}
$cli = (php_sapi_name() == 'cli');
$eol = "\n";
$gle = get_loaded_extensions();
$rows = array();
$le = '';
$wide = 4;
$j = count($gle);
$pad = $wide - $j % $wide;
$len = max(array_map('strlen', $gle));
$func = create_function('$a', 'return str_pad($a, ' . intval($len) . ');');
$gle = array_map($func, $gle);
for($i = 0; $i < $j; $i += $wide)
{
$le .= ' ' . implode(' ', array_slice($gle, $i, $wide)) . $eol;
}
$ec = array(
'E_STRICT' => 2048, 'E_ALL' => 2047, 'E_USER_NOTICE' => 1024,
'E_USER_WARNING' => 512, 'E_USER_ERROR' => 256, 'E_COMPILE_WARNING' => 128,
'E_COMPILE_ERROR' => 64, 'E_CORE_WARNING' => 32, 'E_CORE_ERROR' => 16,
'E_NOTICE' => 8, 'E_PARSE' => 4, 'E_WARNING' => 2, 'E_ERROR' => 1,
);
$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
if (($t & $v) == $v)
{
$e[] = $n;
$t ^= $v;
}
}
if (ceil(count($ec) / 2) + 1 < count($e))
{
$e2 = array();
foreach ($ec as $n => $v)
{
if (!in_array($n, $e) and $n != 'E_ALL')
{
$e2[] = $n;
}
}
$er = $er . ' ((E_ALL | E_STRICT) ^ ' . implode(' ^ ', $e2) . '))';
}
else
{
$er = $er . ' (' . implode(' | ', $e) . ')';
}
if (!$cli)
{
echo '<html><head><title>quick info</title></head><body><pre>', $eol;
}
echo 'PHP Version: ', $ve, $eol;
echo 'PHP OS: ', $os, $eol;
echo 'Error Reporting: ', $er, $eol;
foreach ($flags as $n => $v)
{
echo $n, ': ', $v, $eol;
}
echo 'Loaded Extensions:', $eol, $le, $eol;
if (!$cli)
{
echo '</pre></body></html>', $eol;
}
?>
Posted: Mon Jul 09, 2007 3:26 am
by paudelvikash
Thanks for your interest
i apologise for the late response
The result it shows are as follows:
Code: Select all
PHP Version: 5.1.2
PHP OS: WINNT
Error Reporting: 2039 ((E_ALL | E_STRICT) ^ E_STRICT ^ E_NOTICE))
Register Globals: Off
Short Tags: On
Display Errors: On
Magic Quotes GPC: On
Magic Quotes Runtime: Off
Magic Quotes Sybase: Off
Config file: C:\Program Files\xampp\apache\bin\php.ini
Loaded Extensions:
bcmath calendar com_dotnet ctype
date ftp iconv odbc
pcre Reflection session libxml
standard tokenizer zlib SimpleXML
dom SPL wddx xml
xmlreader xmlwriter apache2handler Zend Optimizer
Posted: Mon Jul 09, 2007 6:46 am
by volka
You already had a thread on the exact same topic
see
viewtopic.php?t=70333
Posted: Mon Jul 09, 2007 6:49 am
by feyd
That one was the newer of the two threads, so it's locked.

Posted: Mon Jul 09, 2007 6:52 am
by volka
oh... right

Still would love to see the output of
Code: Select all
<?php
$ini = get_cfg_var('cfg_file_path');
echo 'version: ', phpversion(), "<br />\n";
echo 'sapi: ', php_sapi_name(), "<br />\n";
echo 'php.ini: ', $ini, "<br />\n";
echo "<pre>\n--\n";
foreach(file($ini) as $l) {
if ( false!==strpos($l, 'oci') ) {
echo $l;
}
}
echo "--\n</pre>\n";
...curious me

Posted: Mon Jul 09, 2007 6:57 am
by feyd
Oracle isn't in the actively loaded extensions as shown by the output of the "run this" script.
Posted: Mon Jul 09, 2007 7:48 am
by volka
correct, and now I'd like to see if this is because paudelvikash didn't edit the php.ini or didn't edit the right php.ini or ignored any warning message messages/messageboxes when starting the webserver.
Posted: Wed Jul 11, 2007 2:13 am
by paudelvikash
well there was few confusion going round here and the problem of connection was solved with yours guidance . Thanks for that .
well feyd, you expected oci_8|PDO_OCI to appear and it did
and volka , i think u might be expecting
extension=php_oci8.dll
extension=php_pdo_oci.dll
extension=php_pdo_oci8.dll
well the connection problem was solved. but the new problem has occurred and other thing i have switched to 10g
when 10g was installed , the name of the machine was changed. and this has now restricted the connection and throws the following error:
Notice: Could not establish a connection: ORA-12541: TNS:no listener in C:\Program Files\xampp\htdocs\dbConn4.php on line 38
Warning: ocierror() expects parameter 1 to be resource, boolean given in C:\Program Files\xampp\htdocs\dbConn4.php on line 50
Notice: Failed to parse SQL query: in C:\Program Files\xampp\htdocs\dbConn4.php on line 52
i tried with replacing the name of the host computer with its IP address but the problem still exist.
the host name in listener.ora file was also changed.
waiting for your suggestion.