Operating System - HP-UX
1836462 Members
2006 Online
110101 Solutions
New Discussion

Re: Help in PHP access to database

 
SOLVED
Go to solution
Ricardo Bassoi
Regular Advisor

Help in PHP access to database


Hi All,

I??m new at PHP and I found some problems trying to pass a call to a function ( ABRE_CL() ) inside the option fied in the form.
Somebody can help ?

Regards

Bassoi

If you never try, never will work
10 REPLIES 10
Ricardo Bassoi
Regular Advisor

Re: Help in PHP access to database


Sorry ,

The attachment is not so good !

Regards
If you never try, never will work
Ricardo Bassoi
Regular Advisor

Re: Help in PHP access to database


Hi Again,

I??ll try the last time
If you never try, never will work
Ricardo Bassoi
Regular Advisor

Re: Help in PHP access to database


function HTML_Head() {
echo "

Processing Form

";
}

function HTML_Form() {

function ABRE_CL() {

$cnx = odbc_connect( 'Workload' , '', '' );
if (!$cnx) {
Error_handler( "Error in odbc_connect" , $cnx );
}

$cur= odbc_exec( $cnx, "select * from Clientes" );
if (!$cur) {
Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
}
$nbrow=0; //Local variable to count number of rows

// fetch the succesive result rows
while( odbc_fetch_row( $cur ) ) {
$nbrow++;
$desc= odbc_result( $cur, 2 ); // get the field "Descri????o"

echo "$desc
";
}

;

// close the connection. important if persistent connection are "On"
odbc_close( $cnx);
}

echo "

Por favor insira os seus dados para o Workload


First Name:

Teste:re

Teste de Sele????o:




Last Name:

Phone Number:




";

}

function HTML_Existing() {
echo "Database Workload OK";
}

function HTML_Foot() {
echo "";
}

HTML_Head();
HTML_Form();
HTML_Existing();
HTML_Foot();

?>

If you never try, never will work
benoit Bruckert
Honored Contributor

Re: Help in PHP access to database

Hi Bassoi,
You should just change in your call :
hth
Benoit
Une application mal pansée aboutit à une usine à gaze (GHG)
benoit Bruckert
Honored Contributor

Re: Help in PHP access to database

Or better :
instead of :
echo "

Por favor insira os seus dados para o Workload


First Name:

Teste:re

Teste de Sele????o:




Last Name:

Phone Number:




";
do :
?>

Por favor insira os seus dados para o Workload


First Name:

Teste:re

Teste de Sele????o:




Last Name:

Phone Number:




Une application mal pansée aboutit à une usine à gaze (GHG)
Ricardo Bassoi
Regular Advisor

Re: Help in PHP access to database

Sorry,

I did what you told me but didn??t work. We have no result inside
the form.
If I call the function ABRE_CL () from outside the form it works fine !

What can I do ?

Regards,

Bassoi
If you never try, never will work
benoit Bruckert
Honored Contributor

Re: Help in PHP access to database

hi ,
I try this time , here's the solution :
echo "
ACTION=\"DataAccess.php3\">
Por favor insira os seus dados para o Workload


First Name:

Teste:re

Teste de SeleC'C#o:




Last Name:

Phone Number:




";

nota :
You cannot include a second php call (Tell me if it's ok...
regards
Benoit
Une application mal pansée aboutit à une usine à gaze (GHG)
Ricardo Bassoi
Regular Advisor

Re: Help in PHP access to database

I tried it again but it didn??t work !!!

Regards

Bassoi
If you never try, never will work
benoit Bruckert
Honored Contributor

Re: Help in PHP access to database

what's your error ??
I made it works on my side !
Warning,
I have disabled the odbc functions (I don't have odbc built in),
here is the full source i used :

function HTML_Head() {
echo "

Processing Form

";
}

function HTML_Form() {

function ABRE_CL() {
echo "toto
";
return;
$cnx = odbc_connect( 'Workload' , '', '' );
if (!$cnx) {
Error_handler( "Error in odbc_connect" , $cnx );
}

$cur= odbc_exec( $cnx, "select * from Clientes" );
if (!$cur) {
Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
}
$nbrow=0; //Local variable to count number of rows

// fetch the succesive result rows
while( odbc_fetch_row( $cur ) ) {
$nbrow++;
$desc= odbc_result( $cur, 2 ); // get the field "DescriC'C#o"

echo "$desc
";
}

;

// close the connection. important if persistent connection are "On"
odbc_close( $cnx);
}

echo "
ACTION=\"DataAccess.php3\">
Por favor insira os seus dados para o Workload


First Name:

Teste:re

Teste de SeleC'C#o:




Last Name:

Phone Number:




";

}

function HTML_Existing() {
echo "Database Workload OK";
}

function HTML_Foot() {
echo "";
}

HTML_Head();
HTML_Form();
HTML_Existing();
HTML_Foot();

?>

cut and paste it in a test.php file and try to access to it.
You should also see the source html file generated by php (view source in your browser), you can have interrested information...
Une application mal pansée aboutit à une usine à gaze (GHG)
benoit Bruckert
Honored Contributor
Solution

Re: Help in PHP access to database

Hi again,
I read a little more your script, you have also a trouble in the pure html side
:
If your connection to odbc is ko, you can see it by viewing the source of the html page.
if it's ok, then, change this line :
echo "$desc
";
to
echo "$desc";

to make a test (without odbc connection), from my previous sample, change :
echo "toto
";
to
echo "toto
";
echo "toto2
" ;

it should work !!
check also your odbc conectivity..
If you are running on HPUX (this is the name of this forum), I'm sure you can build php with odbc support (it's a WIN32 feature).

hope that help
Benoit
Une application mal pansée aboutit à une usine à gaze (GHG)