RE: [PHP-DB] Session variables and arrays

2002-10-30 Thread Peter Beckman
After a little more research I found out strlen will return 5 for a real
array too, so throw that out.  However, since gettype prints a string not
an array, I just don't know.  print_r prints the array, but you can iterate
through it.

Do you do this before your loop?

reset($_SESSION['categories']);

print_r($var) will set the pointer to the end of the array, so you have to
reset it to the beginning before you iterate through it again.

Maybe this is the problem?

Peter

On Wed, 30 Oct 2002, Ryan Neudorf wrote:

> Here are the results:
>
> is_array():
> gettype():string
> strlen():5
>
> > -Original Message-
> > From: Peter Beckman [mailto:beckman@;purplecow.com]
> > Sent: Wednesday, October 30, 2002 8:57 AM
> > To: Ryan Neudorf
> > Cc: [EMAIL PROTECTED]
> > Subject: RE: [PHP-DB] Session variables and arrays
> >
> >
> > On Wed, 30 Oct 2002, Ryan Neudorf wrote:
> >
> > > Ok. The categories are coming from checkboxes, e.g.:
> > >  > />Accountant > > />
> > >
> > > Which then are handled by a $cgi class dealy and handed to the
> > > $_SESSION['categories'] variable before being forwarded to the next
> > > step. I was thinking that the problem might be with the
> > $cgi object,
> > > but when I print_r($_SESSION['categories']) it shows the
> > contents of
> > > the array.
> > >
> > > Anyways, I did the print ":::{$_SESSION['categories']}:::"; and got
> > > :::Array:::
> >
> >  Try this after that print:
> >
> >  print is_array($_SESSION['categories']);
> >
> >  You should get a 1 -- if you don't, try this:
> >
> >  print gettype($_SESSION['categories']);
> >
> >  You should get "array" but if you don't, there is something
> > strange going  on!  If you get "string" though, do this:
> >
> >  print strlen($_SESSION['categories']);
> >
> >  If you get "5", then the variable might be a string with the
> > contents  being the word "Array".  Pretty doubtful, but we're
> > being thorough here.
> >
> > Peter
> >
> > > Hmph
> > >
> > > - Ryan
> > >
> > > > -Original Message-
> > > > From: Peter Beckman [mailto:beckman@;purplecow.com]
> > > > Sent: Tuesday, October 29, 2002 9:59 PM
> > > > To: Ryan Neudorf
> > > > Cc: [EMAIL PROTECTED]
> > > > Subject: Re: [PHP-DB] Session variables and arrays
> > > >
> > > >
> > > > Well, can't say I see the same problem:
> > > >
> > > >  > > > $_SESSION['foo'] = array("hi"=>"bye");
> > > >
> > > > print_r($_SESSION['foo']);
> > > > echo "\n\n";
> > > > print is_array($_SESSION['foo']);
> > > >
> > > > Outputs:
> > > > X-Powered-By: PHP/4.2.2
> > > > Content-type: text/html
> > > >
> > > > Array
> > > > (
> > > > [hi] => bye
> > > > )
> > > > 1
> > > >
> > > > Which is what I'd expect it to show.
> > > >
> > > > Now how did you assign categories?
> > > >
> > > > Maybe the var is a scalar and is actually "Array (\n  [0]
> > => '1';\n
> > > > [1] => '12';" and you are confused.o
> > > >
> > > > If you are saying:
> > > >
> > > > $_SESSION['categories'] = "Array (
> > > > [0] = '1';
> > > > ";
> > > >
> > > > Then it IS a scalar.  Try this:
> > > >
> > > > print ":::{$_SESSION['categories']}:::";
> > > >
> > > > If you get this:
> > > >
> > > > :::Array:::
> > > >
> > > > Then I have no clue what the problem is
> > > >
> > > > If you don't get that, then we know what your problem is.
> > > >
> > > > Peter
> > > >
> > > > On Tue, 29 Oct 2002, Ryan Neudorf wrote:
> > > >
> > > > > I'm having a problem with session variables and arrays. I'm
> > > > > building a multi step sign up form and I need to store all the
> > > > > variable until the final step, when they are inputed to a
> > > > database. I
> > > > > thought the best way to do this would be to store the
> > contents for
> > > > > $HTTP_POST_VARS in session variables. This works fine for
> > > > everything
> > > > > except for my array of checkboxes.
> > > > >
> > > > > When I do a print_r($_SESSION) it displays the
> > following for the
> > > > > sessionvariable assigned to the checkboxes:
> > [categories] => Array (
> > > > >   [0] => '1';
> > > > >   [1] => '12';
> > > > > ... Etc ...
> > > > >
> > > > > But when I run any sort of array function (is_array,
> > foreach) on
> > > > > $_SESSION['categories'] it appears that it is a scalar, not
> > > > an array.
> > > > >
> > > > > Any ideas?
> > > > >
> > > > > - Ryan
> > > > >
> > > > >
> > > > > --
> > > > > PHP Database Mailing List (http://www.php.net/)
> > > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > > >
> > > >
> > > > --
> > > > -
> > > > Peter BeckmanSystems Engineer, Fairfax Cable
> > > > Access Corporation
> > > > [EMAIL PROTECTED]
> > > > http://www.purplecow.com/
> > > >
> > > > --
> > > > -
> > > >
> > > >
> > > > --
> > > > PHP Database Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > >
> > >
> > >
> > > --
> > >

Re: [PHP-DB] global vars

2002-10-30 Thread David Smith
When you redirect, you lose your variables. This means that you must
send them in some form to the other script. If you change your redirect
command to the following, you will see that $a gets transferred and
echoed in the second script as well as the first:

Header("Location: second.php?a=$a");

Note: this only works if you have "register globals" on which you seem
to have, so it should fix your problem.

Good luck!

--Dave


On Wed, 2002-10-30 at 23:05, Tomas Kubis wrote:
> Hello,
>  I have big problem. I upgraded PHP from 4.1.2 to 4.2.3 and my scripts with
> doesn´t work. Please help me!
> in php.info register globals=On
> 
> For example I have one script:
> first.php
>  global $a;
> $a=150;
> Header("Location: second.php");
> ?>
> 
> second.php
> 
>  echo $a;
> echo $GLOBALS['a'];
> echo "END";
> ?>
> 
> Where I have a bug?
> 
> Thank you very much
> 
> Tomas Kubis
> 
> 
> 
> -- 
> 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] global vars

2002-10-30 Thread Tomas Kubis
Hello,
 I have big problem. I upgraded PHP from 4.1.2 to 4.2.3 and my scripts with
doesn´t work. Please help me!
in php.info register globals=On

For example I have one script:
first.php


second.php



Where I have a bug?

Thank you very much

Tomas Kubis



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




RE: [PHP-DB] HTML Select Boxes not displaying

2002-10-30 Thread John W. Holmes
What do you see in the HTML source of the browser's that "don't work"
and how does it not work? The select boxes just don't show up at all? Do
other form elements show up?

---John Holmes...

> -Original Message-
> From: Nigel Dunn [mailto:nigel.dunn@;strobe.net.nz]
> Sent: Wednesday, October 30, 2002 10:36 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] HTML Select Boxes not displaying
> 
> Hi Everyone,
> 
> I have encountered a problem with IE that I am unsure how to get
around.
> I dynamically create quite a few drop down boxes to enable categories
to
> be oredered. It works fine for me (XP box) however everyone else in my
> office is running ME or 98 and it doesnt work in IE for any of them.
> Works fine in Netscape and Mozilla. Both myself and my boss are
running
> IE6, same build, however he is ME and I'm XP, and he cant see them
either.
> 
> Below is the code I'm usingany help with this would be great.
> 
> Thanks in advance,
> Nigel Dunn
> 
>  // includes the db connection, etc
> include("../config/global.inc");
> 
> function display_ordered_list() {
> 
>echo "";
>echo "Category NameCategory
> Order";
>$result = mysql_query("SELECT * FROM category WHERE parent_id = '0'
> ORDER BY list_id, name");
>$num_rows = mysql_num_rows($result);
>if ($row = mysql_fetch_array($result)) {
>  do {
>$cat_id = $row['id'];
>$name = $row['name'];
>$list_id = $row['list_id'];
>echo "$name name='cat[$cat_id]'>\n";
>echo select_list($list_id, $num_rows);
>echo "\n\n";
> 
>$result2 = mysql_query("SELECT * FROM category WHERE parent_id
=
> '$cat_id' ORDER BY list_id, name");
>$num_rows2 = mysql_num_rows($result2);
>if ($num_rows2 != 0) {
>  // echo "";
>  echo " \n\n";
>  echo " cellspacing='0'>\n";
>  echo "Sub-Category Name align='right'>Sub Category Order\n";
>  if ($row2 = mysql_fetch_array($result2)) {
>do {
>  $sub_id = $row2['id'];
>  $sub_name = $row2['name'];
>  $sub_list_id = $row2['list_id'];
>  echo "$sub_name name='cat[$sub_id]'>\n";
>  echo select_list($sub_list_id, $num_rows2);
>  echo "\n";
>} while ($row2 = mysql_fetch_array($result2));
>  }
>  echo "\n\n";
>  echo "\n";
>  echo "\n";
>}
>  } while ($row = mysql_fetch_array($result));
>}
>echo "\n";
>echo "  value='Submit'>\n";
>echo "\n";
> }
> 
> function select_list($id, $total) {
> 
>for ($x = 1; $x <= $total; $x++) {
>  if ($x == $id) {
>$option_list .= "$x\n";
>  } else {
>$option_list .= "$x\n";
>  }
>}
>return $option_list;
> }
> 
> ?>
> 
> 
> Order Categories Test
> 
> 
> 
> 
> 
> 
>  if ($Submit == "Submit") {
> 
>$the_end = false;
>$s = reset($cat);
>$k = key($cat);
>$c = count($cat);
> 
>while(!$the_end) {
>  for($i = 0; $i < $c; $i++) {
>$result = mysql_query("UPDATE category SET list_id = '" .
> $cat[$k] . "' WHERE id = '$k'");
>$s = next($cat);
>if ($s==false) {
>  $the_end=true;
>} else {
>  $k = key($cat);
>}
>  }
>}
> }
> 
> display_ordered_list();
> 
> ?>
>
> 
> 
> 
> 
> --
> 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] HTML Select Boxes not displaying

2002-10-30 Thread Nigel Dunn
Hi Everyone,

I have encountered a problem with IE that I am unsure how to get around.
I dynamically create quite a few drop down boxes to enable categories to 
be oredered. It works fine for me (XP box) however everyone else in my 
office is running ME or 98 and it doesnt work in IE for any of them. 
Works fine in Netscape and Mozilla. Both myself and my boss are running 
IE6, same build, however he is ME and I'm XP, and he cant see them either.

Below is the code I'm usingany help with this would be great.

Thanks in advance,
Nigel Dunn


// includes the db connection, etc
include("../config/global.inc");

function display_ordered_list() {
	
  echo "";
  echo "Category NameCategory 
Order";
  $result = mysql_query("SELECT * FROM category WHERE parent_id = '0' 
ORDER BY list_id, name");
  $num_rows = mysql_num_rows($result);
  if ($row = mysql_fetch_array($result)) {
do {
  $cat_id = $row['id'];
  $name = $row['name'];
  $list_id = $row['list_id'];
  echo "$name\n";
  echo select_list($list_id, $num_rows);
  echo "\n\n";			
	
  $result2 = mysql_query("SELECT * FROM category WHERE parent_id = 
'$cat_id' ORDER BY list_id, name");
  $num_rows2 = mysql_num_rows($result2);
  if ($num_rows2 != 0) {
// echo "";
echo " \n\n";
echo "\n";
echo "Sub-Category NameSub Category Order\n";
if ($row2 = mysql_fetch_array($result2)) {
  do {
$sub_id = $row2['id'];
$sub_name = $row2['name'];
$sub_list_id = $row2['list_id'];
echo "$sub_name\n";
echo select_list($sub_list_id, $num_rows2);
echo "\n";
  } while ($row2 = mysql_fetch_array($result2));
}
echo "\n\n";
echo "\n";
echo "\n";
  }
} while ($row = mysql_fetch_array($result));
  }
  echo "\n";
  echo " \n";
  echo "\n";
}

function select_list($id, $total) {

  for ($x = 1; $x <= $total; $x++) {
if ($x == $id) {
  $option_list .= "$x\n";
} else {
  $option_list .= "$x\n";
}
  }
  return $option_list;
}

?>


Order Categories Test





		

if ($Submit == "Submit") {

  $the_end = false;
  $s = reset($cat);
  $k = key($cat);
  $c = count($cat);
	
  while(!$the_end) {
for($i = 0; $i < $c; $i++) {
  $result = mysql_query("UPDATE category SET list_id = '" . 
$cat[$k] . "' WHERE id = '$k'");
  $s = next($cat);
  if ($s==false) {
$the_end=true;
  } else {
$k = key($cat);
  }
}
  }
}

display_ordered_list();

?>
  




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



RE: [PHP-DB] Multiple table select, but still returning row if no record exists in second table?

2002-10-30 Thread John W. Holmes
LEFT JOIN

> -Original Message-
> From: Leif K-Brooks [mailto:eurleif@;buyer-brokerage.com]
> Sent: Wednesday, October 30, 2002 9:49 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Multiple table select, but still returning row if no
> record exists in second table?
> 
> I'm using mysql.  Is there any way to do a multiple-table select, but
> still return the results from table 1 if there are no matching rows in
> table 2?  Something like "select table1.something,table2.something as
> something2 from table1,table2 where table1.table2id = table2.id" will
> only return the data from table1 if a row with the id in
table1.table2id
> exists in table2.
> 
> --
> The above message is encrypted with double rot13 encoding.  Any
> unauthorized attempt to decrypt it will be prosecuted to the full
extent
> of the law.
> 
> 
> 
> --
> 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] Multiple table select, but still returning row if no record existsin second table?

2002-10-30 Thread Leif K-Brooks
I'm using mysql.  Is there any way to do a multiple-table select, but 
still return the results from table 1 if there are no matching rows in 
table 2?  Something like "select table1.something,table2.something as 
something2 from table1,table2 where table1.table2id = table2.id" will 
only return the data from table1 if a row with the id in table1.table2id 
exists in table2.

--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.



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



RE: [PHP-DB] Newbie-Question: What's that @?

2002-10-30 Thread Marcus Fleige
great!

@ryan & josh: thank you for the quick answers! :-)

marcus


--
^v^
[EMAIL PROTECTED]



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




RE: [PHP-DB] Session variables and arrays

2002-10-30 Thread Ryan Neudorf
Here are the results:

is_array():
gettype():string
strlen():5

> -Original Message-
> From: Peter Beckman [mailto:beckman@;purplecow.com] 
> Sent: Wednesday, October 30, 2002 8:57 AM
> To: Ryan Neudorf
> Cc: [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] Session variables and arrays
> 
> 
> On Wed, 30 Oct 2002, Ryan Neudorf wrote:
> 
> > Ok. The categories are coming from checkboxes, e.g.:
> >  />Accountant > />
> >
> > Which then are handled by a $cgi class dealy and handed to the 
> > $_SESSION['categories'] variable before being forwarded to the next 
> > step. I was thinking that the problem might be with the 
> $cgi object, 
> > but when I print_r($_SESSION['categories']) it shows the 
> contents of 
> > the array.
> >
> > Anyways, I did the print ":::{$_SESSION['categories']}:::"; and got
> > :::Array:::
> 
>  Try this after that print:
> 
>  print is_array($_SESSION['categories']);
> 
>  You should get a 1 -- if you don't, try this:
> 
>  print gettype($_SESSION['categories']);
> 
>  You should get "array" but if you don't, there is something 
> strange going  on!  If you get "string" though, do this:
> 
>  print strlen($_SESSION['categories']);
> 
>  If you get "5", then the variable might be a string with the 
> contents  being the word "Array".  Pretty doubtful, but we're 
> being thorough here.
> 
> Peter
> 
> > Hmph
> >
> > - Ryan
> >
> > > -Original Message-
> > > From: Peter Beckman [mailto:beckman@;purplecow.com]
> > > Sent: Tuesday, October 29, 2002 9:59 PM
> > > To: Ryan Neudorf
> > > Cc: [EMAIL PROTECTED]
> > > Subject: Re: [PHP-DB] Session variables and arrays
> > >
> > >
> > > Well, can't say I see the same problem:
> > >
> > >  > > $_SESSION['foo'] = array("hi"=>"bye");
> > >
> > > print_r($_SESSION['foo']);
> > > echo "\n\n";
> > > print is_array($_SESSION['foo']);
> > >
> > > Outputs:
> > > X-Powered-By: PHP/4.2.2
> > > Content-type: text/html
> > >
> > > Array
> > > (
> > > [hi] => bye
> > > )
> > > 1
> > >
> > > Which is what I'd expect it to show.
> > >
> > > Now how did you assign categories?
> > >
> > > Maybe the var is a scalar and is actually "Array (\n  [0] 
> => '1';\n  
> > > [1] => '12';" and you are confused.o
> > >
> > > If you are saying:
> > >
> > > $_SESSION['categories'] = "Array (
> > > [0] = '1';
> > > ";
> > >
> > > Then it IS a scalar.  Try this:
> > >
> > > print ":::{$_SESSION['categories']}:::";
> > >
> > > If you get this:
> > >
> > > :::Array:::
> > >
> > > Then I have no clue what the problem is
> > >
> > > If you don't get that, then we know what your problem is.
> > >
> > > Peter
> > >
> > > On Tue, 29 Oct 2002, Ryan Neudorf wrote:
> > >
> > > > I'm having a problem with session variables and arrays. I'm 
> > > > building a multi step sign up form and I need to store all the 
> > > > variable until the final step, when they are inputed to a
> > > database. I
> > > > thought the best way to do this would be to store the 
> contents for 
> > > > $HTTP_POST_VARS in session variables. This works fine for
> > > everything
> > > > except for my array of checkboxes.
> > > >
> > > > When I do a print_r($_SESSION) it displays the 
> following for the 
> > > > sessionvariable assigned to the checkboxes: 
> [categories] => Array (
> > > > [0] => '1';
> > > > [1] => '12';
> > > > ... Etc ...
> > > >
> > > > But when I run any sort of array function (is_array, 
> foreach) on 
> > > > $_SESSION['categories'] it appears that it is a scalar, not
> > > an array.
> > > >
> > > > Any ideas?
> > > >
> > > > - Ryan
> > > >
> > > >
> > > > --
> > > > PHP Database Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > >
> > >
> > > --
> > > -
> > > Peter BeckmanSystems Engineer, Fairfax Cable
> > > Access Corporation
> > > [EMAIL PROTECTED]
> > > http://www.purplecow.com/
> > >
> > > --
> > > -
> > >
> > >
> > > --
> > > 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
> >
> 
> --
> -
> Peter BeckmanSystems Engineer, Fairfax Cable 
> Access Corporation
> [EMAIL PROTECTED] 
> http://www.purplecow.com/
> 
> --
> -
> 


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




RE: [PHP-DB] Newbie-Question: What's that @?

2002-10-30 Thread Josh Johnson
It suppresses error messages and warnings when you call a function,
regardless of your level of error reporting. 

So yeah, it is like batch programming :)

-- Josh

-Original Message-
From: Marcus Fleige [mailto:marcus.fleige@;gmx.de] 
Sent: Wednesday, October 30, 2002 7:05 PM
To: PHP-Mailinglist
Subject: [PHP-DB] Newbie-Question: What's that @?

hi there,

i've got a general question about php-scripts:

whats the difference between

@mysql_query($query)

and

@mysql_query($query)?

is it the same as in batch programming?
like, ignore all return messages?

thanks and greetings from germany,

marcus

--
^v^
[EMAIL PROTECTED]



-- 
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




RE: [PHP-DB] Newbie-Question: What's that @?

2002-10-30 Thread Ryan Jameson (USA)
Well the only difference I see is the ? ... hehe... but if you are refering to the @ 
symbol then you are correct ... ignore errors... :-)

<>< Ryan

-Original Message-
From: Marcus Fleige [mailto:marcus.fleige@;gmx.de]
Sent: Wednesday, October 30, 2002 5:05 PM
To: PHP-Mailinglist
Subject: [PHP-DB] Newbie-Question: What's that @?


hi there,

i've got a general question about php-scripts:

whats the difference between

@mysql_query($query)

and

@mysql_query($query)?

is it the same as in batch programming?
like, ignore all return messages?

thanks and greetings from germany,

marcus

--
^v^
[EMAIL PROTECTED]



-- 
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] Newbie-Question: What's that @?

2002-10-30 Thread Marcus Fleige
hi there,

i've got a general question about php-scripts:

whats the difference between

@mysql_query($query)

and

@mysql_query($query)?

is it the same as in batch programming?
like, ignore all return messages?

thanks and greetings from germany,

marcus

--
^v^
[EMAIL PROTECTED]



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




Re: [PHP-DB] Problems with ODBC connectivity

2002-10-30 Thread Andrew Hill
Bill,

1. Are you getting an error message in your PHP?
2. Can you successfully test the DSN in the ODBC Administrator?
3. Is the ODBC entry uncommented in the php.ini for your new install?

Best regards,
Andrew Hill
Director of Technology Evangelism - OpenLink Software
Universal Data Access and the Virtuoso Universal Server
http://www.openlinksw.com/virtuoso/whatis.htm


On Tuesday, October 29, 2002, at 04:31 PM, Bill Hudspeth wrote:


I have developed a PHP application that accesses a Microsoft Access 
database
through ODBC. The application works well using PHP version 4.1. I have
recently installed the newest version of PHP (4.2.3) on another machine
running NT4, and IIS 4.
Again, I am using an ODBC connection, and have given this connection 
the
same name, login, and password as is present in my PHP files. While 
the PHP
module is running fine, I cannot retrieve records from the database,
probably indicating a problem with my connectivity to the ODBC. Again, 
I
have made the same settings in the new ODBC entry as is present on the
development machine. Could there be a version problem with the PHP 
module?
Any other suggestions would be greatly appreciated.

Thanks, Bill



--
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] Resolved: Inserting current date(MySQL)?

2002-10-30 Thread David Jackson
John, Jeffery, Alex and Jason --
Thanks for you response.
As you all suggested it was as simple as CURDATE(). without any quotes 
or backticks.


Thanks again,
David


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



[PHP-DB] Re: Inserting current date(MySQL)?

2002-10-30 Thread Alex Francis
I'm no expert, but here's what I did in the same situation.

$enterdate = date('Ymd'); --- this gives me the current date.
then when entering the information from the form into my database I just
entered the variable into a field called evdt

When using the date I wanted it in a more user friendly state (also UK
format) I did this:
$query = ' SELECT  DATE_FORMAT(eventdate, "%D %M %Y")as evdt FROM notices';
This gives me it in the format "1st December 2002".

"David Jackson" <[EMAIL PROTECTED]> wrote in message
news:3DC0256F.3000306@;mustardandrelish.com...
> Howdy --
> I'm my trying to insert to current date from a php form? I know that
> MySQL has a CURDATE() fucntion and PHP has several date function, but I
> cann't seem to get either to work? Here is my existing code:
>
> TIA,
> David Jackson
>
>
> -- client_add.php 
>
> 
> 
>
> 
>  $ADDDATE=date("Y-m-d");
> mysql_query ("INSERT INTO client (cl_add_date,
> cl_first_name,
> cl_last_name,
> cl_company,
> cl_phone,
> cl_email,
> cl_address,
> cl_city,
> cl_state,
> cl_zip,
> cl_web)
>
>  VALUES ('$_POST[ADDDATE]',
> '$_POST[cl_first_name]',
> '$_POST[cl_last_name]',
> '$_POST[cl_company]',
> '$_POST[cl_phone]',
> '$_POST[cl_email]',
> '$_POST[cl_address]',
> '$_POST[cl_city]',
> '$_POST[cl_state]',
> '$_POST[cl_zip]',
> '$_POST[cl_web]') ");
> ?>
>
> 
> 
>



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




Re: [PHP-DB] Inserting current date(MySQL)?

2002-10-30 Thread 1LT John W. Holmes
> I'm my trying to insert to current date from a php form? I know that
> MySQL has a CURDATE() fucntion and PHP has several date function, but I
> cann't seem to get either to work? Here is my existing code:

> $ADDDATE=date("Y-m-d");
[snip]
>  VALUES ('$_POST[ADDDATE]',

You've got two different variables there. You should just use $ADDDATE in
your query.

Or, like you said, just use CURDATE() or NOW() in your query.

VALUES (NOW(), ...

VALUES (CURDATE(), ...

---John Holmes...


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




Re: [PHP-DB] Inserting current date(MySQL)?

2002-10-30 Thread Jeffrey_N_Dyke

it looks like you have defined $ADDDATE and it is not a posted variable.
what happens if you just have:





Jeff


   

David Jackson  

  cc:

Subject: [PHP-DB] Inserting current 
date(MySQL)?   
10/30/2002 01:31   

PM 

   

   





Howdy --
I'm my trying to insert to current date from a php form? I know that
MySQL has a CURDATE() fucntion and PHP has several date function, but I
cann't seem to get either to work? Here is my existing code:

TIA,
David Jackson


-- client_add.php 











--
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] Inserting current date(MySQL)?

2002-10-30 Thread David Jackson
Howdy --
I'm my trying to insert to current date from a php form? I know that 
MySQL has a CURDATE() fucntion and PHP has several date function, but I 
cann't seem to get either to work? Here is my existing code:

TIA,
David Jackson


-- client_add.php 






$ADDDATE=date("Y-m-d");
mysql_query ("INSERT INTO client (cl_add_date,
cl_first_name,
cl_last_name,
cl_company,
cl_phone,
cl_email,
cl_address,
cl_city,
cl_state,
cl_zip,
cl_web)

	VALUES ('$_POST[ADDDATE]',
		'$_POST[cl_first_name]',
		'$_POST[cl_last_name]',
		'$_POST[cl_company]',
		'$_POST[cl_phone]',
		'$_POST[cl_email]',
		'$_POST[cl_address]',
		'$_POST[cl_city]',
		'$_POST[cl_state]',
		'$_POST[cl_zip]',
		'$_POST[cl_web]') ");
?>





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



[PHP-DB] posted my problem online

2002-10-30 Thread Seabird
Hi everyone,

I keep bumping into my problem with my session variables. Maybe a online
example helps.

I created a account:

http://seabird.jmtech.ca

username=forum
password=forum

I placed a array under my navigation on the left and one inside my welcome
page (that onloads.) As you can see, it has session variables inside the
index.php, but not inside my welcome (or any other page for that matter.)

If more info is needed just let me know.

Peter, I tried what you said, but it still didn't work for me. I don't know
why this one just won't. (I had it working for a second yesterday) but it
stopped (thus the first post).
--
http://seabird.jmtech.ca

Attitude is Everything!
But Remember, Attitudes are Contagious!
Is Yours worth Catching



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




RE: [PHP-DB] Session variables and arrays

2002-10-30 Thread Peter Beckman
On Wed, 30 Oct 2002, Ryan Neudorf wrote:

> Ok. The categories are coming from checkboxes, e.g.:
> Accountant
>
> Which then are handled by a $cgi class dealy and handed to the
> $_SESSION['categories'] variable before being forwarded to the next
> step. I was thinking that the problem might be with the $cgi object, but
> when I print_r($_SESSION['categories']) it shows the contents of the
> array.
>
> Anyways, I did the print ":::{$_SESSION['categories']}:::"; and got
> :::Array:::

 Try this after that print:

 print is_array($_SESSION['categories']);

 You should get a 1 -- if you don't, try this:

 print gettype($_SESSION['categories']);

 You should get "array" but if you don't, there is something strange going
 on!  If you get "string" though, do this:

 print strlen($_SESSION['categories']);

 If you get "5", then the variable might be a string with the contents
 being the word "Array".  Pretty doubtful, but we're being thorough here.

Peter

> Hmph
>
> - Ryan
>
> > -Original Message-
> > From: Peter Beckman [mailto:beckman@;purplecow.com]
> > Sent: Tuesday, October 29, 2002 9:59 PM
> > To: Ryan Neudorf
> > Cc: [EMAIL PROTECTED]
> > Subject: Re: [PHP-DB] Session variables and arrays
> >
> >
> > Well, can't say I see the same problem:
> >
> >  > $_SESSION['foo'] = array("hi"=>"bye");
> >
> > print_r($_SESSION['foo']);
> > echo "\n\n";
> > print is_array($_SESSION['foo']);
> >
> > Outputs:
> > X-Powered-By: PHP/4.2.2
> > Content-type: text/html
> >
> > Array
> > (
> > [hi] => bye
> > )
> > 1
> >
> > Which is what I'd expect it to show.
> >
> > Now how did you assign categories?
> >
> > Maybe the var is a scalar and is actually "Array (\n  [0] =>
> > '1';\n  [1] => '12';" and you are confused.o
> >
> > If you are saying:
> >
> > $_SESSION['categories'] = "Array (
> > [0] = '1';
> > ";
> >
> > Then it IS a scalar.  Try this:
> >
> > print ":::{$_SESSION['categories']}:::";
> >
> > If you get this:
> >
> > :::Array:::
> >
> > Then I have no clue what the problem is
> >
> > If you don't get that, then we know what your problem is.
> >
> > Peter
> >
> > On Tue, 29 Oct 2002, Ryan Neudorf wrote:
> >
> > > I'm having a problem with session variables and arrays.
> > > I'm building a multi step sign up form and I need to store all the
> > > variable until the final step, when they are inputed to a
> > database. I
> > > thought the best way to do this would be to store the contents for
> > > $HTTP_POST_VARS in session variables. This works fine for
> > everything
> > > except for my array of checkboxes.
> > >
> > > When I do a print_r($_SESSION) it displays the following for the
> > > sessionvariable assigned to the checkboxes: [categories] => Array (
> > >   [0] => '1';
> > >   [1] => '12';
> > > ... Etc ...
> > >
> > > But when I run any sort of array function (is_array, foreach) on
> > > $_SESSION['categories'] it appears that it is a scalar, not
> > an array.
> > >
> > > Any ideas?
> > >
> > > - Ryan
> > >
> > >
> > > --
> > > PHP Database Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> > --
> > -
> > Peter BeckmanSystems Engineer, Fairfax Cable
> > Access Corporation
> > [EMAIL PROTECTED]
> > http://www.purplecow.com/
> >
> > --
> > -
> >
> >
> > --
> > 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
>

---
Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation
[EMAIL PROTECTED] http://www.purplecow.com/
---


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




Re[2]: [PHP-DB] Retruning an array from a row

2002-10-30 Thread Erick Wellem
Hello John,

Thanks, I've modified my code, and the solution is very simple

function get_dbfield_data(){ 

$conn=dbconn(); // mysql connection function 
$result=mysql_query("SELECT Field1,Field2 FROM table_name WHERE Condition); 
$row=mysql_fetch_array($result); 

return $row; 

} 
// End function 


//... Now the main program 

$data=get_dbfield_data(); 

echo "Data Field : ".$data[0].", ".$data[1].""; 
} 

The Output: 

Data Field : Data1, Data2 

Thanks for inspiring reply John... :)


Best regards,

Erick Wellem


Wednesday, October 30, 2002, 7:53:30 PM, you wrote:
1JWH> You're only returning the first column of each row. If you just want to
1JWH> return the first row in the result, then do this:

1JWH> $result = mysql_query(...)
1JWH> $row = mysql_fetch_row($result)
1JWH> return $row;

1JWH> ---John  Holmes...



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




RE: [PHP-DB] Decimal places.

2002-10-30 Thread Josh Johnson
This works too: print (int)(($eall - $sall) / 1000);

-- Josh

-Original Message-
From: Andrew Wilson [mailto:will@;netwaynetworks.com.au] 
Sent: Tuesday, October 29, 2002 11:18 PM
To: '[EMAIL PROTECTED]'
Subject: [PHP-DB] Decimal places.

Hay guys, 
I have two variables ( integers ) that are being minused one from the
other
and i am printing the result to the screen but i am getting unwanted
decimals.
 
print ($eall - $sall) / 1000;

My question is what is the easiest way to strip decimals off the above
result. The only way i know around it is if i piped the above statement
into
another varible and set that variable to an integer then printed that. 

I dont really want to do this as i will end up with 50 extra variables.
Thanks in advance for your comments. 

Andrew Wilson 
Technical Support 
Netway Networks 
8920-8877 

 


Netway Networks Pty Ltd 
(T) 8920 8877 
(F) 8920 8866 




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




Re: [PHP-DB] Retruning an array from a row

2002-10-30 Thread 1LT John W. Holmes

- Original Message -
From: "Erick Wellem" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 30, 2002 6:44 AM
Subject: [PHP-DB] Retruning an array from a row


> Hello All,
>
> How can I return and print an array from a user defined function from
> a database from a row like this, *just one row*, but it contains more
> than 1 columns:
> +++
> | Field1 | Field2 |
> +++
> | Data1  | Data2  |
> +++
>
> I want the output will be: Data1
>Data2
>
> I have tried this:
>
> funtion get_dbfield_data(){
>
>  $conn=dbconn(); // mysql connection function
>  $result=mysql_query("SELECT Field1,Field2 FROM table_name WHERE
Condition);
>  $fields_data=array();
>
>  while($row=mysql_fetch_row($result)){
>$fields_data[]=$row[0];

You're only returning the first column of each row. If you just want to
return the first row in the result, then do this:

$result = mysql_query(...)
$row = mysql_fetch_row($result)
return $row;

---John  Holmes...


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




RE: [PHP-DB] losing my session variables

2002-10-30 Thread Ford, Mike [LSS]
> -Original Message-
> From: Peter Beckman [mailto:beckman@;purplecow.com]
> Sent: 30 October 2002 04:09
> To: Seabird
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] losing my session variables
> 
> 
> Put "session_start()" somewhere in your code.

.. but make sure that "somewhere" is before you do any real output to your page!

> $_SESSION isn't set until you "start" your session.
> 
> And don't set session variables by $_SESSION[foo] = bar;
> 
> DO this:
> 
> $foo = bar;
> session_register("foo");
> 
> Much better.

No -- this is fraught with problems in current releases of PHP (most, if not all, of 
which will be fixed in 4.3).  Most particularly, the following caution appears at 
http://www.php.net/manual/en/ref.session.php:

  "If you are using $_SESSION and disable register_globals, do not use 
session_register(), session_is_registered() and session_unregister(), if your scripts 
shall work in PHP 4.2 and earlier."

Since the default for 4.2.x is register_globals=off, this is a very pertinent warning!

Even with register_globals=on, there are other problems which make it best to stick to 
manipulating the values in $_SESSION directly, rather than using the "equivalent" 
global variables.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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




[PHP-DB] Retruning an array from a row

2002-10-30 Thread Erick Wellem
Hello All,

How can I return and print an array from a user defined function from
a database from a row like this, *just one row*, but it contains more
than 1 columns:
+++
| Field1 | Field2 |
+++
| Data1  | Data2  |
+++

I want the output will be: Data1
   Data2

I have tried this:

funtion get_dbfield_data(){

 $conn=dbconn(); // mysql connection function
 $result=mysql_query("SELECT Field1,Field2 FROM table_name WHERE Condition);
 $fields_data=array();

 while($row=mysql_fetch_row($result)){
   $fields_data[]=$row[0];
 }

 return $fields_data;
}
// End function


//... Now the main program

$data=get_dbfield_data();
$i=0;
foreach($data as $k){
   echo "$k";
   $i++;
}

The output : Data1

:( and if I count(get_dbfield_data()) it returns 1. Can anybody help
me? Thank you for your generous help...


-- 
Best regards,
Erick Wellem



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




[PHP-DB] Re: Decimal places.

2002-10-30 Thread David Robley
In article <118DC586DF4FD311948800A0247C044D02775821@NTSVR1>, 
[EMAIL PROTECTED] says...
> Hay guys, 
> I have two variables ( integers ) that are being minused one from the other
> and i am printing the result to the screen but i am getting unwanted
> decimals.
>  
> print ($eall - $sall) / 1000;
> 
> My question is what is the easiest way to strip decimals off the above
> result. The only way i know around it is if i piped the above statement into
> another varible and set that variable to an integer then printed that. 
> 
> I dont really want to do this as i will end up with 50 extra variables.
> Thanks in advance for your comments. 

number_format() might help you :-{

Cheers
-- 
David Robley
Temporary Kiwi!

Quod subigo farinam

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




RE: [PHP-DB] Interbase BLOB problem

2002-10-30 Thread David Russell
Hi Peter,

Thanks for this. I have been waiting for the PHP Manuals to include
documentation on the interbase BLOB functions. I need to find a real
connection and download it 

Actually my problem was that I have 2 machines - Windows (development
and testing) and Linux (Server). The site was initially made in an all
Linux environment. Now I am maintaining and expanding on my Windows box.

The problem was with the fopen( "r") which on Windows needs to be
fopen(, "rb") for binary files.

It is all working now.

Thanks again to all.

David Russell
IT Support Manager
Barloworld Optimus (Pty) Ltd
Tel: +2711 444-7250 
Fax: +2711 444-7256
e-mail: [EMAIL PROTECTED]
web: www.BarloworldOptimus.com

-Original Message-
From: Peter Beckman [mailto:beckman@;purplecow.com] 
Sent: 29 October 2002 05:47 PM
To: David Russell
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Interbase BLOB problem


Your SQL query doesn't need that semicolon at the end of the query --
lose it.

I never used ibase, so here's what I found from the PHP Manual page for
ibase_query:

Using BLOB

Insert BLOB:

/* create blob */
$blob_id = ibase_blob_create();

/* fill blob */
ibase_blob_add($blob_id, $var_datablob);

/* close new blob */
$blob_id_str = ibase_blob_close($blob_id);

/* insert into table */
ibase_query("INSERT INTO BLOB_TABLE (ID, BLOB) VALUES (1,
?)",$blob_id_str);

Open BLOB:

/* query */
$set = ibase_query("SELECT BLOB FROM BLOB_TABLE WHERE ID = 1");

/* fetche a row */
$row = ibase_fetch_object($set);

/* open BLOB for read */
$blob_id = ibase_blob_open($row->BLOB);

/* get BLOB data */
$stringBLOB = ibase_blob_get($blob_id);

/* print BLOB */
echo $stringBLOB;

/* close new blob */
ibase_blob_close($blob_id);

/* free result */
ibase_free_result($set);

Peter

On Tue, 29 Oct 2002, David Russell wrote:

> Hi all,
>
> I have a file I need to insert into a blob in a interbase table. Code 
> as
> follows:
>
> $filehandle = fopen($file, "r");
> $blob_id = ibase_blob_import($filehandle);
> $qry = "INSERT INTO BPFATTACHMENTS ";
> $qry = $qry . "(BPFATTACHMENTNO, BPF, ATTACHMENTTYPE, FILENAME, 
> FILESIZE, ATTACHMENT)";
> $qry = $qry . "VALUES";
> $qry = $qry . "($bpfAttNo, $BPFNo, $AttachmentType, '$file_name', 
> $file_size, ?);";
> $res = ibase_query($qry, $blob_id);
>
> I have a ibase_pconnect prior to this.
>
> The problem is that is only adds a tiny part of the file (ie 5k of the

> 200k file) What should I be looking for?
>
> Thanks
>
> David Russell
> IT Support Manager
> Barloworld Optimus (Pty) Ltd
> Tel: +2711 444-7250
> Fax: +2711 444-7256
> e-mail: [EMAIL PROTECTED]
> web: www.BarloworldOptimus.com
>


---
Peter BeckmanSystems Engineer, Fairfax Cable Access
Corporation
[EMAIL PROTECTED]
http://www.purplecow.com/

---


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




smime.p7s
Description: application/pkcs7-signature