I5_PREPARE() problem

General discussion on Zend Platform for IBM System i

I5_PREPARE() problem

Postby lenny61 on Tue Jun 23, 2009 4:50 pm

i am getting this error Error number =262 msg=Parameter 2 must be a ressource but an array was passed

this is my code. i am newbe at php and zend. Any ideas?


<html>
<body>

<?php

include ("connect.php");


$description = array(
array(
"Name"=>"CUST",
"IO"=>I5_INOUT,
"Type"=>I5_TYPE_PACKED,
"Length"=>"7"
),
array(
"Name"=>"NME",
"IO"=>I5_INOUT,
"Type"=>I5_TYPE_CHAR,
"Length"=>"25"
)
);

$desc = file_get_contents("/www/zendcore/htdocs/wwphpcust.pcml");



$pgm = i5_prepare("BWLIB/WWPHPCUST", $description);



if ($pgm === FALSE) die("<br>Program prepare error. Error number =".i5_errno()."
msg=".i5_errormsg());
i5_close($conn);
if (!$pgm){
echo "<br>";
$errtab=i5_error();
echo "<br>";
var_dump($errtab);
echo "<br>";
var_dump($description);
die();
}
$parmIn = array(
"CUST"=>$_POST["CUST"],
"NME"=>$_POST["NME"]

);

$parmOut = array(
"CUST"=>"CUST",
"NME"=>"NME"
);

$ret = i5_program_call($pgm,$parmIn,$parmOut);
//$ret - i5_program_call($pgm);

if (!$ret){
$errtab=i5_error();
var_dump($errtab);
die();
}





i5_program_close($pgm);
i5_close($conn);


?>

</body>
</html>
lenny61
 
Posts: 5
Joined: Tue Jun 23, 2009 4:32 pm

Re: I5_PREPARE() problem

Postby massimilianoc on Mon Jul 06, 2009 2:05 pm

In which line of your code you get the error?

AFAIK, the 'i5_prepare()' needs a connection (resource) to the DB as second parameter.
According to your code you passed an array.

I think you should be having a call to 'is_connect()' before you call 'i5_prepare()'.

Best regards,
Massi.
Best regards,
Massi.
massimilianoc
 
Posts: 699
Joined: Thu Mar 12, 2009 11:58 am

Re: I5_PREPARE() problem

Postby shlomov on Mon Sep 07, 2009 1:54 pm

Program call usiing PCML file example:

<?php
// Connect to server
$conn = i5_connect("127.0.0.1", "shlomo", "xxxxx", array(I5_OPTIONS_INITLIBL=>"SHLOMOPHP,SHLOMO"));
//$conn = i5_connect("127.0.0.1", "shlomo", "xxxxx", array(I5_OPTIONS_JOBNAME => "SHLOMOjob"));
if (!$conn) die("<br>Connection failed. Error number =".i5_errno()." msg=".i5_errormsg());

$description = file_get_contents('/www/zendcore/htdocs/shlpcml.pcml');
/*'<pcml version="4.0">
<!-- RPG program: ASARFTPMSG -->
<!-- created: 2006-12-28-14.32.15 -->
<!-- source: SHLOMO/QRPGLESRC(ASARFTPMSG) -->
<program name="ASARFTPMSG" path="/QSYS.LIB/SHLOMO.LIB/ASARFTPMSG.PGM">
<data name="MESSAGE" type="char" length="200" usage="inputoutput" />
</program>
</pcml>';*/

$pgm = i5_program_prepare_PCML($description);

if (!$pgm) die("<br>Program prepare error. Error number =".i5_errno()." msg=".i5_errormsg());

$parmIn = array('MESSAGE'=>'shlomo test record number 8');

$parmOut = array('MESSAGE' => 'message');

$ret = i5_program_call($pgm, $parmIn, $parmOut);

if (!$ret) die("<br>Program call error. Error number=".i5_errno()." msg=".i5_errormsg());
//var_dump($parmOut);
echo "<br>Message:"; var_dump($message);
// Close program call
i5_program_close($pgm);

// Close connection
i5_close($conn);
?>
Shlomo Vanunu
IBM System i
User avatar
shlomov
Zend Global Support
 
Posts: 137
Joined: Mon Dec 29, 2008 2:38 pm

Re: I5_PREPARE() problem

Postby pete7318 on Tue Dec 17, 2013 6:28 am

I am really bad at coding.
pete7318
 
Posts: 1
Joined: Tue Dec 17, 2013 6:24 am


Return to Zend Platform for i5/OS

Who is online

Users browsing this forum: No registered users and 1 guest