Re: [PHP-DB] csv problem.. read csv from var

2007-02-16 Thread bedul

- Original Message -
From: Niel Archer [EMAIL PROTECTED]
To: php-db@lists.php.net
Sent: Friday, February 16, 2007 1:59 PM
Subject: Re: [PHP-DB] csv problem.. read csv from var


 hi

  the problem i have is.. how about the csv is a var
  DATA===
  $csv=
  A507257,3/2/2007,\Hematologi Lengkap,Cholesterol Total,LDL
  Cholesterol,Trigliserida,HDL Cholesterol,Asam Urat,Gula Darah Puasa,Gula
  Darah 2 Jam PP,Kreatinin,Ureum,Bilirubin Total,Alkali
  Fosfatase,SGOT,SGPT,Urine Lengkap,Feses Rutin,Darah Samar
Faeces,VDRL,Anti -
  HBs,Total PSA,HBsAg,Anti - HCV Total\;
 
  what should i do to make the ouput like above.

 Use

   $arry = explode(',', $csv);

=CODE
?
$csv=
 A507257,3/2/2007,\Hematologi Lengkap,Cholesterol Total,LDL
 Cholesterol,Trigliserida,HDL Cholesterol,Asam Urat,Gula Darah Puasa,Gula
 Darah 2 Jam PP,Kreatinin,Ureum,Bilirubin Total,Alkali
 Fosfatase,SGOT,SGPT,Urine Lengkap,Feses Rutin,Darah Samar
Faeces,VDRL,Anti -
 HBs,Total PSA,HBsAg,Anti - HCV Total\;

$arry = explode(',', $csv);

foreach($arry as $val){
 $txt.= =.$val . br /\n;
}

print $txt;

?

=OUTPUT===
= A507257
=3/2/2007
=Hematologi Lengkap
=Cholesterol Total
=LDL Cholesterol
=Trigliserida
=HDL Cholesterol
=Asam Urat
=Gula Darah Puasa
=Gula Darah 2 Jam PP
=Kreatinin
=Ureum
=Bilirubin Total
=Alkali Fosfatase
=SGOT
=SGPT
=Urine Lengkap
=Feses Rutin
=Darah Samar Faeces
=VDRL
=Anti - HBs
=Total PSA
=HBsAg
=Anti - HCV Total

 to separate the variable into an array, then process it using foreach as
 before

i'll already try that! fail.. it has tobe return 3 not ..10
thx for the reply

 Niel

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


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



[PHP-DB] echo delay...

2007-02-16 Thread Matthew Ferry
Hi fellow php late night peoples

Thanks for everyone's help the last couple of days...
I have learned so much.  The best way to learn this stuff...is simple trial and 
error...
and thanks for good old Ggle!

My problem tonight is very simple.  I just don't know what command I want to 
use.
I want to echo text in a page then take a delay then echo more text/images to 
the same page.

I tried the sleep command with the number of seconds, but it don't load the 
page to the sleep timer is done.

any ideas of what php command I can use?

Matt


RE: [PHP-DB] echo delay...

2007-02-16 Thread Bastien Koert


I would suggest placing all the data into divs and using some js to show 
those divs when the time is right


bastien


From: Matthew Ferry [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] echo delay...
Date: Fri, 16 Feb 2007 03:37:17 -0500

Hi fellow php late night peoples

Thanks for everyone's help the last couple of days...
I have learned so much.  The best way to learn this stuff...is simple trial 
and error...

and thanks for good old Ggle!

My problem tonight is very simple.  I just don't know what command I want 
to use.
I want to echo text in a page then take a delay then echo more text/images 
to the same page.


I tried the sleep command with the number of seconds, but it don't load the 
page to the sleep timer is done.


any ideas of what php command I can use?

Matt


_
Your Space. Your Friends. Your Stories. Share your world with Windows Live 
Spaces. http://discoverspaces.live.com/?loc=en-CA


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



[PHP-DB] Problem with ocilogon

2007-02-16 Thread Dominik Helle

Hi,

I've a problem with php-oci and I hope anybody can help me. I want to 
connect with ocilogon to an Oracle Database. If i call my php-Script in 
the browser, this error message turn up:


Warning: ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. There 
is something wrong with your system - please check that ORACLE_HOME is 
set and points to the right directory in...


That is very funny, because if i activate the file on the command line - 
the connect is possible and no error message turns up.


FYI: My System:  Ubunutu 6, Apache 2 and php 5-with-oci  Oracle 
Database 10g (10.1.0.2).


Thank you for helping.

Dominik

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



Re: [PHP-DB] Problem with ocilogon

2007-02-16 Thread Brad Bonkoski

Dominik Helle wrote:

Hi,

I've a problem with php-oci and I hope anybody can help me. I want to 
connect with ocilogon to an Oracle Database. If i call my php-Script 
in the browser, this error message turn up:


Warning: ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. 
There is something wrong with your system - please check that 
ORACLE_HOME is set and points to the right directory in...


That is very funny, because if i activate the file on the command line 
- the connect is possible and no error message turns up.


FYI: My System:  Ubunutu 6, Apache 2 and php 5-with-oci  Oracle 
Database 10g (10.1.0.2).


Thank you for helping.

Dominik


I'm assuming since you mention the apache, this is a web application...
It looks like the ORACLE_HOME path is not know by apache/PHP.  So, you 
might try stopping apache, and doing something like 'source 
/etc/profile' or wherever your ORACLE_HOME env variable is set, and then 
restarting apache and trying again...

HTH
-B

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



Re: [PHP-DB] Problem with ocilogon

2007-02-16 Thread Dominik Helle

Brad Bonkoski schrieb:

Dominik Helle wrote:

Hi,

I've a problem with php-oci and I hope anybody can help me. I want to 
connect with ocilogon to an Oracle Database. If i call my php-Script 
in the browser, this error message turn up:


Warning: ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. 
There is something wrong with your system - please check that 
ORACLE_HOME is set and points to the right directory in...


That is very funny, because if i activate the file on the command line 
- the connect is possible and no error message turns up.


FYI: My System:  Ubunutu 6, Apache 2 and php 5-with-oci  Oracle 
Database 10g (10.1.0.2).


Thank you for helping.

Dominik


I'm assuming since you mention the apache, this is a web application...
It looks like the ORACLE_HOME path is not know by apache/PHP.  So, you 
might try stopping apache, and doing something like 'source 
/etc/profile' or wherever your ORACLE_HOME env variable is set, and then 
restarting apache and trying again...

HTH
-B


Mhmmm I set this variables in the Apache - but it don't work :(

SetEnv ORACLE_HOME /xxx
SetEnv TNS_ADMIN /xxx
SetEnv LD_LIBRARY_PATH /xxx
SetEnv ORACLE_SID orcl10g
SetEnv NLS_LANG GERMAN_GERMANY.WE8ISO8859P1

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



Re: [PHP-DB] Problem with ocilogon

2007-02-16 Thread roy . a . jones
Here are a couple of things I have done ...

1) Edit the apachectl script and set the variables there
2) Set the variables in your shell then start apache
3) use phpinfo() to display your settings (I also found the below php 
script to work well)

-
?php
phpinfo();
$a= ini_get_all();//Call ini_get_all()
$output=table border=1;   //Start an output string
  while(list($key, $value)=each($a))  //Loop through results
  {
list($k, $v)= each($a[$key]); //Access each array
$output.=trtd
$key
  /tdtd
$v
/tdtd
$k
  /td/tr;//Build output
  }//while
$output.=/table;  //Finish up
echo $output; //Spit it all out
?
-


Roy A. Jones 
US Distribution IT 
GlaxoSmithKline Inc. US Pharma IT, Financial Shared Services IT 
External:
(919) 483-0266
Internal:
703-0266
Fax:
(919) 315-4979
Office:
STH D-1228
Email:
[EMAIL PROTECTED]
Pager:
(919) 312-0729




Dominik Helle [EMAIL PROTECTED] 
16-Feb-2007 09:58
 
To
php-db@lists.php.net
cc

Subject
Re: [PHP-DB] Problem with ocilogon






Brad Bonkoski schrieb:
 Dominik Helle wrote:
 Hi,

 I've a problem with php-oci and I hope anybody can help me. I want to 
 connect with ocilogon to an Oracle Database. If i call my php-Script 
 in the browser, this error message turn up:

 Warning: ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. 
 There is something wrong with your system - please check that 
 ORACLE_HOME is set and points to the right directory in...

 That is very funny, because if i activate the file on the command line 
 - the connect is possible and no error message turns up.

 FYI: My System:  Ubunutu 6, Apache 2 and php 5-with-oci  Oracle 
 Database 10g (10.1.0.2).

 Thank you for helping.

 Dominik

 I'm assuming since you mention the apache, this is a web application...
 It looks like the ORACLE_HOME path is not know by apache/PHP.  So, you 
 might try stopping apache, and doing something like 'source 
 /etc/profile' or wherever your ORACLE_HOME env variable is set, and then 

 restarting apache and trying again...
 HTH
 -B

Mhmmm I set this variables in the Apache - but it don't work :(

SetEnv ORACLE_HOME /xxx
SetEnv TNS_ADMIN /xxx
SetEnv LD_LIBRARY_PATH /xxx
SetEnv ORACLE_SID orcl10g
SetEnv NLS_LANG GERMAN_GERMANY.WE8ISO8859P1

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





Re: [PHP-DB] csv problem.. read csv from var

2007-02-16 Thread Niel Archer
Hi

sorry, I misunderstood your problem, it was not too clear to me as the
code you list shouldn't produce the output you supplied.

try this:

$array = explode(',', $csv);

print br=  . $array[0] . \n;
print br=  . $array[1] . \n;

for ($i = 2; $i  count($array); ++$i) {
 $txt.= br /= . $array[$i] . \n;
}

print $txt;


Niel

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



[PHP-DB] mysql_real_escape_string

2007-02-16 Thread Ron Piggott
I am creating a form where I am using 

$web_site_#

for the various fields.  At the present time there are 11 fields I am
asking the user to key in.  I am wondering if there is a slick way to
use the mysql_real_escape_string command with this so

$web_site_1 = mysql_real_escape_string($web_site_1);
$web_site_2 = mysql_real_escape_string($web_site_2);
$web_site_3 = mysql_real_escape_string($web_site_3);
...
$web_site_11 = mysql_real_escape_string($web_site_11);

would be replaced by some type of loop

Suggestions?  

Ron



Re: [PHP-DB] csv problem.. read csv from var

2007-02-16 Thread Martin Alterisio

2007/2/16, bedul [EMAIL PROTECTED]:


i have problem with reading csv.. for i know the example script i get was
BASIC SCRIPT=
$handle = fopen(hasillab.csv, r);
$data2=$handle;
while($data = fgetcsv($handle, 1000, ,)){
foreach($data as $str)
  $data2.=br=  .$str;

}

the result was:
==OUTPUT==
= A507257
= 3/2/2007
= Hematologi Lengkap,Cholesterol Total,LDL Cholesterol,Trigliserida,HDL
Cholesterol

hasillab.csv contain
A507257,3/2/2007,Hematologi Lengkap,Cholesterol Total,LDL
Cholesterol,Trigliserida,HDL Cholesterol,Asam Urat,Gula Darah Puasa,Gula
Darah 2 Jam PP,Kreatinin,Ureum,Bilirubin Total,Alkali
Fosfatase,SGOT,SGPT,Urine Lengkap,Feses Rutin,Darah Samar Faeces,VDRL,Anti
-
HBs,Total PSA,HBsAg,Anti - HCV Total

the problem i have is.. how about the csv is a var
DATA===
$csv=
A507257,3/2/2007,\Hematologi Lengkap,Cholesterol Total,LDL
Cholesterol,Trigliserida,HDL Cholesterol,Asam Urat,Gula Darah Puasa,Gula
Darah 2 Jam PP,Kreatinin,Ureum,Bilirubin Total,Alkali
Fosfatase,SGOT,SGPT,Urine Lengkap,Feses Rutin,Darah Samar Faeces,VDRL,Anti
-
HBs,Total PSA,HBsAg,Anti - HCV Total\;

what should i do to make the ouput like above.

until now.. i try save the var into files then i use basic script to load
it

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



You can parse the csv yourself. So, lets cast some regexp magic into the
emptyness of this mailing thread:

   preg_match_all('/(?=^|,)((.|\n)*(?!)|.*)(,|$)/Um', $csv, $matches,
PREG_SET_ORDER);
   $rows = array();
   $fields = array();
   foreach ($matches as $match) {
   $field = $match[1];
   if ($field != ''  $field != ''  $field[0] == '' 
substr($field, -1) == '') {
   $field = substr($field, 1, -1);
   $field = str_replace('', '', $field);
   }
   $fields[] = $field;
   if ($match[3] == '') {
   $rows[] = $fields;
   $fields = array();
   }
   }

$rows variable will be filled with an array for each row in a CSV format
complaint string, using line breaks as row separators and commas as field
separators.

If you wonder about the mystic forces that powers this regexp, I'll be more
than willing to explain them throughly, if time becomes available. If it
doesn't work (I tested it againts all the use cases I could think of, but...
murphy's law applies) go blame someone else... =P



Also, if you're working on PHP5, you may bring up the new, mostly unused,
spells in your PHP spell book, available to all those who have reached level
5 in PHP wizardry. Just copy  paste (that skill you have probably adquired
in your early days as an apprentice) the code from the PHP manual included
as an example of custom stream wrappers:

http://www.php.net/stream_wrapper_register

With the VariableStream class registered as a stream wrapper, you can
magically use global variables as a streams. Therefore something like this
will work:

$csv=...etc...;
$handle = fopen(var://csv, r);
... etc ...