[PHP-DB] Re: [PHP] Regex for telephone numbers

2010-12-31 Thread Jim Lucas
On 12/29/2010 4:35 PM, Daniel P. Brown wrote:
 On Wed, Dec 29, 2010 at 19:12, Ethan Rosenberg eth...@earthlink.net wrote:
 Dear List -

 Thank you for all your help in the past.

 Here is another one

 I would like to have a regex  which would validate that a telephone number
 is in the format xxx-xxx-.
 
 Congrats.  People in Hell would like ice water.  Now we all know
 that everyone wants something.  ;-P
 
 Really, this isn't a PHP question, but rather one of regular
 expressions.  That said, something like this (untested) should work:
 
 ?php
 
 $numbers = array(
 '123-456-7890',
 '2-654-06547',
 'sf34-asdf-',
 'abc-def-ghij',
 '555_555_',
 '000-000-',
 '8007396325',
 '241-555-2091',
 '800-555-0129',
 '900-976-739',
 '5352-342=452',
 '200-200-2000',
 );
 
 foreach ($numbers as $n) {
 echo $n.(validate_phone($n) ? ' is ' : ' is not ').'a valid
 US/Canadian telephone number.'.PHP_EOL;
 }
 
 
 function validate_phone($number) {
 
 if 
 (preg_match('/^[2-9]{1,}[0-9]{2,}\-[2-9]{1,}[0-9]{2,}\-[0-9]{4,}$/',trim($number)))
 {
 return true;
 }
 
 return false;
 }
 ?
 
 

Actually...

Specified here [1] it says that the {1,} is the same as '+'.  I think you should
drop the comma.  If you don't this would be valid 844-2345-123456

^[2-9]{1,}[0-9]{2,}\-[2-9]{1,}[0-9]{2,}\-[0-9]{4,}$

should be

^[2-9]{1}[0-9]{2}\-[2-9]{1}[0-9]{2}\-[0-9]{4}$


1  http://us.php.net/manual/en/regexp.reference.repetition.php

Jim Lucas

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



[PHP-DB] Re: [PHP] goto - My comments

2010-12-21 Thread Jim Lucas

On 12/18/2010 9:17 PM, Ethan Rosenberg wrote:

Dear List -

Thanks to all for your EXCELLENT comments. I definitly agree that goto
is a command to be avoided at all costs. In this case, I could not
figure out how to acheive the desired result without the goto. So
being a newbie, I humbly request that you show [and at the same time
teach] me how to rewrite the code to eleiminate the goto.

Additionally, would you please do the same for the code I list below.
This code runs perfectly.
==
This is the form:

form action=srchrhsptl2.php method=post
centerSite: input type=text name=Site value=AA /
Record Number: input type=text name=MedRec /
First Name: input type=text name=Fname /
Last Name: input type=text name=Lname /br /br /
Phone: input type=text name=Phone /
Height: input type=decimal name=Height //inputbr /br /
Maleinput type=radio name=Sex value = 0/input
Femaleinput type=radio name=Sex value = 1/inputbr /br /br /
input type=submit /br /br /
input type=reset value = Clear Form //center
/form



Not sure if you can change the values for the Sex field to 'Male'  
'Female' respectively, but it would simplify the following example.



Here is my rendition of how I would do it.

?php

...

$query = select * from Intake3 where 1 ;

$allowed_fields = array('Site', 'MedRe', 'Fname', 'Lname',
'Phone', 'Sex', 'Height');

# deal with the special case first
# Normally you do not want to modify the _POST/_GET/_REQUEST array, but
# in this case, it is used as an quick example of how to get the data
# passed along. if you can change the field values to Male/Female you
# could remove the following section and have just the foreach() loop.
if ( ! empty($_POST['Sex']) )
{
if ( $_POST['Sex'] === '1' )
$_POST['Sex'] = 'Female';
else
$_POST['Sex'] = 'Male';
}

# Now deal with the rest...
foreach ( $allowed_fields AS $field )
{
if ( ! empty( $_POST[$field] ) )
{
$value = mysql_real_escape_string( $_POST[$field] );
$query .=  AND `{$field}` = '{$value}' ;
}
}

in the end, you will end up with a nicely formatted SQL query to execute.

I would suggest cleaning up the output code some and use *_assoc() 
instead of the *_array() function call.  It gives you back the array 
version of the output.  This way instead of calling $row[0], $row[...] 
you would call $row['Fname'] or $row['Lname'] instead.


Get rid of all those commented out sections and you will have a good 
script to play with.


Let us know what comes of it...



==
THANK YOU EVER SO MUCH FOR YOUR HELP.

Ethan





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



[PHP-DB] Re: [PHP] Sample script files with 3 different select boxes with mysql conditions in select boxes

2008-01-03 Thread Jim Lucas
Robert Cummings wrote:
 On Thu, 2008-01-03 at 09:18 -0600, Balaji A wrote:
 Hi,

 I have a table with the below fields. (id, title, language, author 
 link to the book).

 Initially I want to display a page with 3 select boxes (language,
 author  title).

 Initially first select box displays the available language by querying
 the database. On selecting one language, author select box should show
 the matching records from the database. After selecting the author,
 matching records should display in title.

 Could any body send the sample script files with 3 select boxes?
 
 Anything else you'd like to add to the requirements document?
 
 Cheers,
 Rob.

I would think it be best if it was javascript based so it dynamically loads the 
data via AJAX or a
predefined JS hash, but then when JS was disabled, it would be best if it fell 
back to old school
and submitted the form when I select the lang-auth-book.

Thanks

-- 
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



[PHP-DB] Re: [PHP] Re: the opposite of a join?

2007-10-03 Thread Jim Lucas

Colin Guthrie wrote:

Martin Marques wrote:

SELECT * FROM company WHERE id NOT IN (SELECT companyID FROM contacts);


Not ideal as has been mentioned else where in this thread.

Col


I think one would have to take into account the DB type being used here.

I can have MySQL and PostgreSQL setup and running with the same table structure (well, as close as 
you can get) configured with two different databases in them.


SQL #1  SELECT  *
FROMcompany
WHERE   id
NOT IN  (
SELECT  companyID
FROMcontacts
);

SQL #2  SELECT  company.*
FROMcompany
LEFT JOIN contacts
ON  (
company.companyID = contacts.companyID
)
WHERE   contacts.companyID IS NULL

Now, both SQL statements will perform relatively the same on either DB's with a 
small data set.

but, if you have a large data set, MySQL will benefit from having the Sub-Query 
style statement

Where-as PostgreSQL will shine with the JOIN command.

This is only from my own personal testing.  Mind you that I have only been using PostgreSQL for a 
year or so.  But one problem that I have always ran into with MySQL is that when JOIN'ing tables 
that have large data sets is a PITA.


So, if I was running MySQL, I would use SQL #1, but if I were using PostgreSQL, 
I would use SQL #2

If anybody else has suggestions or comments about performance between MySQL vs. PostgreSQL with 
regards to similarly formed SQL calls, I would like to hear their experiences.


--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



[PHP-DB] Re: [PHP] Re: the opposite of a join?

2007-10-03 Thread Jim Lucas

Robert Cummings wrote:

On Wed, 2007-10-03 at 14:49 -0700, Jim Lucas wrote:
This is only from my own personal testing.  Mind you that I have only been using PostgreSQL for a 
year or so.  But one problem that I have always ran into with MySQL is that when JOIN'ing tables 
that have large data sets is a PITA.


Were you doing left joins when you experienced those problems? Left
joins are usually very fast.


So, if I was running MySQL, I would use SQL #1, but if I were using PostgreSQL, 
I would use SQL #2


I'd use the left join whenever available.

Cheers,
Rob.


Honestly, I cannot remember.  It was right when I first started with 
PHP/mysql back in 1999.  I think we were using a JOIN (without the LEFT)


Which I think the default is an INNER JOIN if I do recall.

I really have never played with performance over the past few years.

This past year I have been working on a new DB with Call Detail Records 
for a phone company.  On average we have to deal with processing 2 - 4 
million records each billing cycle.  So, having to work with that amount 
of CDR's and a couple thousand client records that are associated with 
them, makes for a good performance test on SQL statements.


--
Jim Lucas


Perseverance is not a long race;
it is many short races one after the other

Walter Elliot



Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP-DB] any php/Linux gurus out there?

2002-03-05 Thread Jim Lucas [php]

I being a person that is working with both RH 7.0  7.1 would not recommend
forcing an upgrade.

I did that when I attempted to upgrade to 7.2 and wanted to try a few new
things that didn't come with the install.  I ended up having to reinstall
the entire OS.

So, make the effort and upgrade all the deps also.  it will be worth it in
the long run.

Jim Lucas
- Original Message -
From: Jason Wong [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 04, 2002 8:18 PM
Subject: Re: [PHP-DB] any php/Linux gurus out there?


 On Tuesday 05 March 2002 07:52, Peter Lovatt wrote:
  Hi
 
  I am running the security upgrade and am getting the following error
when I
  run the RPM
  The install is RH 7.0 and was pre-installed. I had assumed that the RPMs
  from Redhat would match the pre installed version, as it was standard.
 
  I am a humble programmer (and part time sys admin!), rather than a
Linux/RH
  guru, so would appreciate some advice. What is the best way to deal with
  this ?
 
 
  error: failed dependencies:
  libcrypto.so.1 is needed by php-4.0.6-9.7.0
  libmm.so.11 is needed by php-4.0.6-9.7.0
  libssl.so.1 is needed by php-4.0.6-9.7.0
  libcrypto.so.1 is needed by php-imap-4.0.6-9.7.0
 

 Have you followed the instructions given on the RH website? Most upgrades
are
 performed using:

   rpm -Uvh xxx.rpm

 or

   rpm -Fvh xxx.rpm




 --
 Jason Wong - Gremlins Associates - www.gremlins.com.hk

 /*
 I'd love to go out with you, but I'm doing door-to-door collecting for
static
 cling.
 */

 --
 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] easy date format question

2002-03-01 Thread Jim Lucas [php]

$today = date(Ymd);
$sql = INSERT into table (date) values ('$today');

when the $today variable is inserted into a mysql date column it will fit
just right.
but, if you want to insert it into a timestamp column, you will have to padd
it with 6 zero's

Jim Lucas
www.bend.com

- Original Message -
From: Matthew Crouch [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, March 01, 2002 2:50 PM
Subject: [PHP-DB] easy date format question


 should be simple as pie, of course, but i can't find a straightforward
 syntax example in the documentation. i'm trying to change the PHP date
 format to mysql's.

 my code:
 $today = date(MMDD);
 $sql = INSERT into table (date) values ('$today');
 and so on...

 is filling the date field with zeros, instead of 2002-02-28


 --
 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] Passing form values with quotes, to itself

2002-02-14 Thread Jim Lucas [php]

it is called magic quotes and it can be enabled through the php.ini file.

Jim Lucas
- Original Message -
From: William Fong [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, February 13, 2002 10:36 AM
Subject: Re: [PHP-DB] Passing form values with quotes, to itself


 Doesn't PHP have something that will automatically do this?  I can't
 remember, but I think you had to enable it in php.ini or when you compile.

 (just like to know for future reference).

 thx.

 -w

 --
 William Fong - [EMAIL PROTECTED]
 Phone: 626.968.6424 x210  |  Fax: 626.968.6877
 Wireless #: 805.490.7732|  Wireless E-mail: [EMAIL PROTECTED]




 - Original Message -
 From: David Fudge [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, February 13, 2002 10:12 AM
 Subject: Re: [PHP-DB] Passing form values with quotes, to itself


 : before you submit to the db, you have to escape the quotes like this:
 :
 : $Body = addslashes($Body);
 : all   will show up as \ \
 : and ' ' will be \' \'
 :
 : when you pull the info from the db, you'll have to use stripslashes()
to
 : remove those you put in.
 : $Body = stripslashes($Body_from_db);
 :
 : - Original Message -
 : From: Faye Keesic [EMAIL PROTECTED]
 : To: [EMAIL PROTECTED]
 : Sent: Wednesday, February 13, 2002 1:02 PM
 : Subject: [PHP-DB] Passing form values with quotes, to itself
 :
 :
 :  Hi there.
 : 
 :  I have a form that contains several fields w/ text info (which may or
 may
 :  not contain single and double quotes).
 : 
 :  When the user clicks Preview, the form's action is set to call itself
 :  ($PHP_SELF), and the info is displayed nicely so they can read it
over,
 : and
 :  verify it before saving to the db.
 : 
 :  What I'm having problems with is that when the data has quotes, the
text
 :  data cuts off.
 : 
 :  If I use: input type=text name=Body value= ?php echo $Body;
?
 :  then double quotes are cut off.
 : 
 :  If I use: input type=text name=Body value=' ?php echo $Body;
?'
 :  then single quotes are cut off.
 : 
 :  I want nothing cut off!  I've tried addslashes()..still cuts off.
 : 
 :  I hope that all made sense...
 :  --
 :  Faye
 : 
 : 
 :  --
 :  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 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] A while loop prob ?

2002-02-14 Thread Jim Lucas [php]

Try this

if ($submit)
{
if($search == )
{
$error1 = font color=redNo Records found. Please use at least 1
character in search box/font;
} else {
$srchsql = select * from $tbn where name like \%$search%\ ;
$srchresult = mysql_query($srchsql, $con);
$name =$srchrow['name'];
$details =$srchrow['details'];
$price =$srchrow['price'];
$imgloc =$srchrow['imgloc'];
while (list($name, $details, $price, $imgloc) =
mysql_fetch_array($srchresult))
{
$display_srch_rows .=
trtd$imgloc/tdtd$name/tdtd$details/tdtd$price/td/tr;
}
echo $display_srch_rows;
}
}

the problem is, you were overwriting your results each time you went into
the loop therefor always ending up with the last returned result set.
if you use  .=  instead of  =  you will concat the results, therefor
making one long string.

then echo/print the $display_srch_rows variable.

Jim Lucas
- Original Message -
From: Dave Carrera [EMAIL PROTECTED]
To: php List [EMAIL PROTECTED]
Sent: Wednesday, February 13, 2002 11:40 AM
Subject: [PHP-DB] A while loop prob ?


 Hi All

 What have I done wrong here.

 3 yes 3 hours I have been plaing with this loop.

 All it shows is the last record in my db.

 It should show and record containing any string in the search.

 Error works

 Please help I beg you...

 As always thank you for any help

 Dave C

 - My Code Starts Here 

 if ($submit){
 if($search == ){
 $error1 = font color=redNo Records found. Please use at least
 1 character in search box/font;
 }
 else
 {
 $srchsql = select * from $tbn where name like \%$search%\ ;
 $srchresult = mysql_query($srchsql, $con);
 $name =$srchrow['name'];
 $details =$srchrow['details'];
 $price =$srchrow['price'];
 $imgloc =$srchrow['imgloc'];
 while (list($name, $details, $price, $imgloc)
 =mysql_fetch_array($srchresult)){

 $display_srch_rows =
 trtd$imgloc/tdtd$name/tdtd$details/tdtd$price/td/tr
 ;
 }
 }
 }

 Dave Carrera
 Website Designer
 http://www.davecarrera.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




Re: [PHP-DB] Passing form values with quotes, to itself

2002-02-13 Thread Jim Lucas [php]

Try this.

input type=text name=Body value=?=htmlspecialchars($Body)?

That should to the job.

Jim Lucas
- Original Message -
From: Faye Keesic [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, February 13, 2002 10:02 AM
Subject: [PHP-DB] Passing form values with quotes, to itself


 Hi there.

 I have a form that contains several fields w/ text info (which may or may
 not contain single and double quotes).

 When the user clicks Preview, the form's action is set to call itself
 ($PHP_SELF), and the info is displayed nicely so they can read it over,
and
 verify it before saving to the db.

 What I'm having problems with is that when the data has quotes, the text
 data cuts off.

 If I use: input type=text name=Body value= ?php echo $Body; ?
 then double quotes are cut off.

 If I use: input type=text name=Body value=' ?php echo $Body; ?'
 then single quotes are cut off.

 I want nothing cut off!  I've tried addslashes()..still cuts off.

 I hope that all made sense...
 --
 Faye


 --
 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] Passing form values with quotes, to itself

2002-02-13 Thread Jim Lucas [php]

it will still cut off with the double quots.  if you have a double quote
inside of a double quoted value property
?
$myvalue = And he asked, \what have you done, son\?  ;
?
input type=text name=something value=?=addslashes($myvalue)?

This will still break.  it does care if they are escaped.

Jim Lucas
- Original Message -
From: David Fudge [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, February 13, 2002 10:12 AM
Subject: Re: [PHP-DB] Passing form values with quotes, to itself


 before you submit to the db, you have to escape the quotes like this:

 $Body = addslashes($Body);
 all   will show up as \ \
 and ' ' will be \' \'

 when you pull the info from the db, you'll have to use stripslashes() to
 remove those you put in.
 $Body = stripslashes($Body_from_db);

 - Original Message -
 From: Faye Keesic [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, February 13, 2002 1:02 PM
 Subject: [PHP-DB] Passing form values with quotes, to itself


  Hi there.
 
  I have a form that contains several fields w/ text info (which may or
may
  not contain single and double quotes).
 
  When the user clicks Preview, the form's action is set to call itself
  ($PHP_SELF), and the info is displayed nicely so they can read it over,
 and
  verify it before saving to the db.
 
  What I'm having problems with is that when the data has quotes, the text
  data cuts off.
 
  If I use: input type=text name=Body value= ?php echo $Body; ?
  then double quotes are cut off.
 
  If I use: input type=text name=Body value=' ?php echo $Body; ?'
  then single quotes are cut off.
 
  I want nothing cut off!  I've tried addslashes()..still cuts off.
 
  I hope that all made sense...
  --
  Faye
 
 
  --
  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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Select rows where ?

2002-02-12 Thread Jim Lucas [php]

select * from table where columnsomething
select * from table where column NOT LIKE %something%

Jim Lucas
- Original Message - 
From: Dave Carrera [EMAIL PROTECTED]
To: php List [EMAIL PROTECTED]
Sent: Tuesday, February 12, 2002 10:39 AM
Subject: [PHP-DB] Select rows where ?


 Hi All
 How do I select the rows that DO NOT contain a certain character.
 
 I.e. : select * from tablename where field dose not contain A
 
 Any pointers as always appreciated.
 
 davec
 
 Dave Carrera
 Website Designer
 http://www.davecarrera.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




Re: [PHP-DB] # of Records in Table

2002-01-23 Thread Jim Lucas [php]

does the table have an autoincrement column?

Jim Lucas
- Original Message -
From: Zach Curtis [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, January 23, 2002 10:27 AM
Subject: [PHP-DB] # of Records in Table


 What syntax can I use to determine how many records are in a MySQL table
and
 then retrieve the value of the field password for the last record? I
tried
 using some combinations of COUNT(*) and LIMIT with no success.

 Thanks.


 Zach Curtis
 POPULUS


 --
 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 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] Passing parameter in Paging

2001-12-28 Thread Jim Lucas [php]

better yet, have a starting page multiplied by the page length

define a constant that gives the page limit then have the receiving page do
some math and do a mysql_data_seek() or array_seek() (which ever you are
using) and then limit the returns by the page limit size?

wouldn't that be the easiest way? if not, please let me know, cuz I am using
that for pagination throughout my site via a couple function calls.

Jim
- Original Message -
From: olinux [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, December 28, 2001 2:58 PM
Subject: Re: [PHP-DB] Passing parameter in Paging


 Aren't all these form solutions making things more
 complex than they need to be? Why not just pass the
 parameters in the URL

 Use php to echo out start_at and end_at variables

 ie. A

HREF=http://website.com/search.php?keyword=somethingstart_at=15end_at=30;
2/A
 A

HREF=http://website.com/search.php?keyword=somethingstart_at=31end_at=45;
3/A

 etc.

 olinux


 --- Mihail Bota [EMAIL PROTECTED] wrote:
  Bogdan, in this respect, I have a question: can I
  pass the values of
  javascript variables to php variables? if yes, how?
 
  Mihai
 
  On Fri, 28 Dec 2001, Bogdan Stancescu wrote:
 
   I don't understand why you won't use forms with
  buttons and hidden controls
   since you know about this solution. I have two
  suggestions along this line:
   1. You probably don't want buttons on the page --
  you may use image icons
   instead (similar to a tape recorder's play and
  fast forward for next page
   and last page)
   2. If you don't want to use images either, you may
  use regular links with
   href='javascript:document.nextPage.submit()'
  where nextPage would be the form
   name with the page forward data -- and so on.
  
   HTH

 __
 Do You Yahoo!?
 Send your FREE holiday greetings online!
 http://greetings.yahoo.com

 --
 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 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] Mysql result resource error

2001-12-20 Thread Jim Lucas

which one was giving you the problem? the first or second mysql try.  if it
was the second, try wrapping the $cattyname with single quotes  like this
Minor_Category = '$cattyname'.  if the $cattyname var has anything but
numbers, the statement won't work.

Jim
- Original Message -
From: Shannon Doyle [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, December 19, 2001 4:19 PM
Subject: [PHP-DB] Mysql result resource error


 Hi People,

 I am getting a Not a valid Mysql result resource error with the
 following code, can someone take a look at this for me and see if there
 is anything that stands out

 Thanks,

 Shannon

 ?
 $cattyname = ;
 $sql = select Minor_Category main where Page = 'wines' order by
 Minor_Category;
 $dbh = @mysql_connect($dbhost,$dbuser,$dbpass);
 $results2 = mysql_db_query($db,$sql,$dbh);
   for($j = 0; $j  mysql_num_rows($results2); $j++) {
   $array[$j] = mysql_fetch_array($results2);
 }
 mysql_close($dbh);
 for ($h = 0; $h  count($array); $h++)  {

 if ($array[$h][Minor_Category] != $cattyname) {
   $cattyname = $array[$h][Minor_Category];
   echo trtd colspan='4'a
 name='.$cattyname.'/ab.$cattyname./b/td/td/tr;


 $catname = ;
 $sql = select Category,Code,Description,Pack,Unit,Price from main where
 Page = 'wines'  Minor_Category = $cattyname order by Category;
 $dbh = @mysql_connect($dbhost,$dbuser,$dbpass);
 $results = mysql_db_query($db,$sql,$dbh);
   for($i = 0; $i  mysql_num_rows($results); $i++) {
   $array[$i] = mysql_fetch_array($results);
 }
 mysql_close($dbh);

 for ($i = 0; $i  count($array); $i++)  {

 if ($array[$i][Category] != $catname) {
   $catname = $array[$i][Category];
   echo trtd colspan='4'a
 name='.$catname.'/ab.$catname./b/tdtd
 align='center'pbCarton Size/b/p/tdtd
 align='center'pbUnit/b/p/tdtd
 align='right'pbPrice/b/p/tdtda href='#top'img
 src='images/arrow.gif' border='0'/a/td/tr;
 }

   echo trtd/tdtdpa
 href=javascript:order_now(quot;.$array[$i][Code].quot;)img
 src='images/order.gif' border='0'/a/tdtd/tdtd
 align='left'p.$array[$i][Description]./p/tdtd
 align='center'p.$array[$i][Pack]./p/tdtd
 align='center'p.$array[$i][Unit]./p/tdtd
 align='right'p$.$array[$i][Price]./p/td/tr\n;
 }
 }
 }
 ?


 --
 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 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] Checkboxes, PHP, and MySQL

2001-12-20 Thread Jim Lucas

Try this

input type=checkbox name=firstvalue ?=($result[32]?checked:)?

Jim
- Original Message -
From: SpyProductions Support Team [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, December 20, 2001 8:40 AM
Subject: [PHP-DB] Checkboxes, PHP, and MySQL



 I've looked around in a few of the PHP lists for an answer to this, but
 can't come up with one.

 Here's what I am doing:

 I have a form with a few checkboxes.

 When the information as to whether the checkboxes are checked or not is
 'saved' into the MySQL table, they are represented by a value of '1' -
fine.

 When I want to edit this information, in the form of a similar form with
 checkboxes, the boxes are not checked off if they were before.

 What I am stuck on is how a checkbox can get checked off when pulling
 information from the MySQL as an array.

 Here's a line of code showing my array coming out.

 input type=checkbox name=firstvalue value='$result[32]'

 $result is the array.

 I guess what I am asking is that if a checkbox is assigned a value of one,
 why doesn't it appear as already checked off?

 Thanks,

 -Mike


 --
 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 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] Learning PHP Sessions

2001-10-31 Thread Jim Lucas

one problem I see, you are trying to populate the variable after you
register it.

session_start();
$myvar = something;
session_register('myvar');
echo $myvar;


Jim Lucas


- Original Message -
From: Russ Michell [EMAIL PROTECTED]
To: Steve Cayford [EMAIL PROTECTED]
Cc: Matthew Tedder [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, October 31, 2001 8:44 AM
Subject: Re: [PHP-DB] Learning PHP Sessions



 * session_register('myvar'); creates a session var called $myvar
 * session_start(); needs to be called from the top of each script that
will need the session var
 $myvar
 * session_destroy('myvar'); rids you of $myvar completely.
 * session_destroy('HTTP_SESSION_VARS'); rids you off *all* currently
registered session vars

 Note that a variable used in this way is refered to as 'myvar' and
referenced a snormal within the
 script as: $myvar

 HTH you out.
 Russ

 On Wed, 31 Oct 2001 09:55:33 -0600 Steve Cayford
[EMAIL PROTECTED] wrote:

  This is really off-topic for this list, but...
 
   From my understanding of sessions, you really don't want
session_start()
  in an if{} block. Every time you hit this script, it will have no memory
  of any session variables until you call session_start().
 
  -Steve
 
  On Tuesday, October 30, 2001, at 02:30  PM, Matthew Tedder wrote:
 
   ?php
   /*
   Hi,
  
   I'm new to PHP and am having trouble understanding how to use PHP
   sessions.  My book tells in near the beginning how to start them and
   register
   session variables, but I can't figure out how to destroy a session or
   later
   read those session variables.  I'm also trying to do this across
   frames, but
   can't even get it to work within a single page.
  
   Here's what I've learned so far and what my problems are:
   */
  
   /* To start a session */
   session_start();
  
   /* To register a session variable */
   session_register(myvar);
   $myvar = some value;
  
   /*
   PROBLEM #1:  From the above commands, I get a $PHPSESSID that seems to
   be
   globally available for use, but I cannot seem to read my values back
   out of
   the registered session variable from anywhere...  I tried:
   */
  
   print $myvar\n;   /* and absolutely nothing is printed */
  
   /* To destroy a session */
   session_destroy();
  
   /*
   PROBLEM #2:  This says there is no session to destroy.  It's rather
   strange
   because I can still print the $PHPSESSID value..
  
   I've attached my code...
  
   */
   ?
--
   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 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]
 

 #---#

   Believe nothing - consider everything

   Russ Michell
   Anglia Polytechnic University Webteam
   Room 1C 'The Eastings' East Road, Cambridge

   e: [EMAIL PROTECTED]
   w: www.apu.ac.uk/webteam

   www.theruss.com

 #---#


 --
 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 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] New users on mysql using php

2001-10-25 Thread Jim Lucas

go grab yourself a copy of 
phpmyadmin
http://phpmyadmin.sourceforge.net/download.html
jim

- Original Message - 
From: Harpreet [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, October 25, 2001 2:02 PM
Subject: [PHP-DB] New users on mysql using php


 I connect to mysql database using the following:
 
 $StrConnectionUser=mysql_connect(ipaddress,$USER);
 mysql_select_db(database name, $StrConnectionUser);
 
 My question is how can I add new users to mysql using the web interface.
 Like can i run the Grant and revoke (mysql commands)  in my php page??
 
 This way i can add or delete users that can have access to the mysql
 database through the web.
 I hope the above makes sense.
 
 Thanks,
 Regards,
 Harpreet Kaur
 Software Developer
 Crispin Corporations Inc.
 
 
 
 -- 
 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 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] array-problems

2001-10-24 Thread Jim Lucas


- Original Message -
From: Jim Lucas [EMAIL PROTECTED]
To: Bart Verbeek [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, October 24, 2001 12:42 PM
Subject: Re: [PHP-DB] array-problems


 Try this:

  BEGIN:PHP-CODE 

 $result = mysql_query (SELECT DISTINCT date FROM linktracker WHERE name
 LIKE '$PHP_AUTH_USER' GROUP BY date ORDER BY date);
 if (mysql_num_rows($result))
 {
   for($i=0;$icount($row);$i++)
   {
 $date = array(
   begin = array($i = $row[date]),
   end = array($i = $row[date])
   );
   }
 } else {
   print (Sorry, no record were found.);
 }

 function drawSelect($which)
 {
   global $date;
   foreach($date[$which] AS $date_begin)
   {
 ?
 option value=?=$date_begin??=$date_begin?/option
 ?
   }

 }

 ?
 table
   tr
 tdBegindate/td
 tdEnddate/td
   /tr
   tr
 tdform method=post action=index.php name=date_select
 input type=hidden name=action value=date_select
 select name=date_begin
 ?
 drawSelect(begin);
 ?
 /select
 /td
 tdselect name=date_end
 ?
 rsort($date[end]);

 drawSelect(end);
 ?
 /select
 /td
   /tr
   tr
 td colspan=2input type=submit name=Submit
 value=Submit/form/td
   /tr/table

  END:PHP-CODE 

 btw - you need to watch your closing ''  you are missing a few.  Plus to
 get distince to work right you need to use the GROUP BY clause.

 Jim

 - Original Message -
 From: Bart Verbeek [EMAIL PROTECTED]
 To: Php-General-list [EMAIL PROTECTED]; PHP-DB mailinglist
 [EMAIL PROTECTED]
 Sent: Wednesday, October 24, 2001 12:23 PM
 Subject: [PHP-DB] array-problems


  Hello,
  Can anyone help me with this script I'm using?
 
  I've saved dates in a database and want to make two select-lists of
these
  dates in a html-form.
  I want to select each unique date one time (no doubles).
  List 1 is used to set the begin-date of the query for the report, List 2
  will
  set the end-date and must be reversed.
  When the form is processed the data selected between the begin-date and
 the
  end-date has to be show.
 
  I can't seem to get my code to work: the select-lists stay empty after
  processing the code below.
 
  Can anyone help? Tips...
 
  regards,
 
  Bart
 
 
   BEGIN:PHP-CODE 
  $i=0;
   $result = mysql_query (SELECT DISTINCT date FROM linktracker WHERE
name
  LIKE '$PHP_AUTH_USER' ORDER BY date);
   if ($row = mysql_fetch_array($result)) {
  do {
$date = array(
  begin = array($i = $row[date]),
  end = array($i = $row[date])
  );
  $i++;
  } while ($row = mysql_fetch_array($result));
   } else {print (Sorry, no record were found.);
   } //end else $result
 
  print(tabletrtdBegindate/tdtdEnddate/td/tr\n.
  trtdform method=\post\ action=\index.php\
  name=\date_select\.
  input type=\hidden\ name=\action\
  value=\date_select\.
  select name=\date_begin\);
 
  while (list($key, $date_begin) = each($date[begin])) {
  echo option value=\.$date_begin  .\ . $date_begin .
  /option\n;
  }
 
  print(/select/tdtdselect name=\date_end\);
 
  rsort($date[end]);
 
  while (list($key, $date_end) = each($date[end])) {
echo option value=\.$date_end  .\ . $date_end .
  /option\n;
  }
 
  print(/select/td/tr\ntrtd colspan=\2\.
input type=\submit\ name=\Submit\
value=\Submit\.
/form/td/tr/table);
 
  mysql_free_result ($result);
  mysql_close();
   END:PHP-CODE 
 
 
  --
  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 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]