[PHP-DB] big/small letters with oracle

2004-06-01 Thread Torsten Lange
Hello,
I want to automatically generate a select list, where a user can 
select all measurement parameter, lets say Na, Mg, Cl and Si as (s)he 
likes. For instance I have a specific spring and all chemistry parameter 
are saved in one table. For our Oracle9iDB, this parameter select list 
can be easily populated using the query:

select column_name from user_tab_columns
where table_name = 'ANALYSES_SPRINGS';
But when using queries on the USER_... data dictionary, Oracle delivers 
always big letters, which is for chemical elements (NA vs. Na) or 
location names (ALICE SPRINGS vs. Alice Springs) and location codes 
often uncomfortable to read. Has anyone a better solution? (I try to 
avoid handling every possible case with string fucntions.)

Thank you, Torsten
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] big/small letters with oracle No2

2004-06-01 Thread Torsten Lange
 But when using queries on the USER_... data dictionary, Oracle 
delivers always big letters, which is for
 chemical elements (NA vs. Na) or location names (ALICE SPRINGS vs. 
Alice Springs) and location codes
 often uncomfortable to read.

It happend in the heat of the moment... The above is only the case for 
column names, i.e. the parameter columns (Na, Mg...). Locations etc. 
belonging of course to data sets.

Torsten
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Drop-down box in php

2004-04-20 Thread Torsten Lange
I use html forms with select field size 1 and the option values and/or 
what is supposed to appear in the box. This you populate by your DB 
query, maybe using an array and a loop (from 0 to ..).

Torsten

andy amol schrieb:

hi,
  I would like to know how to create and populate drop down boxes in php.
I want the value to be populated from database.
What I am try to do is to provide the forign key value as combo box option, so that I 
do not have to check for referential integrity.
Also if you can help me with a date validation program I will be grateful.

Thanks in advance.




-
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢
 

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] ocistatement

2004-03-05 Thread Torsten Lange
Hello,
I receive an array from an OCIFetchStatement() and want to address its 
elements by indices, which fails. The original select has two columns.
How do I have to visualize that array? I want to load it into an 
option list.  I tried also some examples with while(list...), but it 
can not work until I don't know the structure.

Thanks for help,
Torsten
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] SELECT

2004-03-04 Thread Torsten Lange
peppe schrieb:

for ($row =1; $row = $numRows; $row++) {
  $rowArray = mysql_fetch_array($result);
$access1   = $rowArray[1];
Hi Peppe,
although I don't know the function mysql_fetch_array()...
why you use $rowArray[1], which is the first element (if $rowArray is of 
type array). change it to $rowArray[$row].
Torsten

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] global variables

2004-03-02 Thread Torsten Lange
Yes agreed - but you cannot store them in a variable because they will
be lost each time the page reloads. Why not store them in a cookie?
Hello Davey,
thank you for help! I now don't use a cookie but added a column for this 
purpose in my usertable in the db.

Torsten

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] global variables

2004-03-01 Thread Torsten Lange
Hi,
I build a small web interface to a database.
I include into the index.php the filepaths and a manage.php:
#index.php
?php
session_start();
$base_path = /.../;
include('manage.php');
?
In manage.php I include the variables.php and the functions.php 
and then decide on the status of a variable $page_no which further 
file.php has to be included to perfom the query jobs:

#manage.php
?php
include('variables.php');
include('functions.php');
if(!isset($page_no))
   {
   $page_no = login;
   }
if(!(login_status($session_id)) == 1)
   {
   $page_no = login;
   }
// user logged in?
if(!($page_no == login))
 {
 include('head.php');
 }
 else
  {
  if(isset($_POST['login']))
   {
   if(!($_POST['user'] == )  !($_POST['passw'] ==))
{
$user_pid = check_user($_POST['user'], $_POST['passw']);
if(($user_pid != false)  (login_status($user_pid) == false))
 {
 login($user_pid, $session_id);
 $res_login = 1;
 $page_no = start_select;
 }
 else
 .
 .
 .  
if($res_login == 0)
 {
 include('b_login.php');
 }
}
if($page_no == start_select)
   {
   if(isset($_POST['b_start_select']))
  {
  if(!($_POST['sources'] == ))
 {
 switch($_POST['sources'])
{
case wells: $page_no = wells;
  break;
case springs:   $page_no = springs;
  break;
case precipitation: $page_no = precipitation;
  break;
case surface:   $page_no = surface;
  break;
case used:  $page_no = used;
  break;
default:  $page_no = start_select;
}
 }
  }
   }
if(!($page_no == login))
   {
   switch($page_no)
  {
  case start_select:  include('b_start_select.php');
break;
  case wells: include('b_wells.php');
break;
  case springs:   include('b_springs.php');
break;
  case precipitation: include('b_precipitation.php');
break;
  case surface:   include('b_surface.php');
break;
  case used:  include('b_used.php');
break;
  default:  echo If you see this side, please mail to.;
  }
   include('fuss.php');
   }
?

I declared the $page_no in my

#variables.php as
$v_dec[page_no] = $page_no.
Now I have the problem that after login and switching to 
b_start_select.php still $page_no=start_select, because I can print it 
to this page:

echo $page_no gives: start_select
but
echo $v_dec[page_no] prints nothing
Second problem: When I pass my selection through the form on the 
b_start_select.php (form action = index.php) $page_no again becomes 
unset. That means I fall back to the login page.

Any suggestions? How in general do you this.

Thank you,
Torsten
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] global variables

2004-03-01 Thread Torsten Lange
Richard Davey wrote:

 You don't check $v_dec in your manage.php script though, you check to
 see if $page_no is set which it never will be, because no-where do you
 give it a value.
Thanks Davey,
but is $page_no not set every time (see below) or did you mean that I 
must rather use $v_dec[page_no] in the code?

if(!isset($page_no))
 {
 $page_no = login;
 }
$page_no is set to login
if(!(login_status($session_id)) == 1)
   {
   $page_no = login;
   }
$page_no is set to login
if(($user_pid != false)  (login_status($user_pid) == false))
   {
   login($user_pid, $session_id);
   $res_login = 1;
   $page_no = start_select;
If login ok then $page_no is set to start_select.
if(!($page_no == login))
switch {
  case...: $page_no=new value}
Torsten

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] global variables

2004-03-01 Thread Torsten Lange
Hello Devey,

 $v_dec[page_no] = $page_no;
 Which means that $v_dec will always equal nothing, because at the
 point at which the file is included, $page_no hasn't been set to
 anything at all.
You mean this will unset $v_dec[page_no]?
This explains why at reload of index.php happens what happend.
But how to solve it? I _have_ to store some variables anywhere.
The session management at this point is rudimentary. I wrote it that 
way, that it works for now, i.e. building the query pages. This is of 
course not the final session management. At login I just write the 
session_id() into the table without checking if the user already owns a 
session. I left it to the end of work. So maybe it is not a problem of 
login_status()?

function check_user($check_name, $check_passw)
   {
   $connect = @OCILogon(, , );
   if(!$connect)
  {
  $err_oci = OCIError();
  echo (2) No connection - OCIError(): 
nbsp;nbsp;nbsp;.$err_oci[message];
  echo p;
  }
   else
  {
  $sql_check = SELECT count(*) AS count FROM user_web
   WHERE user_name = '.$check_name.' AND user_pass = 
'.$check_passw.';
  $stmt = OCIParse($connect, $sql_check);
  OCIExecute($stmt);

  while(OCIFetch($stmt))
 {
 $res_check = (int) OCIResult($stmt, COUNT);
 }
  if(!$res_check == 1)
 {
 OCIFreeStatement($stmt);
 OCILogOff($connect);
 return(false);
 }
 else
{
$sql_check = SELECT user_pid FROM user_web
  WHERE user_name = '.$check_name.' AND 
user_pass = '.$check_passw.';
$stmt = OCIParse($connect, $sql_check);
OCIExecute($stmt);

while(OCIFetch($stmt))
{
$user_pid = (int) OCIResult($stmt, USER_PID);
}
OCIFreeStatement($stmt);
OCILogOff($connect);
return($user_pid);
}
  }
   }
function login($user_pid, $session_id)
   {
   $connect = @OCILogon(, , );
   if(!$connect)
  {
  $err_oci = OCIError();
  echo (2) No connection - OCIError(): 
nbsp;nbsp;nbsp;.$err_oci[message];
  echo p;
  }
   else
  {
  $sql_login = UPDATE user_web SET user_session = '.$session_id.'
WHERE user_pid = '.$user_pid.';
  $stmt = OCIParse($connect, $sql_login);
  OCIExecute($stmt);
  }
   OCIFreeStatement($stmt);
   OCILogOff($connect);
   }

function login_status($session_id)
   {
   $connect = @OCILogon(, , );
   if(!$connect)
  {
  $err_oci = OCIError();
  echo (2) No connection - OCIError(): 
nbsp;nbsp;nbsp;.$err_oci[message];
  echo p;
  }
   else
  {
  $sql_session_id = SELECT count(user_session) FROM user_web
WHERE user_session = '.$session_id.';
  $stmt = OCIParse($connect, $sql_session_id);
  OCIExecute($stmt);

  while(OCIFetch($stmt))
 {
 $res_status = OCIResult($stmt, COUNT(USER_SESSION));
 }
  if(!$res_status == 1)
 {
 return(false);
 }
 else
{
return($res_status);
}
  }
OCIFreeStatement($stmt);
OCILogOff($connect);
   }
Now I changed $page_no to $v_dec[page_no] with the same result.
If through submitting a form index.php is reloaded, but the value in 
$v_dec[page_no] get lost.

#manage.php
?php
$session_id = session_id();
include('variables.php');
include('functions.php');
if(!isset($v_dec[page_no]))
   {
   $v_dec[page_no] = login;
   }
if(!(login_status($session_id)) == 1)
   {
   $v_dec[page_no] = login;
   }
/* User logged in? */
if(!($v_dec[page_no] == login))
   {
   include('head.php');
   }
   else
  {
  if(isset($_POST['login']))
 {
 if(!($_POST['user'] == )  !($_POST['passw'] ==))
{
$user_pid = check_user($_POST['user'], $_POST['passw']);
if(($user_pid != false)  (login_status($user_pid) == false))
   {
   login($user_pid, $session_id);
   $res_login = 1;
   $v_dec[page_no] = start_auswahl;
   }
   else
  {
  $res_login = 0;
  $res_login_text = Login incorrect.;
  }
}
else
   {
   $res_login = 0;
   $res_login_text = Insert Login AND Passwort.;
   }
 }
 else
{
$res_login = 0;
}
  if($res_login == 0)
 {
 include('b_login.php');
 }
  }
/* if page = wells,
springs,
precipitation,
surface
used überprüfen, ob Formulare abgeschickt */
if($v_dec[page_no] == start_select)
   {
   if(isset($_POST['b_start_select']))
  {
  if(!($_POST['sources'] == ))
 {
 switch($_POST['sources'])
{
 

[PHP-DB] oracle: fetch a query result into an array

2004-02-18 Thread Torsten Lange
Hello,
I'm a php beginner and not succeed in fetching an oracle query result 
into an array. I want to load the colum names of a table (from an 
Oracle9i) into a select-field. There is something working, but only 
the last column name appears in the select field and is  wraped by each 
letter.
For instense acw_fid_lab:
 ___
|non|
|all|
|A  |
|C  |
 .
 . and so on.

What are my mistakes? If anyone could suggest me how to solve it or 
using a better approach...

Thank you, Torsten
---
My last version (I also tried OCIFetchInto before):
---
function fill_select($table_name)
   {
   $connect = @OCILogon(, , );
   if(!$connect)
  {
  $err_oci = OCIError();
  echo (2) No connection - OCIError(): 
nbsp;nbsp;nbsp;.$err_oci[message];
  echo p;
  }
  else
 {
 $sql_table_names = SELECT column_name FROM user_tab_columns
 WHERE table_name = '.$table_name.';
 $stmt = OCIParse($connect, $sql_table_names);
 OCIExecute($stmt);

 $column_name = array();
 $counter = 0;
 while(OCIFetch($stmt))
{
$column_name = OCIResult($stmt,'COLUMN_NAME');
$counter++;
}
 if($counter == 0)
{
$column_name[0] = nothing found;
}
 OCIFreeStatement($stmt);
 OCILogOff($connect);
 return($column_name);
 }
   }
# This is a cut-out from that file I call the function from
echotd\n;
echoselect name=\chemistry\ size=\12\ multiple\n;
echooptionnone/option\n;
echooptionall/option\n;
 $table_name = AN_CHEMISTRY_WATER;
 $count = (int) count_table_columns($table_name);
 $column_names = fill_select($table_name);
 for($i=1; $i=$count; $i++)
{
echo option,$column_names[$i],/option\n;
}
echo/select\n;
echo/td\n;
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php