ODBC DB2 data fetch error (out of memory error) - php-7.2

I have connected ODBC to remote DB2 successfully, I'm able to insert data in a table but when fetching the data I'm getting PHP Fatal error: Out of memory (allocated 2097152) (tried to allocate 206158430219 bytes) error.
i'm using, ubuntu 18, DB2 DSDrive fixpack 10, unixodbc v 2.3.4 , php v 7.2
i tested unixODBC using isql -v , i'm able to fetch the data, but i'm only getting the problem when fetching using php script
I created another db2 instance and tried but I'm getting the same error
i tried to set the memory limit from 128M to 200M,in php.ini, still not worked
$conn = odbc_connect( $conn_string, "", "" );
if( $conn )
{
echo "Connection succeeded.";
$sql = "insert into testsam values('testname',20,'male');";
$rs = odbc_exec($conn,$sql); // here i'm getting problem while using select * from testsam
echo "<table><tr>";
echo "<th>User Name $rs</th></tr>";
#while (odbc_fetch_row($rs)){
# $user = odbc_result($rs,"NAME");
# print_r($user);
#}
if($rs){
echo "data fetched";
}
odbc_close($conn);
//echo "</table>";
# Disconnect
#
#odbc_close( $conn );
}
else
{
echo "Connection failed.";
}

Related

Strange MySQL connect error

I am working with phpmyadmin version 4.4.15.7. DB server MariaDB 5.5.47 localhost via unix socket utf-8. Webserver apache 2.4.6. Php version 5.4.16. Originally this code worked well running with cpanel but recently I switched to vestacp running .9.8-16. connection credentials seem to be correct. Error is thrown after using mysqli_connect function:
Failed to connect to MySQL: php_network_getaddresses: getaddrinfo
failed: Name or service not known
Here is my php file--redacted a little for security purposes. The first echo statement is the one thrown.
<?php
$sql = "SELECT * FROM Staff";
// Create connection
$con=mysqli_connect(‘localhost',’pil_pil’,’pass_password’,’db_db’);
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// Check if there are results
if ($result = mysqli_query($con, $sql))
{
// If so, then create a results array and a temporary one
// to hold the data
$resultArray = array();
$tempArray = array();
// Loop through each row in the result set
while($row = $result->fetch_object())
{
// Add each row into our results array
$tempArray = $row;
array_push($resultArray, $tempArray);
}
// Finally, encode the array to JSON and output the results
echo json_encode($resultArray);
}
// Close connections
mysqli_close($con);
?>
Thank you for all the help guys. It appears to be working now. I don't know what happened. It may have been server side because I contacted the server admin. I think it may have been a dns transition phase from the cpanel dns and it just needed time. I didn't change any code on my part.

PHP with Oracle - Error 12537 (TNS:connection closed)

I am trying to use PHP with Oracle 11g. I have configured the php.ini file (enabled php_oci8.dll, php_oci8_11g.dll)
This is the testing code I'm using:
if ($conn = oci_connect('system', 'pass', '//localhost:1158/em')) {
print 'Successfully connected to Oracle Database XE!';
oci_close($conn);
} else {
$errmsg = oci_error();
print 'Oracle connect error: ' . $errmsg['message'];
}
?>
But I'm getting this error:
Oracle connect error:
ORA-12537: TNS:connection closed
Any solution?

LOAD DATA LOCAL INFILE Error in query (1148): The used command is not allowed with this MySQL version

I've seen this question asked about a dozen times and the answers that seem to work for everyone are the same: add local-infile = 1 to [mysql], [mysqld], and add [client] loose-local-infile=1 to my.conf. I've done all of that as well as adding file permission to my DB user for . and I still get the same error.
I'm running MySQL 5.6 on a virtual Ubuntu 14.04 server. Can anyone let me know what I'm missing? I've got this working successfully on my live server which is a VPS running CentOS and MySQL 5.6 as well and I don't remember having to jump through any hoops to get it working, though it was some time ago that I set it up.
If it matters, I'm attempting this import through the below PHP function:
// Connect to a database without using prepared statements (for LOAD FILE feed commands)
// $query = query to execute; $rs = return a result set if true
function db_query_unprepared($query, $rs = false) {
// Create database connection
$link = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
if (!$link) {
print 'Error connecting to MySQL Server. Errorcode: ' . mysqli_connect_error();
exit;
}
// Execute the query
if ($rs) {
$queryresults = array();
$counter = 0;
if (mysqli_multi_query($link, $query)) {
do {
// Save results to an array
if ($result = mysqli_store_result($link)) {
while ($row = mysqli_fetch_assoc($result)) {
$queryresults[$counter][] = $row;
}
mysqli_free_result($result);
$counter++;
}
} while (mysqli_next_result($link));
}
else {
print mysqli_error($link);
}
}
else {
mysqli_multi_query($link, $query);
}
mysqli_close($link);
// Return the results
if (isset($queryresults)) {
return $queryresults;
}
}
That in turn is called like so:
db_query_unprepared('LOAD DATA LOCAL INFILE \'/path/to/mydatafile.csv' . '\' INTO TABLE feed_mydata FIELDS TERMINATED BY \',\' ENCLOSED BY \'"\' LINES TERMINATED BY \'\r\n\' IGNORE 1 LINES ( field1, field2, field3 )');

Oracle Connection Error in PHP. Fatal error: Call to undefined function oci_connect()

I am working on this project where i need to connect to the Oracle database. I am using the latest version of WAMP 2.2 and also activated all the extensions related the Oracle in PHP extensions. I have used following code for the connection to Oracle Database.
<?php
$dbHost = "192.168.0.205";
$dbHostPort="1523";
$dbServiceName = "orcl";
$usr = "system";
$pswd = "admin";
$dbConnStr = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
(HOST=".$dbHost.")(PORT=".$dbHostPort."))
(CONNECT_DATA=(SERVICE_NAME=".$dbServiceName.")))";
if(!$dbConn = oci_connect($usr,$pswd,'192.168.0.205:1158/em')){
$err = oci_error();
trigger_error('Could not establish a connection: ' . $err['message'], E_USER_ERROR);
}
else
{
echo "COnnected";
}
$strSQL = "SELECT SYSDATE FROM DUAL";
$stmt = oci_parse($dbConn,$strSQL);
if ( ! oci_execute($stmt) ){
$err = oci_error($stmt);
trigger_error('Query failed: ' . $err['message'], E_USER_ERROR);
};
while(oci_fetch($stmt)){
$rslt = oci_result($stmt, 1); print "<h3>query returned: ".$rslt."</h3>";
}
?>
Kindly suggest the error. Thanks in advance.
The OCI8 PHP extension is not available in your PHP installation. See the manual of the OCI8 PHP extension for installtion instructions.

I can't create my database in PHP and MySQL

I am using WAMP and have written a php script to connect to the data base i don't think it's the code because i'm getting an error that says SCREAM: Error suppression ignored for and then get several different errors, some say :
Warning: mysql_connect(): MySQL server has gone away in C:\wamp\www\php.php
Warning: mysql_connect(): Error while reading greeting packet. PID=9044 in C:\wamp\www\php.php
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\php.php
Here is my code:
<?php
$con = mysql_connect("127.0.0.1:80",'user','');
if(!$con){
die( 'error:' . mysql_error());
}
$db = 'CREATE DATABASE db_one';
if(mysql_query($db,$con)){
echo 'data base created';
}
else {
echo 'Err:' . mysql_error();
}
$table = 'CREATE TABLE persons ( fname varchar (15),lname varchar(15), age int)';
mysql_query($table,$con);
mysql_close($con);
?>
Remove the port declaration from the connection.
$con = mysql_connect("127.0.0.1",'user','');
Or change it to 3306 (default for mysql)

Resources