× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



That is weird because in the last example you sent I was convinced that you did not have quotes.

Glad it is fixed anyway.


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Aug 14, 2017, at 7:47 AM, Jason Aleski <jason.aleski@xxxxxxxxx> wrote:

Alan,

Thank you! That was it. I didn't realize it was a constant. Now, I can change the libraries and it pulls the the table without fulling qualifying it; from the i5_libl. I hate it when I look at code for so long and miss obvious errors!

Best Regards,
-JA-

For reference, I've placed the code below.


<?php
//Adding additional PHP files
require_once('../../masterInclude.php');

//Overriding options for testing.
$database['options'] = array('i5_naming' => DB2_I5_NAMING_ON,
'i5_libl' => 'CUSLIB'
);

//Building connection
$conn = db2_connect($database['server'],
$database['username'],
$database['password'],
$database['options']
);

if($conn){
print 'Connection successful.';

//Preparing query
$params = array('123456789', 'MYLASTNAME');
$query = "SELECT count(*) AS ROWCOUNT FROM CMSTRP1 WHERE cusnbr = ? AND lstnam = ?";
$stmt = db2_prepare($conn, $query);

//Running Query
$result = db2_execute($stmt, $params);

//Getting results
if($result){
$row = db2_fetch_assoc($stmt);
print $row['ROWCOUNT'];
}

//Closing connection
db2_close($conn);

}else{
//Something didn't go as planned :(
print 'Connection failed.';
}

die("I'm done. **while throwing papers in the air**");






On 8/11/2017 4:37 PM, Alan Seiden wrote:
Jason, try removing quotes from ‘DB2_I5_NAMING_ON’.

DB2_I5_NAMING_ON is a constant, so it shouldn’t use quotes.

Try and let us know.

Alan

Alan Seiden
Principal, Seiden Group
The PHP on IBM i Experts



Free PHP tips: http://www.seidengroup.com/tips <http://www.seidengroup.com/tips>

Office: 201-447-2437 Cell: 201-248-4704
http://www.seidengroup.com <http://www.seidengroup.com/> | alan@xxxxxxxxxxxxxxx <mailto:alan@xxxxxxxxxxxxxxx>
http://twitter.com/alanseiden <http://twitter.com/alanseiden>
On Aug 11, 2017, at 2:20 PM, Jason Aleksi <jason.aleski@xxxxxxxxx <mailto:jason.aleski@xxxxxxxxx>> wrote:

I was wondering if someone could point me in a direction regarding a
db2_prepare statement. In my connection options, I specify a library list.
However, with or without the library list, I still have to fully qualify
the database name in the query. Otherwise, I get a db2_prepare():
Statement Prepare Failed in error.


$database['options'] = array('i5_libl' => 'CUSLIB',
'i5_naming' => 'DB2_I5_NAMING_ON'
);

$conn = db2_connect($database['server'],
$database['username'],
$database['password'],
$database['options']
);

if($conn){
print 'Connection successful.';

$params = array('123456789', 'MYLASTNAME');
$query = "SELECT count(*) FROM CUSLIB.CUSLOC WHERE locid = ? AND
lastname = ?";
$stmt = db2_prepare($conn, $query);

}else{
print 'Connection failed.';
}



Should I not be able to just use the library list without fully qualifying
the database in the SQL statement?

-JA-
--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxx <mailto:OpenSource@xxxxxxxxxxxx>
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/opensource <http://lists.midrange.com/mailman/listinfo/opensource>
or email: OpenSource-request@xxxxxxxxxxxx <mailto:OpenSource-request@xxxxxxxxxxxx>
Before posting, please take a moment to review the archives
at http://archive.midrange.com/opensource <http://archive.midrange.com/opensource>.

--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/opensource.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.