Re: [PHP-DB] Re: while...if statements???

2001-12-19 Thread Chris Lee

personal pref. Once I knew php and mysql better I wrote my own wrappers, I found using 
them easier. But there is no reason why someone couldnt do fine without one. writing a 
set of wrappers allowed me to better optimize my queries and write code faster without 
having to worry about everything else.

have you tried the PEAR db wrappers? PEAR came out after I wrote mine, therfore I 
never used them, you?

  Chris Lee
  [EMAIL PROTECTED]



- Original Message - 
From: "matt stewart" <[EMAIL PROTECTED]>
To: "'Chris Lee'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; 
<[EMAIL PROTECTED]>
Sent: Wednesday, December 19, 2001 1:16 AM
Subject: RE: [PHP-DB] Re: while...if statements???


> and i always thought the best tactic was to go ugly early.
> 
> seriously, this isn't really that ugly a solution, most textbooks tend to
> tell you to use this method to start with as its a bit simpler to understand
> for beginners - an if...else statement to see if an initial row is returned,
> then you can happily use a do...while on that first row, and it'll carry on
> outputting the following rows if there are any more.
> 
> -Original Message-
> From: Chris Lee [mailto:[EMAIL PROTECTED]]
> Sent: 18 December 2001 20:49
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: [PHP-DB] Re: while...if statements???
> 
> 
> because the while() statement works like this
> 
> - do something while x is true. if x is not true dont do anything.
> - do something while conent is in the db. if there is no conent in the db
> dont do anything.
> 
> your if() statement is never run if there is no content.
> 
> $return = mysql_fetch_row($result);
> if ( isset($return['pet_name']) )
> do
> {
> echo $return['pet_name'] ."";
> } while( $return = mysql_fetch_row($result) );
> else
> echo " No Pets ";
> 
> its ugly but it works. I dont like ugly, so I wrote my own db wrappers.
> 
> http://www.mediawaveonline.com/examples/
> 
> foreach( $db->select_array('', 'petinfo', '') as $pos => $val )
> echo $val['pet_name'] ."";
> if ( !isset($val['pet_name']) )
> echo " No Pets ";
> 
> I like that more. but whatever.
> 
> --
> 
>   Chris Lee
>   [EMAIL PROTECTED]
> 
> 
> 
> "Jay Fitzgerald" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Does anyone know why this isn't working?? What I am trying to do is
> display
> > photos from a database based on each month. This part works fine when I
> set
> > it to the current month of December (today) as that is when I uploaded the
> > photos.
> >
> > However, when I manually set the date to a month that has no photos in it,
> > I want it to echo the No Animals string belowThis is only working
> > half-way...meaning that it will display a blank page with nothing on it
> > instead of actually echoing the No Animals string
> >
> > Can anyone please help?? Is there really a way to have a "while...if"
> > statement
> >
> >
> >
> > =
> >  > $connection = mysql_connect($hostname, $user, $pass) or die ("Unable to
> > connect!");
> > $query = "SELECT petname, petDesc, petpicture FROM petinfo WHERE petmonth
> =
> > 'Apr'";
> > $result = mysql_db_query($database, $query, $connection) or die ("Error in
> > query: $query. " . mysql_error());
> >
> > while (list($pet_name, $pet_Desc, $pet_picture) =
> mysql_fetch_row($result))
> > {
> > if ($pet_picture == "")
> > {
> > echo "No Animals have been posted for $date at this moment. Please check
> > back soon.";
> > exit;
> > }
> >
> > else
> > {
> > echo "
> > Pet of the month
> >
> > 
> >  >
> SRC=\"http://moss.bayou.com:/oppj/admin/animalcontrol/photos/$pet_pictur
> e\"
> > HEIGHT=150>
> >
> > 
> > $pet_Desc
> >
> > 
> > To adopt $pet_name please visit the Ouachita Parish Animal Shelter.
> > The adoption fee is \$50.00 which includes Spade, Neutering and 7-N-1
> > Shot.
> >
> > 
> > Sorry, we can not hold $pet_name for you (First come first serve
> > basis).
> > ";
> > }
> > }
> > ?>
> > =
> >
> > Thanks,
> >
> >
> > Confus3d
> >
> >
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.307 / Virus Database: 168 - Release Date: 11/12/01
>  
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.307 / Virus Database: 168 - Release Date: 11/12/01
>  
> 


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re: while...if statements???

2001-12-18 Thread Chris Lee

because the while() statement works like this

- do something while x is true. if x is not true dont do anything.
- do something while conent is in the db. if there is no conent in the db
dont do anything.

your if() statement is never run if there is no content.

$return = mysql_fetch_row($result);
if ( isset($return['pet_name']) )
do
{
echo $return['pet_name'] ."";
} while( $return = mysql_fetch_row($result) );
else
echo " No Pets ";

its ugly but it works. I dont like ugly, so I wrote my own db wrappers.

http://www.mediawaveonline.com/examples/

foreach( $db->select_array('', 'petinfo', '') as $pos => $val )
echo $val['pet_name'] ."";
if ( !isset($val['pet_name']) )
echo " No Pets ";

I like that more. but whatever.

--

  Chris Lee
  [EMAIL PROTECTED]



"Jay Fitzgerald" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Does anyone know why this isn't working?? What I am trying to do is
display
> photos from a database based on each month. This part works fine when I
set
> it to the current month of December (today) as that is when I uploaded the
> photos.
>
> However, when I manually set the date to a month that has no photos in it,
> I want it to echo the No Animals string belowThis is only working
> half-way...meaning that it will display a blank page with nothing on it
> instead of actually echoing the No Animals string
>
> Can anyone please help?? Is there really a way to have a "while...if"
> statement
>
>
>
> =
>  $connection = mysql_connect($hostname, $user, $pass) or die ("Unable to
> connect!");
> $query = "SELECT petname, petDesc, petpicture FROM petinfo WHERE petmonth
=
> 'Apr'";
> $result = mysql_db_query($database, $query, $connection) or die ("Error in
> query: $query. " . mysql_error());
>
> while (list($pet_name, $pet_Desc, $pet_picture) =
mysql_fetch_row($result))
> {
> if ($pet_picture == "")
> {
> echo "No Animals have been posted for $date at this moment. Please check
> back soon.";
> exit;
> }
>
> else
> {
> echo "
> Pet of the month
>
> 
> 
SRC=\"http://moss.bayou.com:/oppj/admin/animalcontrol/photos/$pet_pictur
e\"
> HEIGHT=150>
>
> 
> $pet_Desc
>
> 
> To adopt $pet_name please visit the Ouachita Parish Animal Shelter.
> The adoption fee is \$50.00 which includes Spade, Neutering and 7-N-1
> Shot.
>
> 
> Sorry, we can not hold $pet_name for you (First come first serve
> basis).
> ";
> }
> }
> ?>
> =
>
> Thanks,
>
>
> Confus3d
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re: Using A Query Results Multiple Times

2001-11-01 Thread Chris Lee

just put it in a loop.

while($val = mysql_fetch_result($result))
  $array[] = $val;

foreach($count = 0; $count < count($array); $count++)
  echo $array[$count]['product_name'];
foreach($count = 0; $count < count($array); $count++)
  echo $array[$count]['product_name'];

php4 has foreach() its better, think of upgrading, there are numerous
reasons.

--

  Chris Lee
  [EMAIL PROTECTED]



"Adam Douglas" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I have an instance where I have to query my MySQL database and then
> use the multiple row results to create multiple pull down menus on a web
> page. My problem is how can I take the results of the query and use them
> more the once to create pull down menus? I've always used a while look to
> fetch each row of the results and have it create the pull down menu as it
> goes through each row. But doing it this way only stores one row of
results
> in a variable. Is there a way I can grab all the results from a query that
> would go into an array so I could use it multiple times? I've lookingere
> briefly for a function to MySQL that would allow me to do this but haven't
> found anything unless I misunderstand mysql_fetch_array function. At first
I
> thought I could loop through my while loop and have it put the results
from
> the query of each row in to a multidimensional array. But then how would I
> add to the array after the initial row?
>
> BTW, I'm using PHP 3.0.16 so I can't use the added array functions
that
> PHP 4 has. I do plan on upgrading soon.
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Warning: SQL error: , SQL state in SQLConnect in test.php on line 5

2001-05-21 Thread Chris Lee

Dear All,

Language:  PHP v4.05
OS:RedHat Linux 7.1
WebServer: Apache 1.3.20 w/mod_php
DB2:   db2connect-7.1
DB Server: IBM AS/400 DB2

Connect to db2/as400 under the console of DB2 Connect works!
However, connect to db2/as400 via PHP fail sometime with the following
error, what's the problems?

Warning: SQL error: , SQL state in SQLConnect in test.php on line 5


- test.php 
";
  // Build Column Headers
  for ($i=1; $i <= $Fields; $i++){
  printf("%s", odbc_field_name( $cur,$i));
  }
  // Table Body
  $Outer=0;
   while( odbc_fetch_row( $cur )){
   $Outer++;
   print "";
   for($i=1; $i <= $Fields; $i++){
   printf("%s", odbc_result( $cur, $i ));
   }
   print "";
   }
   print "";
   print " Your request returned $Outer rows!";
   // odbc_close( $cnx);
?>




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Connection to AS/400.

2001-05-07 Thread Chris Lee

Dear Nicaolas,

Take a look at:

http://www.faqts.com/knowledge_base/view.phtml/aid/5613/fid/12
http://www.faqts.com/knowledge_base/view.phtml/aid/3536/fid/10
http://www.faqts.com/knowledge_base/view.phtml/aid/257/fid/14

http://www.phpbuilder.com/forum/read.php3?num=1&id=100815&loc=0&thread=100815

DB2 Version 7.1 for Linux HOWTO
http://www.linuxdoc.org/HOWTO/DB2-HOWTO/

Hope this help.

Regards,
Chris Lee


On 7 May 2001 12:32:50 -0700, [EMAIL PROTECTED] ("Nicolas
Machado") wrote:

>OK, I have Linux, Apache and PHP, somebody knows if exist something like
>ODBC to connect to DB2/400.
>I mean, exist ODBC for linux?
>
>Thank for all.
>Best Regards
>
>
>---
>Este Mail NO contiene Virus.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.251 / Virus Database: 124 - Release Date: 26/04/01


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] PHP and Access to DB2.

2001-05-03 Thread Chris Lee

Nicolas,

Take a look of the following link:
Hope this help.

AS/400
Connection from a Linux Box to AS/400 DB2
Connection from a Linux Box to IBM DB2 Mainframes
http://www.faqts.com/knowledge_base/view.phtml/aid/5613/fid/12

Can I use PHP to interface with an AS/400 database?
http://www.faqts.com/knowledge_base/view.phtml/aid/257/fid/14

Can you connect to an AS/400 DB2 database from a Linux web server? 
http://www.faqts.com/knowledge_base/view.phtml/aid/3536/fid/10

Regards,
Chris Lee


On 30 Apr 2001 08:40:42 -0700, [EMAIL PROTECTED] ("Nicolas
Machado") wrote:

>Hy, somebody knows if exist a driver for database access to DB2/400, running
>on AS/400.
>Something like a module.
>
>Thanks.
>
>
>---
>Este Mail NO contiene Virus.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.250 / Virus Database: 123 - Release Date: 18/04/01


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]