Re: [PHP-DB] mysql_num_rows

2002-09-19 Thread 1LT John W. Holmes

 I'm getting a strange error message from calling this function

 It spits out Unknown column 'Resource' in 'field List'
 This is my query:

 SELECT dept.name, count(maintenance.deptid)/$total AS percentage FROM
 maintenance
 JOIN dept WHERE maintenance.deptid=dept.deptid GROUP BY dept.name

 This query runs fine in console I just can't get mysql_num_rows to return
a
 value.

 This is running mysql 4.0.3 and php 4.2.3

What's the value of $total? Probably Resource, meaning something else
before you query isn't going as you expect it to.

---John Holmes...


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




Re: [PHP-DB] set_magic_quotes_runtime???

2002-09-19 Thread 1LT John W. Holmes

 So what does set_magic_quotes_runtime(0) do then???  Will it shut off the
 automatic backslashing of single quotes at run time or not?  (it certainly
 doesn't seem to)

It will turn off the escaping of quotes from data your script reads while
it's executing, namely from data returned from a database query.

---John Holmes...


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




Re: [PHP-DB] magic_quotes_gpc?

2002-09-19 Thread 1LT John W. Holmes

 New PHP (long time PERL user) here.  I am using an Access database -
 yeah I know Access is crap, but I have no choice.  Anyway, it seems that
 this magic backslash thing is unavoidable.  As I understand it, I can shut
 it off at the .ini level, but I am running this app on a hosted server
with
 other apps - I haven't the choice to make that change.  The question is
 this...

 Can I override the magic_quotes_gpc setting at the script level?  (i.e. on
 the fly, for this script only?)  If not, I am guessing I need to remove
the
 single quotes on the client side (javascript) prior to submitting the
data?
 (any other ideas on how to handle this without changing the .ini?)

You can use ini_set() in all of your scripts (or include file), or .htaccess
depending on your server.

php_value magic_quotes_gpc 0

Does Access escape it's quotes with an additional ' instead of an \ ? If so,
then you should look at magic_quotes_sybase. Turning it on will escape
strings with a ' instead of an \. It also can be set in .htaccess or
ini_set().

---John Holmes...


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




Re: [PHP-DB] how can I do?

2002-09-19 Thread 1LT John W. Holmes

 Or this works well too and might be faster for the DB.

 SELECT * FROM SomeTable WHERE create_date BETWEEN $start_date AND
 $end_date

Benchmark it yourself, but I've found that BETWEEN is slower. It's easier to
read, though.

---John Holmes...


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




Re: [PHP-DB] how can I do?

2002-09-19 Thread 1LT John W. Holmes

 I am trying to find the records  whose create dates (field name
 =create_date) are between the ones I want .For example , I want to seee
the
 records between  $start_date  and  $end_date  ..So I tried the code
 below..But it looks not that right to me?...

 select * from bug where  ..  and   $start_date   create_date  $end
 _date

You want:

WHERE $start_date  create_date AND $end_date  create_date

or...

WHERE create_date BETWEEN $start_date AND $end_date

but, this is dependant on your format of create_date and the variables
$start_date and $end_date. All of them should be MySQL DATE, DATETIME, or
TIMESTAMP columns/format.

---John Holmes...


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




Re: [PHP-DB] advise needed for 'authorized only' site

2002-09-23 Thread 1LT John W. Holmes

 I have set up a section of my company site for use by authorized dealers
 only. I am currently using
 mysql authorization, which works for the first page, but if someone were
to
 type in the url of an
 underlying page they would be able to get in without authorization. I know
 I could use .htaccess
 for handling this but with a minimum of 350 -400 users to keep track of
 that would be unwieldly to
 say the least, especially for my boss who doesn't have a clue about *nix
 and has never even heard
 of .htaccess.

 What other options do I have to keep the underlying pages from being
 accessed without the user
 being forced to go through the logon screen?

You have to make a check on every page that the user is valid. Start a
session on the first page, after they log in, and then check for a variable
in this session on each subsequent page. If it's there, then they are good.

---John Holmes...


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




Re: AW: [PHP-DB] getting mysql_fetch_row into array

2002-09-23 Thread 1LT John W. Holmes

  $res = mysql_query (SELECT COUNT(deptid) FROM maintenance GROUP BY
  deptid);
  $deptcount = array(); // reset the array
  while ($row = mysql_fetch_row ($res)) {
$deptcount[] = $row[0];

 this should be $deptcount[] .= $row[0]; shouldn't it?

No. The way it's written is it's adding an element onto the array with each
loop. It's basically the same as doing

array_push($deptcount,$row[0]);

---John Holmes...


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




Re: [PHP-DB] advise needed for 'authorized only' site

2002-09-23 Thread 1LT John W. Holmes

Why do you need the secret variable? If your server is set up correctly, the
user can't create any session variables, all they can do is create a session
ID. So you could just check for a user-id and you'd be good.

---John Holmes...

- Original Message -
From: Jackson Miller [EMAIL PROTECTED]
To: 'Bryan McLemore' [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, September 23, 2002 4:06 PM
Subject: RE: [PHP-DB] advise needed for 'authorized only' site


  you could make them log in once per session and just have
  every page check and see if they already have logged in and
  if they have not then trigger the login mechanism.
 

 This is what I do.  I have a file/function called verify that I call at
 the top of every page that I want secure (and any page that might just
 perform an action and then redirect to a page that displays content).

 Here is how my authentication system works:

 1) On any page a session is started if one doesn't already exist.

 2) When they submit they submit login information it is checked against
 the database.

 3) If the login is approved, I session_register() the user_id field, the
 user_level (if applicable), and a variable called valid.

 4) I set valid = to the md5 hash of user_id.user_level.secret_variable
 (secret variable is a variable set in the code so only the server knows
 it.

 5) on every page the verify function checks to make sure that the
 variable $valid is equal to the md5 of
 user_id.user_level.secret_variable  (This works because the session
 knows the user_id, and user_level, and the server knows the secret
 variable).


 Hope this helps.

 -Jackson


 --
 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] Return Array from Function

2002-09-26 Thread 1LT John W. Holmes

You can't start variables with a number.

---John Holmes...

- Original Message -
From: Hutchins, Richard [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, September 26, 2002 4:18 PM
Subject: [PHP-DB] Return Array from Function


 Can somebody tell me what I might be doing wrong in the code below? I'm
 trying to use a function to perform an often-used db query and return the
 resulting resource to the calling script. I keep getting this error
though:

 Parse error: parse error, unexpected T_LNUMBER, expecting T_VARIABLE or
'$'
 in c:\spidey\public\addleveltwo.php on line 51

 I've looked and looked, but I can't find what could be causing a parse
 error. Most likely, I've just been looking at it for too long. Any fresh
 eyes available?

 ?php
 include(../protected/getContent.php);

 getLevelOnes($docnum); //user-defined function from included file.
 Definition appears after this snippet.

 $num=mysql_num_rows($levelones);

 if($num1)
 {
 echo(There is no level one (Section) content for this
 document in the database.);
 exit();
 }

 while($row=mysql_fetch_array($levelones))
 {
 $1contentID=$row[1contentID];
 $parentID=$row[parentID];
 $1child=$row[childID];
 $1content=$row[1content];
 $1ordinal=$row[ordinal];

 echo(trtd.$1content./tdtda
 href=\contentMgr.php?docnum=.$docnum.\
 target=\_right\Add/a/td/tr);
 }
 ?

 ?php
 function getLevelOnes($docnum)
 {
 $sql=SELECT 1contentID, parentID, childID, 1content, 1ordinal FROM
 levelone WHERE 1contentID='$docnum';
 $levelones=mysql_query($sql)
 or die(mysql_error());
 return $levelones;
 }
 ?


 --
 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] Table question....

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

$bgcolor = ($count++  1) ? blue : black;

Then use $bgcolor in your tr

---John Holmes...

- Original Message -
From: Rodrigo [EMAIL PROTECTED]
To: PHP [EMAIL PROTECTED]
Sent: Thursday, October 03, 2002 8:29 AM
Subject: [PHP-DB] Table question


Hi people, is there a way to print a table with the background switching
colors??? like one blue, the next black, blue, black...

thanks in advance...  Equipe Pratic Sistemas
Rodrigo CorrĂȘa
Fone: (14) 441-1700
[EMAIL PROTECTED]
[EMAIL PROTECTED]




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




Re: [PHP-DB] Showing multiple option list from db query?

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

 I have a database (mysql) that has some rows entered.

 Format:
 Name | Desription | catid

 This has some info in it like this

 Joe Man 1
 Jack Man 1
 Jacky Female 2
 Emily Female 2

 What I am trying to do is create dynamically created select lists so
 that all with catid 1 are in the fisrt select list and all with catid 2
 are in a separate second list and so on.

 I have it nearly working but the first list gives the cadid 1 result the
 second gives catid 1 and catid 2 result and so on.

 So how would I split the results?

?
$result = mysql_query(SELECT * FROM table);
while($row = mysql_fetch_assoc($result))
{ $option[$row['catid']] = option
value='{$row['Name']}'{$row['Name']}/option\n; }

Then use $option[1] and $option[2] in your different select boxes.

select name=male
?=$option[1]?
/select

---John Holmes...


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




Re: [PHP-DB] results of query

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

 What does everyone typically use to display the results of a query.  For
 example, I have a database that has a series of subjects and grades.  If I
 select * from the table, I want a nice way for the data to be displayed.
In
 cold fusion, I can simply use a grid that dynamically fills in.  Can I do
 this with php?

There is no automatic way to do it with PHP. You have to write the code to
display it yourself and this depends on how you want to display it. If you
just want to display it in a table, then you can write a generic function to
display column names and values in a table given a result set.

Assuming $result is a result set from any query.

echo table;
while($row = mysql_fetch_row($result))
{
  echo trtd . implode(/tdtd,$row) . /td/tr\n;
}
echo /table;

Adapt to your needs to add error checking, empty fields, header row, etc.
You can use the mysql_field_name() functions to get the field names from the
result set to create your header row, so you don't actually have to know the
names from the query.

---John Holmes...


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




Re: [PHP-DB] need help

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

Remove all of the @ for one, so you can see if there are any errors. You're
using $rs as two different variables, also. Check mysql_error() after your
query to see if an error is returned.

---John Holmes...

- Original Message -
From: Frederick Belfon [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, October 08, 2002 12:19 PM
Subject: [PHP-DB] need help


I have Mysql set up on the same machine as the apache server. There is a
database name inventory_db with a table product_info which have the two row
id and name. I know there are three records in the table. However when ever
I place this script below into a webpage I get just a blank page.  What can
I do to correct it. Thank you




? php
# connect to mysql
$conn= @mysql_connect(localhost, root)
  or die (Err:conn);

#select the specified database
$rs= @mysql_select_db(inventory_db, $conn)
  or die(Err:Db);

#Create the query
$sql= select id, name from product_info;

#execute the query
$rs= mysql_query($sql, $conn);


#write the data
while ($row=mysql_fetch_array($rs) )
{
 echo(Product ID:  .$row[id]);
 echo( Product Name:  .$row[name] br);

}

?


/* The gospel is meant to comfort the afflicted and afflict the
comfortable.
Garrison Keillor*/


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




Re: [PHP-DB] DEALING WITH RETRIEVING AND WRITING DATE VALUE FROM/TO TABLE

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

 I need to know how to retrieve a date field from a database
 table using MYSQL_DB_QUERY to create recordset. As well as
 writing a Date Variable to a table using MYSQL_QUERY  .

For one, don't use mysql_db_query(), it's depreciated.

You'd use mysql_query() for both instances and
mysql_fetch_row/array/assoc/object to fetch the returned data.

Please learn some SQL and read over the MySQL chapter of the PHP manual.

---John Holmes...


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




Re: [PHP-DB] Separating content from style

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

One of the most popular template engines is Smarty. Search on google for it.
There are plenty of others and even some modules that can be installed into
PHP for faster performance.

YOu can easily seperate logic from presentation with PHP, but most people
choose not to. For most simple projects out there, there's no reason to
involve database abstraction and templating...

---John Holmes...

- Original Message -
From: Dave Smith [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, October 09, 2002 11:26 AM
Subject: [PHP-DB] Separating content from style


 Folks,

 I've just learned a bit about Java Beans and how they are useful in
 separating content from style. They let you do XSLT'ish stuff in your HTML
 to grab data while not bogging down your HTML with database-related
 function calls. I've heard this setup referred to as templates and
 3-tier. It has all kinds of advantages, the biggest of which
 is probably the ability to specialize: Allow your web-designer
 to work with HTML/CSS and your DBA to work with SQL, with no
 overlap.

 Obviously, PHP doesn't really lend itself to this sort of setup at first.
 At least, I haven't found a good way to do it.

 Does anyone have any good docs on how to setup a 3-tier templated system
 in PHP that separates content from style? If not, how about a few words on
 this idea? What are your thoughts? How can PHP tackle this problem?

 advTHANKSance,
 Dave


 --
 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] Getting valie between two fields? (mysql)

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

 I have a table something like this:
 __
 | id | number |
 | 1 |   1 |
 | 2 |  23|
 | 3 |  59|
 | 4 | 103   |
 
 If I have a number, say 30, I need to get the last number it's above - 
 in this case id 2.  Any ideas?

$number = 30;
SELECT id FROM table WHERE number  $number ORDER BY number DESC LIMIT 1;

---John Holmes...

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




Re: [PHP-DB] Print data

2002-10-23 Thread 1LT John W. Holmes
 hello, at my company we have several network printers and i was was
 wondering if it's possible to print directly to them using PHP, instead
 of showing on the screen or both ...
 to gain more control on what is printed, because of the nasty browsers
 header and footer ... whom i now how to remove ...

 i know that the printer IP is  192.192.1.100 and the port is 9005 ...

The printer functions in the manual only work in windows and only work for
the printer attached directly to the server. Hmm..I wonder, though, if you
have a network printer that's set up to print from the server, can you use
the printer functions to print to that? I'm sure the answer is in the
manual. If not, maybe you can open a connection directly to the printer and
send it the raw data, if you know the format.

---John Holmes...


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




Re: [PHP-DB] Function that outputs at line xxx

2002-10-23 Thread 1LT John W. Holmes
__LINE__ and __FILE__ should work.

---John Holmes...
- Original Message -
From: Peter Beckman [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, October 23, 2002 3:00 PM
Subject: [PHP-DB] Function that outputs at line xxx


 Hey --

 I'm writing a database error handler function in PHP, and I want it to
tell
 me at what line in what script the error occurred.  Is this possible?  I
 know it happens when PHP hits a warning or a fatal error, but is it
 possible to do in a live script?  Or is there a global variable which
keeps
 track of what line in which scripts each execution is at?

 Thanks,
 Peter
 --
-
 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




Re: [PHP-DB] Function that outputs at line xxx

2002-10-23 Thread 1LT John W. Holmes
Yeah, I understand what your asking. I don't know of any method to get the
line number a function was called on, from within the function.

You may have to pass __LINE__ and __FILE__ in your db_query() function, or
whatever it is.

---John Holmes...

- Original Message -
From: Peter Beckman [EMAIL PROTECTED]
To: 1LT John W. Holmes [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Wednesday, October 23, 2002 3:26 PM
Subject: Re: [PHP-DB] Function that outputs at line xxx


 John, that does work!  Thanks.

 The problem is this:

 Database calls are in db.inc.  The script problem occurs in wine.inc.
 True, the SQL is called and executed from db.inc, so __LINE__ and __FILE__
 are correct in a way.  But how do I find out where in the execution of my
 script the other files are in their execution?

 index.php -- calls function in
 wine.inc -- calls function in
 db.inc -- throws SQL error, calls function in
 wine.inc -- which prints error to user nicely and exits

 What I want is when db.inc throws the error and passes the error text to
 the db_error function in wine.inc to look pretty for the user, I want to
 know where the function db_query was called in wine.inc (one level up, the
 script which called the function now running).

 Is this possible?  Does it exist?

 Peter

 On Wed, 23 Oct 2002, 1LT John W. Holmes wrote:

  __LINE__ and __FILE__ should work.
 
  ---John Holmes...
  - Original Message -
  From: Peter Beckman [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Wednesday, October 23, 2002 3:00 PM
  Subject: [PHP-DB] Function that outputs at line xxx
 
 
   Hey --
  
   I'm writing a database error handler function in PHP, and I want it to
  tell
   me at what line in what script the error occurred.  Is this possible?
I
   know it happens when PHP hits a warning or a fatal error, but is it
   possible to do in a live script?  Or is there a global variable which
  keeps
   track of what line in which scripts each execution is at?
  
   Thanks,
   Peter
 
 --
  -
   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] Credit Card Info Cryptography

2002-10-23 Thread 1LT John W. Holmes
When ever I see easy, encrypt, and credit card in the same sentence,
it makes me worry.

Don't store credit card numbers. Charge them once and don't save it
anywhere.

---John Holmes...

- Original Message -
From: Ryan Jameson (USA) [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, October 23, 2002 4:20 PM
Subject: RE: [PHP-DB] Credit Card Info  Cryptography


Since your goal is to encrypt the card number in the database you'll
naturally need a way to decrypt it as well. At that point it seems your
concern is that your database will be compromised. That can be avoided
easily by creating a single private key and using your own algorithm to
encrypt based on that key. The only catch is, if the code that does the
encrypting is compromised, and the database is compromised, then the numbers
are compromised. My basic point is, your need is not the same as what PGP
addresses in that PGP addresses the more difficult problem of passing data
between 2 entities. Your requirement is very simple to address; 1. write a
simple compiled module with an embedded key, 2. keep that key in a safe
place, and 3. write another module to decrypt, all it needs is the key. This
is similar to what was done with DVDs, just don't allow your encryption
algorithms to be compromised. You can put the source code in the same place
as your key, you can use a code scrambler when you compile, and you should
already have your server secure already. Again, my point is, this is easy
because the same entity that encrypts is doing the decrypt. Hope this helps.

 Ryan

-Original Message-
From: Doaldo Navai Junior [mailto:doaldo;triunfo-bsb.com.br]
Sent: Wednesday, October 23, 2002 12:53 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [PHP-DB] Credit Card Info  Cryptography


Suppose I sell some products online and get user's credit card info via SSL
connection. Isn't there any method (free, preferably) of ASSYMETRIC  (Public
key) cryptography I can use with PHP to store this data in a db?? Or is
there any other good option instead of this?

TIA,
Doaldo



--
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] Credit Card Info Cryptography

2002-10-23 Thread 1LT John W. Holmes
 Well.. Isn't that the ideal.

 I agree in theory, however, not all clients are willing to shell for the
 Payment Processor Services if they are just starting ou tin e-commerce
 and don't know what kind of volume to expect.

They aren't that expensive and usually come with all of the scripts you need
to implement it.

 Thery is wonderful, however, practicle must preside.

Hmmm, that's funny. I would think that _security_ must preside. Maybe I run
a different business than you do.

---John Holmes...

 -Original Message-
 From: 1LT John W. Holmes [mailto:holmes072000;charter.net]
 Sent: Wednesday, October 23, 2002 4:33 PM
 To: Ryan Jameson (USA); [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] Credit Card Info  Cryptography


 When ever I see easy, encrypt, and credit card in the same
 sentence, it makes me worry.

 Don't store credit card numbers. Charge them once and don't save it
 anywhere.

 ---John Holmes...

 - Original Message -
 From: Ryan Jameson (USA) [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, October 23, 2002 4:20 PM
 Subject: RE: [PHP-DB] Credit Card Info  Cryptography


 Since your goal is to encrypt the card number in the database you'll
 naturally need a way to decrypt it as well. At that point it seems your
 concern is that your database will be compromised. That can be avoided
 easily by creating a single private key and using your own algorithm to
 encrypt based on that key. The only catch is, if the code that does the
 encrypting is compromised, and the database is compromised, then the
 numbers are compromised. My basic point is, your need is not the same as
 what PGP addresses in that PGP addresses the more difficult problem of
 passing data between 2 entities. Your requirement is very simple to
 address; 1. write a simple compiled module with an embedded key, 2. keep
 that key in a safe place, and 3. write another module to decrypt, all it
 needs is the key. This is similar to what was done with DVDs, just don't
 allow your encryption algorithms to be compromised. You can put the
 source code in the same place as your key, you can use a code scrambler
 when you compile, and you should already have your server secure
 already. Again, my point is, this is easy because the same entity that
 encrypts is doing the decrypt. Hope this helps.

  Ryan

 -Original Message-
 From: Doaldo Navai Junior [mailto:doaldo;triunfo-bsb.com.br]
 Sent: Wednesday, October 23, 2002 12:53 PM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: [PHP-DB] Credit Card Info  Cryptography


 Suppose I sell some products online and get user's credit card info via
 SSL connection. Isn't there any method (free, preferably) of ASSYMETRIC
 (Public
 key) cryptography I can use with PHP to store this data in a db?? Or is
 there any other good option instead of this?

 TIA,
 Doaldo



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



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




Re: [PHP-DB] Manioulating a Flat File

2002-10-18 Thread 1LT John W. Holmes
 Here's what I'd like to know: Is there a PHP function for easily finding
and removing a line from a flat file of data. And, if not, is there a way
to remove a line (or lines) after finding them using fget()?

Easy way to do this is with file(). It'll read the entire file into an
array, with each array element being a line of the file. Use array_search()
to find the line you're looking for, then unset() that element.

//line to look for
$search = ...;

$file = file(file.txt);
$key = array_search($search,$file);
if($key === FALSE)
{ echo line not found; }
else
{ unset($file[$key]); }

//write corrected file back to disk
$fp = fopen(file.txt);
fwrite($fp,implode(\n,$file);
fclose($fp);

Adapt to your needs...

---John Holmes...


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




Re: [PHP-DB] Millions of records in MySQL

2002-10-25 Thread 1LT John W. Holmes
 I remember ages ago that mysql does not properly handle upwards of 10
 million records in a table?

What's this got to do with PHP?

And yes, MySQL will handle it, depending on what you're doing with the data.
There are always alternatives, though.

---John Holmes...


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




[PHP-DB] Re: [PHP] RE: [PHP-DB] Broken Links 2

2002-10-24 Thread 1LT John W. Holmes
You might want to check out netpbm. I've seen that it makes better quality
thumbnails.

Plus, you can include it in your package (if appropriate) and people that
don't have GD installed can use it.

---John Holmes...

- Original Message -
From: Rankin, Randy [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Thursday, October 24, 2002 7:38 AM
Subject: [PHP] RE: [PHP-DB] Broken Links 2


 Thanks to everyone for the help.

 For those interested, I have posted the final code below. It functions
 beautifully with one exception: the resized image quality is rather poor.
I
 am now reading through the php manual and newsgroups for a solution, but
if
 anyone knows how to handle this it would be great to hear from you.

 Thanks again for all your help!

 Randy

 - BEGIN CODE --

 ?
 if( $image_id )
 {
  $sql=SELECT image_bin_data from IMAGES where image_id='$image_id';
  $result=db_query ( $sql );
  $record=db_fetch_object ( $result );
  $image=$record-image_bin_data;
  $new_w=75;
  $new_h=75;
  Header(Content-type: image/png);
  $src_img=@ImageCreateFromString($image);
  $dst_img=@ImageCreate($new_w, $new_h);


ImageCopyResampled($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img)
 ,ImageSY($src_img));
  ImagePng($dst_img);
  ImageDestroy($dst_img);
 };?

 - END CODE --



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




Re: [PHP-DB] Converting database from MS Access to MySQL on Linux

2002-10-29 Thread 1LT John W. Holmes
 Can u pls help in Converting database from MS Access
 to MySQL on Linux. Pls send the code for converting.

http://www.google.com/search?hl=enie=UTF-8oe=UTF-8q=Converting+database+f
rom+MS+Access+to+MySQL+on+Linux

---John Holmes...


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




Re: [PHP-DB] fetching image by url and storing in mysql

2002-10-29 Thread 1LT John W. Holmes
You don't need filesize().

$fp = fopen('address_to_image','r');
while(!feof($fp))
{ $image .= fread($fp,1); }

Something like that will work...

---John Holmes...

- Original Message - 
From: Marcus Fleige [EMAIL PROTECTED]
To: PHP-Mailinglist [EMAIL PROTECTED]
Sent: Tuesday, October 29, 2002 11:29 AM
Subject: [PHP-DB] fetching image by url and storing in mysql


hi there,

i would like to get an image from an web-url and store it into 
mysql-db.

inserting local images or images i upload to the server is no 
problem, but handling urls as images seems quite difficult..

now, for fopen() i need the filesize() of the image, but that command 
does not work on urls...

anyone got an idea how to solve this, perhaps even without writing an 
temporary image to disk? code snippets anyone?

thanks so far,
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] 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] 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] need help with SHOW Colums

2002-10-31 Thread 1LT John W. Holmes
So show us the code that you tried with. This code doesn't do us any good
because it's not causing the error.

---John Holmes...

- Original Message -
From: David Rice [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, October 31, 2002 11:31 AM
Subject: [PHP-DB] need help with SHOW Colums










 mysql_select_db(filterseveuk);

 $query = (  SHOW COLUMNS FROM user );

 $result = mysql_query ( $query ) or die( mysql_error () );

 while ( $row = mysql_fetch_array ($result) ){

 $x = 0 ;

 echo $row[$x] ;

 $x++ ;
 }


 I would like to replace the table name user with a variable $table, that
 wil automatically take the value of the selected table. I have tried many
 times but cannot get the correct sql syntax, it keeps saying
 you have an error in your sql syntax near 'user' line 1 when i try it
with
 $table.
 any ideas??

 thank's,
 dave rice ([EMAIL PROTECTED])

 _
 Choose an Internet access plan right for you -- try MSN!
 http://resourcecenter.msn.com/access/plans/default.asp


 --
 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] Am I doing This Right?

2002-11-01 Thread 1LT John W. Holmes
No, you're doing it wrong.

---John Holmes...

- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, November 01, 2002 2:05 AM
Subject: [PHP-DB] Am I doing This Right?




 ?php

 function war3_replays_submit() {

 if ( isset($replay_file) ) {
 $htmlHead = ;
 pgHead('Shadow Legion :: Warcraft III Replays', $htmlHead);

 // Get Current DB Entrys
 $rDB = mysql_query(select * from war3_replays where 1);

 // Select The Next Entry ID For Newly Uploaded Replay
 $db_count = sizeof($rDB);
 $db_nextid = $db_count + 1;

 // Define Date Dubmitted
 $rDate = date(m-d-y);

 // Define HTTP_POST_FILES Variables
 $rTemp = $HTTP_POST_FILES['replay_file']['tmp_name'];
 $rName = $HTTP_POST_FILES['replay_file']['name'];
 $rSize = $HTTP_POST_FILES['replay_file']['size'];

 // Define Replay Upload DIR and FILE name
 $rFile = $db_nextid._.$HTTP_POST_FILES['replay_file']['name'];
 $rLoc = files/war3-replays/$rFile;

 // DB Query For Inserting File Information into DB
 // DB Layout [ id | user | date | url | size | type | replaytitle
|
 version | replayname | downloads ]
 $q1 = INSERT INTO war3_replays VALUES ( $db_nextid,
 '$replay_submitter', '$rDate', '$rLoc', '$rSize', '$replay_type',
 '$replay_version', '$replay_mapname', 0 ) ;

 // Check If The File Was Moved And Renamed Properly
 if ( @
 !move_uploaded_file($HTTP_POST_FILES['replay_file']['tmp_name'],
$rLoc) ) {
 print 'centerSorry, file not correctly uploaded.';
 pgMid();
 nav('war3-replays-submit');
 pgFoot();
 exit();

 // If File Was Moved And Renames Properly
 } else {

 // Check If The Database Information Was Inserted Properly
 if ( !mysql_query($q1) ) {
 print 'Failed to insert the Replay Information into the
 database.';
 pgMid();
 nav('war3-replays-submit');
 pgFoot();
 exit();

 // If The DB Was Updated Properly... Make The User Happy
!!!
 } else {

 print 'Thank you for submitting your replay
 '.$replay_submitter.'!br
 The view replay will be up within the next few
days.pThanks
 again!/p';

 }
 }
 } else {
 $htmlHead = 'script Language=Javascript type=text/javascript
 src=/files/upload.js/script';
 pgHead('Shadow Legion :: Warcraft 3 Replays',$htmlHead);
 print 'pbr/p
 centerUpload Your Replay
 form enctype=multipart/form-data
 action=?q=war3-replays-submit method=post
 table border=1 cellpadding=0 cellspacing=0 width=400
 borderColor=#99
 tr
 td valign=topcenterfont size=-1Replay File
 /font:/center/td
 td valign=topinput name=replay_file
type=file
 /td
 /tr
 tr
 td valign=topcenterfont size=-1Replay Title
 /font/center/td
 td valign=topinput type=text maxlength=50
 name=replay_title/td
 /tr
 tr
 td valign=topcenterfont
size=-1Category/font:
 /center/td
 td valign=topselect name=replay_typeoption
 value=-Type.../optionoption value=soloSolo/optionoption
 value=ffaFree For All/optionoption value=teamTeam/optionoption
 value=umsUse Map Settings/option/select/td
 /tr
 tr
 td valign=topcenterfont size=-1Map
Name/font:
 /center/td
 td valign=topinput type=text maxlength=50
 size=20 name=replay_mapname/td
 /tr
 tr
 td valign=topcenterfont size=-1War3
Versionbr
 When Replay Recorded:/font/center/td
 td valign=topselect name=replay_version
 id=replay_versionoption value=-Version.../optionoption
value=1.03
 v1.03/optionoption value=1.02v1.02/optionoption
value=1.01v1.01
 /optionoption value=1.00v1.00/option/select/td
 /tr
 tr
 td valign=topcenterfont
size=-1Member/font:
 /center/td
 td valign=topinput type=text maxlength=20
 name=replay_submitter id=replay_submitter/td
 /tr
 tr
 td valign=top colspan=2centertextarea
 name=replay_disc cols=40 rows=7/textarea/center/td
 /tr
 tr
 td valign=top colspan=2centerinput
type=button
 onClick=javascript:uploadCheck(); value=Upload nbsp; input
 type=reset value=Start Over/center/td
 /tr
 /table
 /form
 /center
 pbr/p
 hr width=75% size=1 color=#99
 p/p';
 pgMid();
 

Re: [PHP-DB] mysql_fetch_array() question

2002-11-06 Thread 1LT John W. Holmes
That's not true. You can assign them to different variables and it works
fine.

$r1 = mysql_query(select * from main limit 1) or die(mysql_error());
$r2 = mysql_query(select * from apft limit 1) or die(mysql_error());

$row1 = mysql_fetch_array($r1);
$row2 = mysql_fetch_array($r2);

print_r($row1);
echo brhr;
print_r($row2);

---John Holmes...

- Original Message -
From: Josh Johnson [EMAIL PROTECTED]
To: 'Graeme McLaren' [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, November 06, 2002 1:02 PM
Subject: RE: [PHP-DB] mysql_fetch_array() question


 In my experience, (I haven't checked the docs just yet to figure out
 exactly why), you can only work with one result id at a time. Every time
 you call mysql_query, it resets the result id (I think it frees the
 result id automatically so you can send another query before getting the
 new result id), so even if you store it in two separate variables, it
 will only refrence the last id (which sounds just like what happened in
 your initial post). I think this is limited to a given connection, but
 I'm not sure.

 One of the, I guess you could say, shortcomings of the mysql interface
 in php is that you can only execute one query at a time, and I think
 this odd result id overwrighting that happens is due to that fact (I
 might be wrong, but I think you can execute multiple queries at a time
 with perl's DBI module).

 I hope that makes more sense :)

 -- Josh

 -Original Message-
 From: Graeme McLaren [mailto:mickel;ntlworld.com]
 Sent: Wednesday, November 06, 2002 12:17 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] mysql_fetch_array() question

 Josh, Thank you for reply.  Thank you to everyone else who replied to my
 email also.  I solved the problem shortly after posting my question,
 I've
 now got a massive SQL query which does the trick.

 I was interested when you replied and part of it read:  Just
 remember that you can only work with one mysql result per connection at
 a time.  Can you explain a little more about that please?  I don't
 think I
 fully understand what you mean.

 Cheers,

 Graeme :)

 - Original Message -
 From: Josh Johnson [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, November 06, 2002 12:29 PM
 Subject: RE: [PHP-DB] mysql_fetch_array() question


  I concur with Jason, but if restructuring is out of the question, just
  rearrange your queries like this:
 
  $query = SELECT Name, Address FROM users;
  $result = mysql_query($query);
  while($details = mysql_fetch_array($result)){
  echo Name: $details[Name];
  echo Address: $details[Address];
  }
  $query2 = SELECT EmailAddress From Members;
  $result2 = mysql_query($query2);
  while($details = mysql_fetch_array($result2)){
  echo Email: $Email[EmailAddress];
  }
 
  The results won't come out at the same time, but you could use some
  logic to combine the results into an array by a common factor. Just
  remember that you can only work with one mysql result per connection
 at
  a time. You *may* (untested!) be able to accomplish what you want to
 do
  with two separate connections, but again, this is seriously overkill.
 :)
 
  I'd definitely recommend restructuring your talbes as Jason suggested.
  -- Josh
 
 
  -Original Message-
  From: Jason Wong [mailto:phplist;gremlins.com.hk]
  Sent: Wednesday, November 06, 2002 5:24 AM
  To: [EMAIL PROTECTED]
  Subject: Re: [PHP-DB] mysql_fetch_array() question
 
  On Tuesday 05 November 2002 05:47, Graeme McLaren wrote:
   Hi, Anyone know how I can use two mysql_fetch_array() functions
  similar
   to the code below?  I've tried a few different ways but I keep
 getting
   Resource ID #4.  I need to do this to retrieve an email address from
  one
   table and retrieve details from another.
  
   Cheers for any tips - I'm stumped with this one,
  
   Graeme :)
  
   $query = SELECT Name, Address FROM users;
   $query2 = SELECT EmailAddress From Members;
  
   $result = mysql_query($query);
   $result2 = mysql_query($query2);
  
   while($details = mysql_fetch_array($result) and $Email =
   mysql_fetch_array($result2))
   {
   echo Name: $details[Name];
   echo Address: $details[Address];
   echo Email: $Email[EmailAddress];
   }
 
  Unless I've missed something you're going about this the wrong way.
 For
  what
  you want to do, you should (in general) be able to accomplish it using
  just a
  single query.
 
  What fields do the tables 'users' and 'Members' contain? There should
 be
  a
  field there (like eg. userid) which links the two together. If there
  isn't
  one then you should seriously restructure your tables so that there is
  one.
 
  --
  Jason Wong - Gremlins Associates - www.gremlins.com.hk
  Open Source Software Systems Integrators
  * Web Design  Hosting * Internet  Intranet Applications Development
 *
 
 
  /*
  Cats are smarter than dogs.  You can't make eight cats pull a sled
  through
  the snow.
  */
 
 
  --
  PHP Database Mailing List 

Re: [PHP-DB] MySQL password protection?

2002-11-06 Thread 1LT John W. Holmes
 I was wondering if it is possible to protect my password to the
MySQL-server
 from being in a PHP-script.  Now I can't do that, so everybody who gets to
 see my php-sourcecode also can see my (not protected/not encrypted)
 password.
 How can I change this?

You can't, unless you want to put it in php.ini or a my.conf file...

---John Holmes...


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




Re: [PHP-DB] MySQL password protection?

2002-11-06 Thread 1LT John W. Holmes
Are you sure you can include an encoded file into a non-encoded one?

I had forgotten about this option, but if you can find a worthwhile
compiler/encoder/etc, then that's a solution.

---John Holmes...

- Original Message -
From: SELPH,JASON (HP-Richardson,ex1) [EMAIL PROTECTED]
To: '1LT John W. Holmes' [EMAIL PROTECTED]; William Trappeniers
[EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, November 06, 2002 5:30 PM
Subject: RE: [PHP-DB] MySQL password protection?


 actually you can make a .php file with your connection info, include it in
 your .php files at the top and encrypt that one file (they don't need to
see
 it anyway).  use a php encoder for the file with your login info in it.

 -Original Message-
 From: 1LT John W. Holmes [mailto:holmes072000;charter.net]
 Sent: Wednesday, November 06, 2002 4:16 PM
 To: William Trappeniers; [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] MySQL password protection?


  I was wondering if it is possible to protect my password to the
 MySQL-server
  from being in a PHP-script.  Now I can't do that, so everybody who gets
to
  see my php-sourcecode also can see my (not protected/not encrypted)
  password.
  How can I change this?

 You can't, unless you want to put it in php.ini or a my.conf file...

 ---John Holmes...


 --
 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] checking for 0 results?

2002-11-15 Thread 1LT John W. Holmes
How about:

$sql =  ... ;
$result = mysql_query($sql);
if($row = mysql_fetch_row($result))
{
  do
  {
//process results in $row
  }while($row = mysql_fetch_row($result);
}
else
{ //no results }

This way you don't have to make an extra call to mysql_num_rows() and it
saves you time.

---John Holmes...

- Original Message -
From: Hutchins, Richard [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, November 15, 2002 8:47 AM
Subject: RE: [PHP-DB] checking for 0 results?


 Aaron was right initially:

 $sql = select * from ietsfuckingfriday;

 $result = mysql_query($sql);

 $num_rows=mysql_num_rows($result);

 Somewhere along the line, things got convoluted, but that's how you check
 for 0 rows returned from a query.

  -Original Message-
  From: Snijders, Mark [mailto:Mark.Snijders;atosorigin.com]
  Sent: Friday, November 15, 2002 8:45 AM
  To: 'Aaron Wolski'; 'Jonathan Narong'; [EMAIL PROTECTED]
  Subject: RE: [PHP-DB] checking for 0 results?
 
 
  and how does $sql now gets in touch with $result
 
 
 
 
  Or you can skip a step like:
 
  $sql = select * from ietsfuckingfriday;
 
  if (mysql_num_rows($result) == 0) {
 
  do_something();
 
  } else {
 
  do_anotherthing();
 
  }
 
  Aaron
 
  -Original Message-
  From: Snijders, Mark [mailto:Mark.Snijders;atosorigin.com]
  Sent: November 15, 2002 8:26 AM
  To: 'Jonathan Narong'; [EMAIL PROTECTED]
  Subject: RE: [PHP-DB] checking for 0 results?
 
  $sql = select * from ietsfuckingfriday;
 
  $result = mysql_query($sql);
 
  $num_rows=mysql_num_rows($result);
 
  if ($num_rows==0)echo yesss we did it;
 
 
  (sorry it's friday :-)
 
  almost can go home :--)
 
 
 
  -Original Message-
  From: Jonathan Narong [mailto:jon;binaryillusions.com]
  Sent: vrijdag 15 november 2002 14:23
  To: [EMAIL PROTECTED]
  Subject: [PHP-DB] checking for 0 results?
 
 
  maybe i'm totally not thinking straight right now, but is
  there a way in
  php
  to check if 0 results are returned in a mysql query?
 
  for example, i have a definition database, that has a list of letters
  the
  user clicks on (click on the letter, and all the terms for that letter
  pop
  up).. but for some letters there are no terms. so i just
  wanted to echo
  out
  a simple no terms message or something. in any case, i need to check
  if
  there are no results from a mysql query (an error won't be returned).
 
  thanks ..
 
  -jon
 
 
 
  --
  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



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




Re: [PHP-DB] HTML Forms question...

2002-11-19 Thread 1LT John W. Holmes
 OK.  If I am using the POST method and the checkbox 'name' for all
 of the checkboxes is 'system', how do I access the results?  I am
 researching on the PHP site trying to figure out what this array is, and
how
 I access this if the index name is the same for all elements.  I am hoping
 that this data will be in an array and I can simply loop through the
 contents of the array.  If this data is stored in a hash (Perl word for
this
 type of array, not sure if it's the same in PHP), how do I access this
data
 since the index for every element would be the same?
 I am SURE that I am probably missing some important conceptual
 issues here, but still learning as I go.  Unfortunately, this probably
means
 that I will be completely rewriting this application at least once in the
 future.  Oh well, live and learn.  Thanks again for the help.

If you have multiple checkboxes with the same 'name' then you should name
then with brackets, [], such as 'system[]'. This will tell PHP to make the
results an array when the form is submitted.

For any of the 'submit[]' checkboxes that are checked, they will be present
in PHP array on the processing page. Those unchecked will not be present.

Say you have the following.

input type=checkbox name=submit[] value=1One
input type=checkbox name=submit[] value=2Two
input type=checkbox name=submit[] value=3Three

If the method on your form is POST, and the user checks One and Three, then
you'll have the following values in PHP on the ACTION page of the FORM.

$_POST['submit'][0] == 1
$_POST['submit'][1] == 3

From that data, though, there's no way to tell that checkbox Two was not
checked, unless you go through and check all of the values. That's fine for
small forms, but a hassle for large ones.

You could also name your checkboxes like this:

input type=checkbox name=submit[1] value=1One
input type=checkbox name=submit[2] value=2Two
input type=checkbox name=submit[3] value=3Three

and if the user checks one and three again, you'll get

$_POST['submit'][1] == 1
$_POST['submit'][3] == 3

Hopefully that clears some things up. If you have any other questions, just
ask.

---John Holmes...


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




Re: [PHP-DB] formatted text, php and mysql

2002-11-19 Thread 1LT John W. Holmes
Have you looked at the nl2br() function?

echo trtd . nl2br($content) . /td/tr;

That may give you the output you're looking for.

---John Holmes...

- Original Message -
From: Griffiths, Daniel [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, November 19, 2002 11:50 AM
Subject: [PHP-DB] formatted text, php and mysql


Hi, hopefully someone can help me out with this..

I need to be able to copy text from a document, keeping carriage returns and
white space chars, into a database and output the same to a web page.
I have a field in a mysql table of type 'longtext' into which i can load
text and keep the white space and carriage return characters intact.
I can output this field to a page using php in a similarly formatted way by
using the pre tag in an echo statemnet : -

echo trpre$content/pre/tr;

however, by using the pre tag all individual lines of text are printed on
a single line and the sizing of my table is ignored, i.e. the text won't
wrap. pre width=20 for example doesn't work.

Is there a 'proper' way of doing something like this with php without
relying on printing out html tags with the string?

cheers

Dan

--
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] retriving values from two tables

2002-11-19 Thread 1LT John W. Holmes
 Hi all,

 I am karthik. I am using using php with mysql. i am stuck with a qury. Pls
hep me out.

 i have two tables. Here is table with sample data

 Table Name : Links

 linkid header
 1   yahoo.com
 2   google.com
 3   php.net
 4   sai.org
 5   mysql.net

 Table Name : subLinks

 linkid childid
 1 2
 3 5
 4 3

 I want to fetch the linkid and header from links table based on condition
that i select only the main links. which are not under any link

 In our example it is

 1 and 4

 Pls help out with the query..Its Urgent

 Thanks

 Jai Sairam

 Karthikeyan.S

How about:

SELECT l.linkid, l.header FROM Links l LEFT JOIN subLinks s ON l.linkid =
s.childid WHERE s.childid IS NULL

I think that'll work.

---John Holmes...


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




Re: [PHP-DB] INSERT question...

2002-11-20 Thread 1LT John W. Holmes
 Try... $query = INSERT INTO accounts (accnts,timestamp)
 VALUES(''.$accnts[0].'','TIMESTAMP(10)');

 Might work?

 Aaron


For the OP, you don't really want to insert the text TIMESTAMP(10) into a
column, do you? If you want the current 10-digit timestamp, then you can
just use NOW() or CURRENT_DATE, so long as your column is declared with a
width of 10. In fact, if it's a timestamp, you don't need to do anything,
it'll be updated with the current time upon insert. so you could probably
just do this:

$query = INSERT INTO accounts (accnts) VALUES (.$accnts[0].);

---John Holmes...


 -Original Message-
 From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED]]
 Sent: November 20, 2002 2:16 PM
 To: '[EMAIL PROTECTED]'
 Subject: [PHP-DB] INSERT question...

 I have an INSERT statement that I cannot quiet get working.  The
 table that this data is being put into has 7 columns, but I only care
 about
 putting in the data from the first two columns at this time.  The first
 column is an array element, and the second column needs to be a
 timestamp.
 Here is the INSERT statement:

 $query = INSERT INTO accounts VALUES('.$accnts[0].', 'TIMESTAMP(10)',
 , ,
 , ,);

 Here is the error being displayed on the web page:

 You have an error in your SQL syntax near ' , , ,)' at line 1
 Thanks in advance for the help.

 Scott Nipp
 Phone:  (214) 858-1289
 E-mail:  [EMAIL PROTECTED]
 Web:  http:\\ldsa.sbcld.sbc.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



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




Re: [PHP-DB] INSERT question...

2002-11-20 Thread 1LT John W. Holmes
 OK.  This sounds great, but now I am getting a completely different
 error message.

 You have an error in your SQL syntax near '-sys) VALUES('sn4265-turner')'
at
 line 1

 Here is the INSERT statement:

 $query = INSERT INTO accounts (id-sys) VALUES('.$accnts[0].');

 Do I have to rename the column?  I would rather not if I can avoid
 it.  If I must, is this a problem with PHP or MySQL not understanding '-'
in
 a column name?  Thanks again.

Try putting backtics (not single quotes) around the column name.

$query = INSERT INTO accounts (`id-sys`) VALUES ('.$accnts[0].');

if that don't work, you'll have to rename the column.

---John Holmes...


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




Re: [PHP-DB] INSERT question...

2002-11-20 Thread 1LT John W. Holmes

  $query = INSERT INTO accounts (`id-sys`, rtime) VALUES('.$accnts[0].',
 'NOW()');

Remove the quotes around NOW(). It's a function, not a string.

---John Holmes...


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




Re: [PHP-DB] autoupload

2002-11-22 Thread 1LT John W. Holmes
 I am currently creating a php/mysql site for a client.  Many of the
 customers who will be using this site also use a vb/access program to
store
 a lot of the same data.  The client asked me last night if we could write
an
 app that would run on the customers machine that would routinely take data
 from the access db on their machine and automatically upload it to our
mysql
 site.  Any ideas on how this can be accomplished?

You'd have to write a little vB or C program to do it, unless you're going
to install PHP on every computer.

---John Holmes...


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




Re: [PHP-DB] Re: MySQL/PHP Iterative Tree

2002-11-26 Thread 1LT John W. Holmes
You may want to check out using Nested Sets instead of a Parent-Child-ID
system. I think it's an easier system for representing hierarchies. Here is
a good article on the system:

http://searchdatabase.techtarget.com/tip/1,289483,sid13_gci537290,00.html

Google for Nested Sets +sql or something and there are more articles out
there. It's sort of confusing in the beginning. If you have any questions,
let's take it off the PHP list.

---John Holmes...

- Original Message -
From: David Elliott [EMAIL PROTECTED]
To: Adam Voigt on PHP-DB [EMAIL PROTECTED]
Sent: Tuesday, November 26, 2002 9:41 AM
Subject: [PHP-DB] Re: MySQL/PHP Iterative Tree


 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Hello Adam

 On 26 November 2002 at 08:25:22 -0500 (which was 13:25 where I live) Adam
 Voigt emanated these words of wisdom

  ... 

  Ok, and I am using this structure to make a kind of drill down
  structure, so the top level would be where parentid = '0', then
  you take those id's and select from this table where parentid is
  equal to those id's, and now your starting to navigate through
  the tree, and so on.

  Now, the real question, I have found a Javascript menu script which
  will let users of the site click on it, and then click on the submenu
  and down and down through all the level's that might dynamically exist,

 Be careful of the size and the time it takes to build a big tree.

  but I can't for the life of me figure out how to recursively get the
  name and id for each row (which is what I need to build the menu and
  make link's out of each item), for as many sublevel's as there might be
  (infinite). Am I missing something, is there a simple logical way to do
  this recursively? Or if there's a semi-complex way, anyone got a script
  example? I'd very much appreciate it.

 This is not much help but have done something like that in MSSQL with
stored
 procedure (about 120 to 150 lines of SQL).

 The logic went something like.

 get all top level
 put into a temptable_1
 go through temptable_1
   put line into temptable_2 noting level
   add on any children for line into temptable_2
 next line of temptable_1
 copy temptable_2 to temptable_1
 keep going through temptable_1 until there is no more children at last
level

 I also used a separate table for the links this way it is easier to go
both
 up and down the tree.

 What would be nice is to do it dynamically and display only the tree that
 you need and just get the data for the children when needed. eg like
MSDSon
 M$ site

 - --
  TTFN, ___
   David   |David  Elliott|   Software Engineer
|
  _| [EMAIL PROTECTED] | PGP Key ID 0x650F4534
|
 | I am Barney of Borg...Sesame Street will be assimilated.
|

 -BEGIN PGP SIGNATURE-
 Version: 6.5.8ckt http://www.ipgpp.com/

 iQA/AwUBPeOIC/mK8eZlD0U0EQI8YQCdEKtpYBkVNmLGYEs2xt3RKBoh1A0An2FG
 KzmAxhrABe/7JZxw3mvmYkaJ
 =xdTm
 -END PGP SIGNATURE-


 --
 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] Newline help...

2002-12-05 Thread 1LT John W. Holmes
HTML doesn't render newlines, only BR. Look at your HTML source code and
the newlines are there.

or,

if you're on windows, use \r\n for newlines.

---John Holmes...

- Original Message -
From: NIPP, SCOTT V (SBCSI) [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, December 05, 2002 11:28 AM
Subject: [PHP-DB] Newline help...


 I must be stupid, because I cannot for the life of me figure out why
 I am not getting newlines from some very simply 'echo' statements.  Here
is
 the portion of the code below, and I am getting everything run together on
a
 single line:

 ?php do {
   echo $list['id-sys'] . \n;
   $sys = split('-', $list['id-sys']);
   echo $sys[1]\n;
   } while ($list = mysql_fetch_assoc($result));


 I am truly stumped by this.  It is quite frustrating that something
 as simple as a newline can misbehave.  I have been searching for this on
the
 PHP site, newsgroups, and in a couple of books I have and yet I am still
 stumped.  Help please.  Thanks.
 Scott Nipp
 Phone:  (214) 858-1289
 E-mail:  [EMAIL PROTECTED]
 Web:  http:\\ldsa.sbcld.sbc.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] MySQL Array

2002-12-05 Thread 1LT John W. Holmes
I think he meant that he is only pulling one column, i.e. field1 with each
mysql_fetch_array and he wants that in four columns.

$c = 1;
echo tr;
while($ar = mysql_fetch_array($result))
{
  echo td{$ar['field1']}/td;
  if(($c % 4) == 0) { echo /trtr; }
}

You'll have to account for incomplete rows and clean up the output, but
hopefully that gives you an idea.

---John Holmes...

- Original Message -
From: Ryan Jameson (USA) [EMAIL PROTECTED]
To: Art Chevalier [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Thursday, December 05, 2002 3:05 PM
Subject: RE: [PHP-DB] MySQL Array


while ($ar = mysql_fetch_array($rs))
  echo trtd. $ar['field1']./tdtd.$ar['field2']./td/tr;


Make sense?

-Original Message-
From: Art Chevalier [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 05, 2002 12:44 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] MySQL Array


Hello,

I am pulling one column out of a MySQL table in an array.  I want to place
each element into a HTML table 4 rows across.  I am currently doing this
with the mysql_fetch_array() function. How can I pull out 4 array elements
in one pass through a while loop?

Thanks

Art Chevalier



--
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] mileage calculator

2002-12-06 Thread 1LT John W. Holmes
 I know a lot of sites, such as car dealerships, where you can put in your
 zip code and then you can search for cars within 50,100, etc miles of your
 house.  How is this done?  I have a site that we want to implement a
feature
 like this.  What is stored in the db?  Can I simply write a function using
 zipcodes to find distance?  I know you can use latitude and longitude.

Do a search on Google. You can buy databases that have zip codes and their
long/lat coordinates. You can then use an equation to calculate distances
and find zip codes that are close to another one.

---John Holmes...


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




Re: [PHP-DB] Return 1 instance of each unique record?

2002-12-06 Thread 1LT John W. Holmes
 How do I get MySQL to summarize a query so that I receive only 1 instance
 per similar record.  I.E. if you have 10 records with name Smith and 5
 records with Barney, etc, that it would return 2 records instead of 15.

This should be on a MySQL list...

SELECT * FROM tbl WHERE ... GROUP BY column

The key is the GROUP BY part... check the manual for more of an explanation.

---John Holmes...


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




Re: [PHP-DB] Update Query Help...

2002-12-10 Thread 1LT John W. Holmes
 $tmp = $_POST['sbcuid'].-.$_POST['system'][$a];
 $update = UPDATE accounts SET atime='NOW()' WHERE
 \id-sys\='.$tmp.';
 echo $update;
 $result1 = mysql_query($update, $Prod) or die(mysql_error());
 echo mysql_affected_rows();

Try:

$update = UPDATE accounts SET atime=NOW() WHERE id-sys='$tmp';

NOW() is a function, don't enclose it within quotes and make it a string.
You don't put quotes around column names, either, only string values.

---John Holmes...


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




Re: [PHP-DB] Update Query Help...

2002-12-10 Thread 1LT John W. Holmes
 I have definitely isolated the problem.  If I change the column name
 that the match is being performed on from 'id-sys' to 'id_sys' I can
execute
 the query without having to worry about quoting the column name and
 everything works.  I think that I am just going to leave the column name
 changed and take this as a lesson never to use '-' in a column name again.
 Thanks again for the help.  Maybe we all learned something from
 this.

If you want to use a column name like id-sys, which you shouldn't, though,
as you've learned, you can enclose it in backticks, like `id-sys`. Note that
those are not single quotes, they are backticks, to the left of the number 1
key.

---John Holmes...


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




Re: [PHP-DB] Still having problems...?!

2002-12-10 Thread 1LT John W. Holmes
 Warning: open(/tmp\sess_1df563d6d8c8b4b16534c438251e7107, O_RDWR) failed:
 No such file or directory (2) in E:\Webroot\tutorial\page1.php on line 3

 Warning: open(/tmp\sess_1df563d6d8c8b4b16534c438251e7107, O_RDWR) failed:
 No such file or directory (2) in Unknown on line 0

 Warning: Failed to write session data (files). Please verify that the
 current setting of session.save_path is correct ***(/tmp)*** in
 Unknown on line 0

 This is the php.ini line; session.save_path = e:\webroot\tmp, and i have
 created the directory tmp in that location. i tried both \'s and /'s for
 that line, not sure as to whether they do any difference or not, and
 restarted the server service both times.

I use c:/path/to/dir in my php.ini.

Are you sure you're editing the right php.ini? Load up a page with just

? phpinfo(); ?

in it and look at the first block. It will tell you the Configuration File
(php.ini) Path that php is looking at. If it is just a directory, and
doesn't list a php.ini file, then that's the directory where php expects to
find php.ini, but it's not there. If there is a php.ini listed, make sure
that's the one your editing.

---John Holmes...


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




Re: [PHP-DB] newbie - last_insert_id() with mysql

2002-12-12 Thread 1LT John W. Holmes
 mysql_insert_id() is a PHP function, not a MYSQL function.  You are also
 missing a close quote on your insert string.  So you have to do it like
 this:

Correct, but LAST_INSERT_ID() is a MySQL function which is what he's
using...

 $sql2 = insert into acl (adminId,transportId,securityId) values
('$userid',.last_insert_id().,'1');

So, no, you're trying to use a MySQL function here in PHP code. The original
syntax was correct.

 $lastid = mysql_insert_id();
 $sql2 = insert into acl (adminId,transportId,securityId) values
('$userid',.$lastid.,'1');

 which is the same as:

 $lastid = mysql_insert_id();
 $sql2 = insert into acl (adminId,transportId,securityId) values
('$userid',$lastid,'1');

Both of those are correct, too, if you want to use the PHP function.

  $sql1 = insert into transport (domain,transport) values
  ('$domain','$transport');
  $sql2 = insert into acl (adminId,transportId,securityId) values
  ('$userid',last_insert_id(),'1';
 
  mysql_query($sql1);
  mysql_query($sql2);

You're missing a closing paranthesis on the end of the second SQL statement.
That is probably what's causing your error. In the future, use mysql_error()
to find out why it's failing...

mysql_query($query) or die(Error in $query:  . mysql_error());

---John Holmes...


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




Re: [PHP-DB] bulk miorting rows into mysql db

2002-12-13 Thread 1LT John W. Holmes
 I have a few hundred rows of data to import into a mysql db. Its currently
 tab separated.

 What's the most straight forward way (ie i dont want to enter it line by
 line) of doing a bulk import?

 I have full admin rights to my dev server. Is there a method or software
app
 that people can recommend to me.

If the columns match your database exactly, then you can use LOAD DATA
INFILE command.

If not, then you can write a PHP script to read each line and format it into
an INSERT query.

---John Holmes...


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




Re: [PHP-DB] Listing A Certain # Range

2002-12-16 Thread 1LT John W. Holmes
 LIMIT 5,10
 LIMIT 10,15

 Something like that should work.

Not quite. LIMIT n,m where n is the starting point and m is how many rows
you want returned.

LIMIT 5 or LIMIT 0,5
LIMIT 5,5
LIMIT 10,5
etc...

---John Holmes...

 Im using MySQL and PHP 4.2.3 on Apache and Mandrake Linux, I was
 wondering how to get PHP to list let says row 5 - 10 from a database, I
 read the MySQL manual and all I could find is LIMIT 0,5 to list just the

 first 5, but I dont know how to make that list 5 - 10 or 10 - 15. Any
 help would be appreciated.


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




Re: [PHP-DB] Updating data on remote server

2002-12-16 Thread 1LT John W. Holmes
Do you have root access to the internet MySQL server? The easiest way to do
this would be to use replication, I think. It doesn't sound too difficult to
set up and it would do all of the updating for you. Is that an option? If
not, then you can enable binary logging (I think that's what it is) in your
local MySQL server and maybe use that log to update the two servers (this is
what replication does for you, though). Last option, beside what you're
doing, is doing a dump of the data and importing it on the Internet server
(or, again if you have access, just copy the mysql/data/database_name folder
from one to the other, but you have to shut down MySQL temporarily to do
that).

---John Holmes...

- Original Message -
From: Dmitry Murashev [EMAIL PROTECTED]
To: DB-PHP [EMAIL PROTECTED]
Sent: Monday, December 16, 2002 4:04 PM
Subject: [PHP-DB] Updating data on remote server


Hello everybody!

I've got a very intersting task for myself and I hope somebody can help me
to solve it.

I have a big site in the Internet that stores many information in several
tables. The site is PHP and MySQL based. I have a copy of this site on my
local server. Any data for the site I add and update on the local server and
only then I upload it on my site in the Internet. The task is what is the
best way to update my data on remote site? What programms in PHP should I
write?

Now I'm trying to use two ways (They can seem too boring)

1. I write all MySQL commands that executes on the local server into
separate table. These commands are DELETE, UPDATE and ADD. Every record has
(in field 'date') a time when it was executed. So from time to time I copy
all commands to a text file, then copy file to the remote server and execute
them there.
2. Every table has the field 'date'. When any infromation is UPDATEd or
ADDed (not DELETEd) the time is writes into necessary row. So the time in
field 'date' shows when the information was updated or added. Again from
time to time I just copy commands (according to the time I select) to a text
file, then copy file to the remote server and execute them there. In this
case I don't know how the remote site will know what data was deleted on the
local site.

The problem is that these two methods are not proffesional written and have
many lacks and the text files becomes too big for uploading (0.5 - 1 Mb).

Could anybody give me any suggestions or links to related resources please?
What methods to update data on the remote server from the local one are?


Thanks,
Dmitry Murashev



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




Re: [PHP-DB] Inserting URL into table

2002-12-19 Thread 1LT John W. Holmes
 I'm trying to insert a URL into a char field.

 MySQLFront punts out this error with my compiled query:

 You have an error in your SQL syntax.  Check the manual that corresponds
to
 your MySQL server version for the right syntax to use near '','Yahoo
 mail','httpNULL/www.yahoo.co.uk/')'

 Well there's nothing helpful in the MySQL Manual so can someone point me
in
 the right direction.

 I am expecting that some form of encoding should take place - but which
one?

Probably an addslashes() issue, but what's your whole query look like?

---John Holmes...


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




Re: [PHP-DB] trees in MySQL

2002-12-19 Thread 1LT John W. Holmes
If you don't know how many nodes you're going to have and the amount of
branches under each node, then that's the only way to do it.

However, if you can define those numbers, you can use something like the
following. A manager would have 50 numbers, for example. So, rather than
counting through the tree to determine left and right pairs, the first
manager simply has left:1 and right:51. Now, a section leader (SL) under him
has 10 numbers (so a manager can have 5 section leaders). The first section
manager would have 2 - 11, the second 12 - 21, etc. Now each section leader
can have an employee (E) that gets an adjacent left and right pair (so they
are a leaf with nothing under them).

Something like this, hopefully the formatting remains.

Manager
150
  |
 /\
SL SL
2  1112-21
   | |
  /   \ E
E  E  13-14
3-4 5-6

So if you count around the tree, you see it still goes in order, but it
leaves holes where you can fill people in.

So, if you can assign specific limits like that, to add a new section leader
under this manager, you simply select the largest right number for the
current section leaders, which will be 21, and add 10 to that, so the new
section leader would have numbers 22-31.

  Manager
  150
|
  / \
  / |\
SL  SL SL
2  1112  21   22  31
   | |
/ \ E
EE13-14
3-4 5-6

That's probably confusing, but it works on paper for well defined trees. I
can explain in more detail if you're interested, but I don't know if it
applies to your situation or not.

---John Holmes...

- Original Message -
From: José Moreira [EMAIL PROTECTED]
To: Php-Db (Correio electrĂłnico) [EMAIL PROTECTED]
Sent: Thursday, December 19, 2002 11:45 AM
Subject: [PHP-DB] trees in MySQL


 hello im implementing a portal and im choosing between the 'Nested Set'
and
 'Adjacency Lists tree' models.
 http://users.starpower.net/rjhalljr/Serve/MySQL/traer.html


 im perfectly aware of the 'Adjacency Lists tree' model how-to and I am
 studying the 'Nested Set', example follows :

 CREATE TABLE LanguageTree (

   Language VARCHAR(255) PRIMARY KEY
 , Parent VARCHAR(255)
 , Lft LONG
 , Rgt LONG
 , INDEX idxLft (Lft)
 , INDEX idxRgt (Rgt)
 ) Comment = Related languages;


 A[1 12]
   /  \
 /   \
 B[2 3]   C[4 11]
/  \
   /\
   D[5 8] F[9 10]
  |
   E[6 7]


 my doubt is that if i want to insert a new node, for example 'G' under 'A'

 A[1 12]
   / | \
 /  \
 B[2 3]G[]   C[4 11]
/ \
   /   \
   D[5 8] F[9 10]
  |
   E[6 7]


 i have? to update almost every left,righ fields after that node, resulting
 in a website performance downgrade 


 help? even if thjats the only way, how can i do it? perhaps im getting it
 wrong ...


 best regards


 José Moreira
 TEGOPI S.A.
 http://www.tegopi.pt









 --
 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] Help Needed

2002-12-26 Thread 1LT John W. Holmes
 Everything's perfect.. except my browser keep blank when I run my php
 files...

No, obviously it's not perfect because it's not working at all. Your page is
blank because ? phpinfo() ? will be evaluated as an unknown HTML tag and
come out blank.

Find another tutorial that discusses how to set up what you want and follow
it step by step.

---John Holmes...

 I juz installed a RedHat 8.0 on my machine.
 But then I have a problem in configuring Apache 2.0.4 to use PHP 4.20..
 It's preety weird.. coz there's nothing shown up in the browser when I
 run phpinfo(); or even a simple 'helloworld' code.
 When I view the source by right-clicking.. it shows the php code.. but
 why it didn't show anything in the browser ???
 
 I've done all the procedures according to manual. but not working at
 all.

 check httpd.conf or something similar  make sure correct .php parsing


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




Re: [PHP-DB] php/mysql

2002-12-26 Thread 1LT John W. Holmes
 I don't know where the error lays, in php, mysql or red hat 8.
 But, I can't get my databased php-apps to work.
 I am trying to run:

 apache_1.3.27
 php-4.2.3
 mysql-3.23.53
 redhat 8.0

 What happens is that apache and php work nicely, but my apps cannot
connect
 to mysql. In IRM I get can not connect to database, and in phpgroupware I
 get the the thing up and running, but can't add anything to the tables.
 E.g. I can't add a to-do even if the routine runs normally, nothing is
added
 in the db table.

 I saw a suggestion on a mysql mail list suggesting symlinking mysql.sock
to
 /tmp but that does no difference.

Can you connect to MySQL from the command line? With what user? Are you sure
you are using a valid login and password in your programs?

---John Holmes...


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




Re: [PHP-DB] php/mysql

2002-12-26 Thread 1LT John W. Holmes
  I don't use RedHat, but I've heard (possibly here) that the RH PHP
  RPM does not properly install MySQL support by default and that
  there's something like php_mysql.rpm (or something similar) that
  needs to be installed as well? Does any of that sound familiar to
  anyone?
 
 I've heard something like that as well, which is why I've compiled php and
 apache from source. Would compiling mysql from source as well help I
 wonder...

It seems like you'd get an unknown function error if PHP wasn't compiled
correctly with MySQL support, though.

Are you sure you're programs are connecting with the host you think they
are? Maybe they are trying to connect with user@computer_name and you've got
it set up as user@localhost in the mysql.user table??

Grasping at straws...

---John Holmes...


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




Re: [PHP-DB] php/mysql

2002-12-26 Thread 1LT John W. Holmes
  I don't know where the error lays, in php, mysql or red hat 8.
  But, I can't get my databased php-apps to work.
  I am trying to run:
 
  apache_1.3.27
  php-4.2.3
  mysql-3.23.53
  redhat 8.0
 
  What happens is that apache and php work nicely, but my apps cannot
  connect
  to mysql. In IRM I get can not connect to database, and in phpgroupware
I
  get the the thing up and running, but can't add anything to the tables.
  E.g. I can't add a to-do even if the routine runs normally, nothing is
  added
  in the db table.
 
  I saw a suggestion on a mysql mail list suggesting symlinking
mysql.sock
  to
  /tmp but that does no difference.
 
  Can you connect to MySQL from the command line? With what user?

 mysql -u ADMIN -pADMINPW irm
 mysql -u ADMIN -pADMINPW phpgroupware

 both work (command line access). Setting the user in IRM as ADMIN and the
 password to ADMINPW I get Cannot connect to database.
 I once desperately thought I had forgotten to configure php --with-mysql
so
 I recompiled. No improvement.

What is IRM? What's the line with mysql_connect() look like? Make sure there
is no @ in the line, as in @mysql_connect, which will suppress any normal
error messages.

---John Holmes...


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




Re: [PHP-DB] Help about printing an integer variable

2003-01-06 Thread 1LT John W. Holmes
You can specify a padding character and length with printf

www.php.net/printf

---John Holmes...

- Original Message -
From: MartĂ­n AgĂŒero [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, January 06, 2003 9:52 AM
Subject: [PHP-DB] Help about printing an integer variable


I need to print an integer varible using this format '', I mean it
always have to show four digits.  How can I do that?

Thanks,

Martin.


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




Re: [PHP-DB] insert form data

2003-01-08 Thread 1LT John W. Holmes
 I am able to get the query to work by itself but it will not work using
 the if (isset ($submit)) and NO errors are outputting...nothing.  

That's because $submit is not set
 
 Any suggestions would be greatly appreciated.  I havnt even gotten to
 the form variables yet...and yes, my globals are turned on (at least for
 now).  Are there error display holes that I have missed?
 
 What am I doing wrong ???...
[snip]
 input type=submit value=Submit

Name your form element, so $submit will be set.

input type=submit name=submit value=Submit

---John Holmes...

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




Re: [PHP-DB] insert form data

2003-01-08 Thread 1LT John W. Holmes
 When I post to my next page in the survey in the form action, instead of
 this page, the data doesnt go into the database.  
 
 Does anyone know a way around this other than rewriting all the pages
 into one page?

Use sessions or hidden form fields to transfer the data between pages.

---John Holmes...

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




Re: [PHP-DB] insert form data

2003-01-08 Thread 1LT John W. Holmes
Well change/set the ACTION attribute of your form, then, if that's where you
really want to go. The second page should check for

if(isset($submit))

and process the data. Or do it in one page and redirect with header()
(before _any_ output) after the processing is complete.

---John Holmes...


 Actually, I dont need these variables in the rest of the form, I just
 need to go to the next page...Like a hyperlink on the submit button
 maybe ???

 Seems like I've seen that...

 Mignon


 On Wed, 2003-01-08 at 14:12, 1LT John W. Holmes wrote:
   When I post to my next page in the survey in the form action, instead
of
   this page, the data doesnt go into the database.
  
   Does anyone know a way around this other than rewriting all the pages
   into one page?
 
  Use sessions or hidden form fields to transfer the data between pages.
 
  ---John Holmes...



 --
 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] HTML tags in auth.php script

2003-01-10 Thread 1LT John W. Holmes
 Hello every one. I am still learning how PHP works. Can some one answer
 this
 for me please.

 This piece of code here works fine ONLY without the HTML tags  (The
 first line and the last lines in the code).
 The moment I add these lines I get the following error:  (By the way I
 don't get these errors if I execute this script on UNIX)

 Warning: Cannot add header information - headers already sent by (output
   started at c:\phpdev\www\public\auth.php:2) in
   c:\phpdev\www\public\auth.php on line 4

   Warning: Cannot add header information - headers already sent by
   (output started at c:\phpdev\www\public\auth.php:2) in
   c:\phpdev\www\public\auth.php on line 5
   Text to send if user hits Cancel button

 Basically what I am trying to do is to add
 this line to get a background image for this page auth.php  in my
 images folder.
 body background=\../pics/creme_swirl.jpg\  text=\green\
 link=\blue\ alink=\red\ vlink=\red\


 HTML
 ?php
  if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm=My Realm');
header('HTTP/1.0 401 Unauthorized');
echo 'Text to send if user hits Cancel button';
exit;
  } else {
echo pHello {$_SERVER['PHP_AUTH_USER']}./p;
echo pYou entered {$_SERVER['PHP_AUTH_PW']} as your
 password./p;
  }
 ?
 /HTML

Absolutely anything outside of the ?php and ? tags is considered output to
the browser. In order to use the header() function, you can't have any
output before the call to header().

If you want to add that text, then add it in where there is already output
in the file. Add it to the echo for the Text to send if ...  or where your
Hello ...  message is at.

---John Holmes...


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




Re: [PHP-DB] blob

2003-01-07 Thread 1LT John W. Holmes
 I want to be able to load PDFs into mysql DB, but I'm not very familiar
with
 the blob data type?
 Can someone point me on the right direction how to do this?

Use fopen() in binary mode and fread() to read the file into a string, then
insert it into the
database as you would any other variable in any other column. Make
sure you have a large enough BLOB to support your file sizes.

---John Holmes...


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




Re: [PHP-DB] Date math functions...

2003-01-15 Thread 1LT John W. Holmes
[snip]
 if ($dateDiff == 3) {
 mysql($DBName,UPDATE Balances SET CompEarned=CompTaken+8 WHERE
 said='$said') or die(mysql_error());
 mysql($DBName,INSERT INTO Log VALUES('DATE_ADD($StopDate,
 INTERVAL 1 DAY','',1,2,'$CalendarDetailsID')) or die(mysql_error());

 My big question is about using the DATE_ADD MySQL function inside
 the INSERT statement.  Is this allowed?  If it is allowed, is it a bad
idea
 for some reason?  Is there a better way of doing this?  Thanks in advance.

Sure, that's allowed. You have $StopDate in PHP, so you could do it with
some math in PHP, also, but then you'd have to worry about the end of
months, years, etc, whereas DATE_ADD will do this for you.

---John Holmes...


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




Re: [PHP-DB] Date math functions...

2003-01-15 Thread 1LT John W. Holmes
 [snip]
  if ($dateDiff == 3) {
  mysql($DBName,UPDATE Balances SET CompEarned=CompTaken+8 WHERE
  said='$said') or die(mysql_error());
  mysql($DBName,INSERT INTO Log VALUES('DATE_ADD($StopDate,
  INTERVAL 1 DAY','',1,2,'$CalendarDetailsID')) or die(mysql_error());
 
  My big question is about using the DATE_ADD MySQL function inside
  the INSERT statement.  Is this allowed?  If it is allowed, is it a bad
 idea
  for some reason?  Is there a better way of doing this?  Thanks in
advance.

 Sure, that's allowed. You have $StopDate in PHP, so you could do it with
 some math in PHP, also, but then you'd have to worry about the end of
 months, years, etc, whereas DATE_ADD will do this for you.

 ---John Holmes...

Wait... just noticed your syntax error. Don't enclose the function in single
quotes, otherwise you're trying to insert a string.

Should be:

... VALUES (DATE_ADD($StopDate,INTERVAL 1 DAY), ...

---John Holmes...


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




Re: [PHP-DB] Mail() and replies

2003-01-15 Thread 1LT John W. Holmes
 Is there any way to receive mail via PHP?

 What I am interested in doing is creating a double opt-in e-mail list
 whereby someone can subscribe to an e-mail service via an on-line form.
Upon
 doing so, they would get a confirmation e-mail. Replying to this e-mail
 would confirm the subscription and add the sender's e-mail address to the
 database (MySQL).

 Doable?

Sure, there are a couple modules in PHP that'll let you access and read your
POP3 or IMAP email. I'm sure there are some classes on phpclasses.org that
can be modified to your needs.

There are programs out there that do this already, too, if you don't want to
re-create the wheel.

---John Holmes...


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




Re: [PHP-DB] Date math functions...

2003-01-15 Thread 1LT John W. Holmes
   mysql($DBName,UPDATE Balances SET CompEarned=CompTaken+8 WHERE
   said='$said') or die(mysql_error());
   mysql($DBName,INSERT INTO Log VALUES(DATE_ADD($StopDate,
   INTERVAL 1 DAY,'',1,2,'$CalendarDetailsID')) or die(mysql_error());

 Actually this is generating another error.  Now, without the single
 quotes I am getting the following error:

 Column 'StartDate' cannot be null

 It looks like for some reason the DATE_ADD is returning a NULL
 value.  Any more ideas?

Are you sure $StopDate has a value and is in the right format? Echo out your
query to the screen when you get an error, so you can look for obvious
mistakes.

Is this just example code?  You're using a function called mysql(), which
isn't standard.

---John Holmes...


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




Re: [PHP-DB] While + Function

2003-01-23 Thread 1LT John W. Holmes
if(category = 'bla')

Maybe you shouldn't be using a constant if it's going to be changing each
time the page loads.

---John Holmes...

- Original Message -
From: Shachar Tal [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, January 23, 2003 7:46 AM
Subject: Re: [PHP-DB] While + Function


 Thanks. your way to do it gave me a good idea, and it's working now :)
 Now I have another small question:

 How can I check what's in a constant?
 let's say i'm doing this :
  define ( category, $cat );

 $cat can be something else each and every time the page loads, then, I
want
 to check what it is, like
 if constant(category) = bla {
 }

 whats the syntax for checking the value of it?

 thanks

 - Original Message -
 From: Jason Wong [EMAIL PROTECTED]
 Newsgroups: php.db
 To: [EMAIL PROTECTED]
 Sent: Thursday, January 23, 2003 11:54 AM
 Subject: Re: [PHP-DB] While + Function


  On Thursday 23 January 2003 06:04, Shahar Tal wrote:
   Hello all!
  
   I got one page, with this code:
  
   ?php
   echo insert_results();
   ?
  
   Which grabs the data I send from another page, on that function.
   Here is the important part of the function while code:
  
   while ($row = mysql_fetch_array($result)){
   function insert_results () {
extract($row);
echo bla;
   }
   }
  
   Ok, this is the problem.
   As you can see, it takes the data from the dattabase, sticks it into
the
   function, and then the second page displays it.
   don't get me wrong, this is working PERFECTLY and just the way I want
 it,
   and then comes my problem.
   It works only with one row. it displays only one row, even when I know
   there are more. no matter how many rows are in the database,
   it will always output one bla.
  
   I need to move on and display all the rows, just like 'while' should
 work,
   I don't know why it's not working.
   Maybe I should stick it into a function array? but that's a bit
strange
 as
   the 'while' command should do it automaticlly.
 
  Why have you defined your function insert_results() inside your
 while-loop?
 
  You be doing something like this instead:
 
function insert_results($row) {
  do_insert_row;
}
 
while ($row = mysql_fetch_array($result)) {
  insert_results($row);
}
 
  --
  Jason Wong - Gremlins Associates - www.gremlins.biz
  Open Source Software Systems Integrators
  * Web Design  Hosting * Internet  Intranet Applications Development *
 
 
  /*
  Joe's sister puts spaghetti in her shoes!
  */
 



 --
 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] function needed

2003-01-24 Thread 1LT John W. Holmes
You could also use this:

function getdomainname($name)
{
$parts = explode('.',$name);
return $parts[count($parts)-2];
}

which will always return the second to last section when divided up by the
periods. So it will return 'domain' for all of the following:

www.domain.com
www.subdomain.domain.org
subdomain.domain.org
domain.museum

---John Holmes...

- Original Message -
From: heilo [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, January 24, 2003 1:27 PM
Subject: Re: [PHP-DB] function needed


 Hi!

 I hope I understood you right... I would use PCREs:

 ?php

 function getdomainname($string)
 {
 $pattern = '#(([[:alnum:]]+)(\.))?(.+)(\.)([[:alnum:]]+)#i';
 $replace = '\\4';
 return preg_replace($pattern, $replace, $string);
 }

 $var = $_SERVER['SERVER_NAME'];

 echo getdomainname($var);

 ?


 .ma

 Shahar Tal [EMAIL PROTECTED] [EMAIL PROTECTED] 18:44 Uhr:

  Hey
 
  I'm looking and wondering for a function, as i'm trying to do something,
and
  here it is.
 
  I'm using the SSI call :
  !--#echo var=HTTP_HOST --.
  to get the domain name I am on. this will output
 
  www.domain.com.
 
  I would like to use PHP in order to take this string, the output, and
cut
  the www. and the .com from it, so only the domain will remain.
  ofcourse we can also have situations whith .org and .net and even
where
  there's no www. but the main thing I need is to remove whats
  after the second dot and before the first dot, along with the dots.
 
  I don't mind writing all the posibilities to the function, ie, all the
  possible extenstions that the function may need to cut, I just need it
to
  take
  the text from the SSI, and cut everything but the domain part, which
is
  the address itself.
 
  what would be the best way to do it?
  thank you!!
 
 



 --
 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] function needed

2003-01-24 Thread 1LT John W. Holmes
But what about www.domain.co.uk, you ask? Well, it'll fail with this. :)

Just filter out the 'co.' like the other function that was posted and this
will still work.

---John Holmes...

- Original Message -
From: 1LT John W. Holmes [EMAIL PROTECTED]
To: heilo [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Friday, January 24, 2003 1:58 PM
Subject: Re: [PHP-DB] function needed


 You could also use this:

 function getdomainname($name)
 {
 $parts = explode('.',$name);
 return $parts[count($parts)-2];
 }

 which will always return the second to last section when divided up by the
 periods. So it will return 'domain' for all of the following:

 www.domain.com
 www.subdomain.domain.org
 subdomain.domain.org
 domain.museum

 ---John Holmes...

 - Original Message -
 From: heilo [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Friday, January 24, 2003 1:27 PM
 Subject: Re: [PHP-DB] function needed


  Hi!
 
  I hope I understood you right... I would use PCREs:
 
  ?php
 
  function getdomainname($string)
  {
  $pattern = '#(([[:alnum:]]+)(\.))?(.+)(\.)([[:alnum:]]+)#i';
  $replace = '\\4';
  return preg_replace($pattern, $replace, $string);
  }
 
  $var = $_SERVER['SERVER_NAME'];
 
  echo getdomainname($var);
 
  ?
 
 
  .ma
 
  Shahar Tal [EMAIL PROTECTED] [EMAIL PROTECTED] 18:44 Uhr:
 
   Hey
  
   I'm looking and wondering for a function, as i'm trying to do
something,
 and
   here it is.
  
   I'm using the SSI call :
   !--#echo var=HTTP_HOST --.
   to get the domain name I am on. this will output
  
   www.domain.com.
  
   I would like to use PHP in order to take this string, the output, and
 cut
   the www. and the .com from it, so only the domain will remain.
   ofcourse we can also have situations whith .org and .net and even
 where
   there's no www. but the main thing I need is to remove whats
   after the second dot and before the first dot, along with the dots.
  
   I don't mind writing all the posibilities to the function, ie, all the
   possible extenstions that the function may need to cut, I just need it
 to
   take
   the text from the SSI, and cut everything but the domain part, which
 is
   the address itself.
  
   what would be the best way to do it?
   thank you!!
  
  
 
 
 
  --
  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] too many connections?

2003-01-27 Thread 1LT John W. Holmes
 any idea what this means? i have not touched or changed my
 config.php file since i put it up the first time... it contains my db
 connect info. also, i just downloaded it from the server to see if it
 had been modified and it had not. thanks again and best, addison

 Warning: Too many connections in
 /users/infoserv/web/register/ca/admin/config.php on line 5

 Warning: MySQL Connection Failed: Too many connections in
 /users/infoserv/web/register/ca/admin/config.php on line 5

It's exactly what it say, there are too many connections to your MySQL
server. By default, you can have 100 connections to a MySQL server. If you
have a ton of traffic, you will need to increase that limit so that you
don't get errors like this. If you don't have enough traffic to generate 100
connections at the same time, then run a SHOW PROCESSLIST on your MySQL
server to see if you have a query locking things up and everything else is
waiting (did this the other day, oops!)

---John Holmes...


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




Re: [PHP-DB] mysql_insert_id() vs. last_insert_id()

2003-01-28 Thread 1LT John W. Holmes
 I've been checking the last_insert_id() function out and I am curious. The
 MySQL docs say to use the mysql_insert_id() function after an insert
into
 query to grab the key value. Both seem to work; however, there are some
 subtle differences.

 Which is the best one to use after a single insert statement, or does it
 matter?

It really doesn't matter. If you need the number in PHP for something else,
then use the PHP function. If you just need it for another query, one right
after the other, then use the MySQL function and don't worry about PHP
retrieving it.

---John Holmes...


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




Re: [PHP-DB] sql syntax error

2003-01-29 Thread 1LT John W. Holmes

- Original Message -
From: Addison Ellis [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, January 28, 2003 10:46 PM
Subject: [PHP-DB] sql syntax error


 hello,
 i can not pinpoint this. your time and help is very much
 appreciated. best, addison

 Error:
   id=, HTTP_POST_VARS=Array, key=, value=, category=, subcategory=,
 [EMAIL PROTECTED]
 Error in query: insert into ads values

(year,make,model,color,mileage,condition,price,other,contact,next_,,created)
 values ('',,NOW()),Error:You have an error in your SQL syntax near
 'created) values ('',,NOW())' at line 1

 Code:
 else
   {
  foreach($HTTP_POST_VARS as $column_name = $column_value)

  $column_names .= $column_name . ',';
  $column_values .= '$column_values',;

  $query = insert into ads values ($column_names,created)
values ($column_values,NOW());
  $result = mysql_query($query)
 or die (Error in query: $query,Error:
.mysql_error());
  }

Try this:

foreach($HTTP_POST_VARS as $column_name = $column_value)
{
  $column_names .= $column_name . ',';
  $column_values .= '$column_value',;
 }
  $query = insert into ads values ($column_names created)
values ($column_values NOW());
  $result = mysql_query($query)
 or die (Error in query: $query,Error:
.mysql_error());

I still don't think it's going to work for you. do you really have a column
called 'next_' in your table? It's probably the button you pressed to submit
the form, which is in HTTP_POST_VARS, but I don't see a reason it would be
in your table...

---John Holmes...


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




Re: [PHP-DB] Storing IP into DB

2003-01-30 Thread 1LT John W. Holmes
 I wondered if anyone could help me.
 I would like to store the user IP only once
 per multiple visits.
 The code below store the user IP on every visit
 which is not my intention.
 Please I would like to have the IP stored at once upon
 repetitive visits of the user.
 Thank
 Below is my code

 ?

 $ip_address = getenv (REMOTE_ADDR);
 $the_date = date(Y-m-D);
 $connect = mysql_connect(localhost, user, pass) or die(Cant
Connect!);
 mysql_select_db(ipvisits)or die(Cant Connect To Database);
 mysql_query(INSERT into visitorsips (ip, date) VALUES ('$ip_address',
'$the_date'));
 mysql_close($connect);

Make your 'ip' column UNIQUE in your table and ignore errors.

Or, set a flag in a session or cookie when you save the IP and if that flag
is present on other pages, then don't save the IP.

---John Holmes...


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




Re: [PHP-DB] Storing IP into DB

2003-01-30 Thread 1LT John W. Holmes
  Make your 'ip' column UNIQUE in your table and ignore errors.
  Or, set a flag in a session or cookie when you save the IP and if that
flag
  is present on other pages, then don't save the IP.

 Or I believe you can use REPLACE INTO...

True. I don't think all databases implement REPLACE, though... so it depends
on your config.

---John Holmes...


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




Re: [PHP-DB] SQL: Limit 1 usage?

2003-01-30 Thread 1LT John W. Holmes
 $sql = SELECT * FROM accessnums WHERE areacode=$_POST[areacode]' and
city='$_POST[cityselected]' ORDER BY network LIMIT 1;

 It can't execute the query.  Any suggestions?

Unless it's a typo, you're missing a single quote around $_POST[areacode]...

---John Holmes...


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




Re: [PHP-DB] what does % mean?

2003-01-31 Thread 1LT John W. Holmes
 I am trying to decipher some code written by someone else.  In it there
 is a query:

 $query = select description from $prodtable where description like '%'
 or type like '%' group by description;

 I've seen it used as mathematical modulos, but not sure how it's used
 here.

It is a wildcard, like someone else said.

That exact query has a poor syntax, though.. .unless there's a method behind
the madness. Since it's matching a wildcard only.. which would match
everything, you could use select description from $prodtable group by
description and get the same results.

---John Holmes...


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




Re: [PHP-DB] VFP 6 via ODBC and data integrity questions

2003-02-03 Thread 1LT John W. Holmes
 I have just began work on a project to let users subscribe to a service
and
 place orders into a database that is VFP 6 based.

 Using PHP4, I am able to interface with their program (that also uses ODBC
 locally) in all aspects (INSERT, UPDATE, DELETE, and SELECT).

 My worries come when inserting a new user/order from the web.

 The morons who designed the database made the Primary Key as character and
 NULLable (once only of course), but I have to deal with that.

 My question is this...

 How can I know the new user I INSERT will be unique? (the field is
 character, but counts like a number field)  This especially holds true
 since I have to deal with local users possibly adding at the exact same
 moment as PHP (ie. a racing issue).

 Can anyone tell me how to avoid problems?

 Would odbc_prepare() reserve a new key for me?

Just insert the name and look for an error coming back to you. There's some
way to get the error reported by the database with ODBC, isn't there? Parse
the error returned for something like duplicate key and then you'll know
the username wasn't unique and they need to find another.

---John Holmes...


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




Re: [PHP-DB] date: reverse order

2003-02-04 Thread 1LT John W. Holmes
 when retrieving data from the db and displaying it on the
 page by creation date how can i reverse the order so that the most
 recent entry appears first? here's what i have now:

 ?
 require(config.php);

  $obj = mysql_db_query($dbname,select * from ads order by
createdate);
 ?

You rely on the list to much for simple questions.

SELECT * FROM ads ORDER BY createdate DESC

---John Holmes...


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




Re: [PHP-DB] print_r($row);

2003-02-04 Thread 1LT John W. Holmes
 i do print_r($row); and all my data is printing properly from
 my db. however, with the below code only one row is not printing:
 {$row-property_type}
 thank you for your time. addison

 ?
  // Begin Ad Block
  $count = 0;
  $id = 45;
  $obj = mysql_db_query($dbname,select a.*,s.name as
 subcategory_name,c.name as category_name from ads a,subcategory s,
  category c where a.subcategory=s.id and s.category=c.id and
 a.subcategory=$id and a.que='checked');
  if ($obj  mysql_num_rows($obj)0) {
  while($row = mysql_fetch_object($obj))
  {
  $count++;
 ?
? echo {$row-bedrooms}Bedroom/{$row-baths}Bath
 {$row-property_type}br
{$row-description}br
{$row-distance} from campus.br
Available: {$row-date_available}br
{$row-price}br
Contact: {$row-contact};
 ?
/fontfont color=#00 size=2 face=Arial,
 Helvetica, sans-serifbr /
br
img src=../images/thin_line.gif width=185 height=1br
br
?
   }
   }
   // End Ad Block
 ?

 this is what is printing:

 2Bedroom/2Bath great place less than 5 miles From Campus Available
 immediately $500.00/month
 Contact: 321-1791

What does the print_r() actually look like? Make sure the cases match,
$row-Test is not the same as $row-TEST.

---John Holmes...


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




Re: [PHP-DB] Date Range Question...

2003-02-04 Thread 1LT John W. Holmes
 I am working on an app that needs to post information to a website
 based on date.  The tricky part for me is that the date is a range that
 spans either 2 or 3 days.  I want the web page to dynamically populate
this
 information based on a query.  The query will look something like this:
 mysql(Calendar2,SELECT StartDate, StopDate, LocationID FROM
 phpCalendar_Daily WHERE StartDate=CURDATE() )

 My question is say for example the StartDate is actually Jan. 1.
 The page is accessed on Jan. 2 or Jan. 3...  The  StartDate for the next
 entry is Jan. 4.  How do I write this query to select the proper entry?
In
 doing some research, it appears that a MySQL SELECT CASE might do the
 trick, but I have never used this before.  The other option I can envision
 is using PHP to handle the login and simply running the query, testing the
 result, if NULL, run the query again with CURDATE(-1).
 Any hints, ideas, or suggestions would be most appreciated.  Thanks
 in advance.

If I understand you correctly, I think you could use something like this:

SELECT StartDate, StopDate, LocationID FROM phpCalendar_Daily WHERE
StartDate BETWEEN CURDATE() AND CURDATE() - INTERVAL $x DAY

Where $x is 2 or 3, depending on your case.

---John Holmes...


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




Re: [PHP-DB] A little JOIN help please...

2003-02-04 Thread 1LT John W. Holmes
 SELECT 'A.Title'
 FROM `phpCalendar_Daily` AS 'B'
 JOIN 'phpCalendar_Details' AS 'A' ON 'A.CalendarDetailsID' =
 'B.CalendarDetailsID'
 WHERE CURDATE( ) 
 BETWEEN 'B.StartDate' AND 'B.StopDate'

Take out all of those quotes! You're making strings out of everything.

WHERE CURDATE() BETWEEN 'string' AND 'anotherstring' etc...

---John Holmes...

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




Re: [PHP-DB] TimeStamp format to date

2003-02-20 Thread 1LT John W. Holmes
 Is like this i have a field in MySql TIME_STAMP int(11) and he has a time
 stamp value (ex: 1045738710) and i want to make show it like a date format
 in the web. Can anyone help me on this...?

Just SELECT it out and run it through the PHP date() function to format it.

www.php.net/date

 Cumprimentos

What'd you call me?

---John Holmes...


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




Re: [PHP-DB] Receiving ARRAY from Forms

2003-02-20 Thread 1LT John W. Holmes
 I tried the following code but all I get back is Array.  I'm trying to
pass
 a huge array.

You need to serialize the array...

 ?
 if( isset( $submit ) )
 {
 echo array list:br;
 print_r( $eList );
 $submit = ;
 }
 else
 {
 $mList = array();
 $mList[0] = 1. hello;
 $mList[1] = 2. there;
 $mList[2] = 3. How are you;

$mList = serialize($mList);

 $fShow = EOD
 pPress Submit Button to test/p
 form method=POST action=$PHP_SELF name=Test Array
   pinput type=submit value=Submit name=submit
   input type=reset value=Reset name=B2/p
   input type=hidden name=eList[] value=$mList
   /form
 EOD;

 echo $fShow;
 }
 ?

and unserialize() it on the receiving page to get your array back. If
magic_quotes is on, be sure to stripslashes() it before unserialize()ing it.

---John Holmes...


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




Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread 1LT John W. Holmes
 I have a mysql database with a table using one column as a primary key.
 (rowID). On a php page I use a query to  list all of the rows of the table
 and have a checkbox beside each  row that should be used to check if you
 would like to delete this row. Can someone give me an example using post
 to pull the boxes that need to be deleted.

Easy one.. :)

Make sure your checkboxes have the rowID as their value, then you can simply
do this:

$query = DELETE FROM table WHERE rowID IN ( .
implode(',',$_POST['checkboxes']) . );

and run that query.

You'll end up with something that looks like this:

DELETE FROM table WHERE rowID IN (1,2,3,4,5)

where the numbers will come from only the checkboxes that you selected.

---John Holmes...


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



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread 1LT John W. Holmes
 I appreciate all of the quick replies. I do have globals off. Currently, I
 have the values for each ID being returned in a array Array ( [0] =
 101 [1] = 201 )  where 101 and 201 were the id's of the rows I checked. I
 have to say I like the way of doing it that Mathieu has shown using the
 explode function.
 Thanks again.
 Lewis

You already have an array of IDs you want to delete. Explode is for making
arrays, so what would you use it on? That doesn't make sense.

$query = DELETE FROM table WHERE rowID IN ( .
implode(',',$_POST['id_array']) . );

is the most efficient, easiest solution, but use whatever you understand.

---John Holmes...


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



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread 1LT John W. Holmes
 Thats just it. I am just not sure what to do with the array before my
 delete from query now that I have it :-)
 Thanks...
 Lewis

You don't have to do anything with it, just throw it into the line that I
gave you. Show the code you have now and someone can help you put it all
together.

---John Holmes...

 - Original Message -
 From: 1LT John W. Holmes [EMAIL PROTECTED]
 To: Lewis Watson [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Monday, February 24, 2003 10:13 AM
 Subject: Re: [PHP-DB] Checkboxes to gather rows to delete


   I appreciate all of the quick replies. I do have globals off.
 Currently, I
   have the values for each ID being returned in a array Array ( [0]
 =
   101 [1] = 201 )  where 101 and 201 were the id's of the rows I
 checked. I
   have to say I like the way of doing it that Mathieu has shown using
 the
   explode function.
   Thanks again.
   Lewis
 
  You already have an array of IDs you want to delete. Explode is for
 making
  arrays, so what would you use it on? That doesn't make sense.
 
  $query = DELETE FROM table WHERE rowID IN ( .
  implode(',',$_POST['id_array']) . );
 
  is the most efficient, easiest solution, but use whatever you
 understand.
 
  ---John Holmes...
 


 --
 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] Checkboxes to gather rows to delete

2003-02-24 Thread 1LT John W. Holmes
 I think the problem is that I need to put the array into a comma delimited
 group
 Lewis

U... that's what IMPLODE does. It will take the array and turn it into a
comma separated list. Your having a problem because you're not passing an
array when you think you are.

---John Holmes...

 - Original Message -
 From: John W. Holmes [EMAIL PROTECTED]
 To: 'Lewis Watson' [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Monday, February 24, 2003 11:09 AM
 Subject: RE: [PHP-DB] Checkboxes to gather rows to delete


   Hi there,
   I have double checked the column namesIts giving me a Warning: Bad
   arguments to implode() error
   Thanks.
   Lewis
 
  What's the code you're using? Are you sure $deleteID is an array at the
  point you call implode()? Are you sure it's available in the current
  scope at the point you call implode()?
 
  ---John W. Holmes...
 
  PHP Architect - A monthly magazine for PHP Professionals. Get your copy
  today. http://www.phparch.com/
 
  
   - Original Message -
   From: 1LT John W. Holmes [EMAIL PROTECTED]
   To: Lewis Watson [EMAIL PROTECTED]; [EMAIL PROTECTED]
   Sent: Monday, February 24, 2003 10:36 AM
   Subject: Re: [PHP-DB] Checkboxes to gather rows to delete
  
  
 Thanks. The below code returns each ID in an array like so...
 Array ( [0] =101 [1] = 201 ). Thanks for the help!
 Lewis

 $teacherID = $_POST[teacherID];
 $deleteID = $_POST[deleteID];

 if(isset($delete_teacher)) {
   This is where I should loop through checking for the chosen
  ones
   to
 delete.
   
$query = DELETE FROM table WHERE teacherID IN ( .
   implode(',',$deleteID) .
);
mysql_query($query);
   
 }

 form action= method=POST
  print input type=checkbox name=\deleteID[]\
 value=\$row[teacherID]\;
  print input type=submit  name=\delete_teacher\
  value=\Delete
   the
 Checked Teachers\;
   
Make sure the column names are correct, but that's it.
   
---John Holmes...
   
   
  
  
   --
   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] Storing an array in the database

2003-02-28 Thread 1LT John W. Holmes
 How would I store an array in the database?  I want to store 2 things.
 One array of shirt sizes and one array of which holds other arrays.

$safe = addslashes(serialize($array));

and store $safe into a text column. Use 

$array = unserialize($database_data);

to get the array back. 

---John Holmes...

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



Re: [PHP-DB] Storing an array in the database

2003-02-28 Thread 1LT John W. Holmes
  How would I store an array in the database?  I want to store 2 things.
  One array of shirt sizes and one array of which holds other arrays.
[snip]
   $query = INSERT INTO table
  ( field1, field2 )
  VALUES
  ( \ . serialize( $singleDimArray ) . \, \ .
serialize( $multiDimArray ) . \ );

FYI: Make sure you addslashes() _after_ you serialize your array if it can
contain quotes. Everything else remains the same.

---John Holmes...


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



Re: [PHP-DB] Help with MySQL Logic

2003-03-03 Thread 1LT John W. Holmes
 A client of mine, a rail car storage company, has asked that I create a
 PHP/MySQL application in which they will maintain and track rail cars. I
am
 having a bit of trouble however working through one of thier requirements.
 They need to know in what position the rail car is on each track. For
 example, they might have a track called X which will hold 30 rail cars.
They
 would enter the car information for 30 cars and associate each of them
with
 track X. If one of the car owners decides to move car 3 out of storage,
then
 the remaining 29 cars must be re-numbered ( ie; car 1 and 2 would remain
and
 car 4-30 would become car 3-29 ). In the same manner, I need to be able to
 add a car to the track once an empty slot is available. For example, If
the
 new car goes at the front of the track then it would become car 1 and the
 remaining cars, originally numbered 1-29 would become 2-30.

Not sure if this helps or if you already realize this...

Say you have a table that identifies the track_id and car_id. Now, you
delete the car_id for car #3, like you've said. So, that row is deleted and
you've got a hole now. You can run a query such as:

UPDATE table SET car_id = car_id - 1 WHERE car_id BETWEEN 4 AND 30 AND
track_id = XX

to adjust all of the other car_id numbers.

Now, say you want to add a new car to the beginning.

UPDATE table SET car_id = car_id + 1 WHERE track_id = XX

and then insert your new car at position #1.

Throw in some checks to make sure you don't go over 30 cars and you should
have it. You can get a count of how many cars are on a certain track with:

SELECT COUNT(*) AS c FROM table WHERE track_id = XX

Hope that helps. It sounds like a fun project.

---John Holmes...


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



Re: [PHP-DB] Confusing Date...

2003-03-03 Thread 1LT John W. Holmes
 I have a MySQL column that was set to date.

 In my PHP page, I have a form and a field called 'Sch_StartDate'.  I'm
 having difficultes understanding how to write to the date column in MySQL.
 If I send 03/04/02for March 4, 2002, the value that gets stored in the
 MySQL database is 2003-04-02 for April 2nd, 2003.

 The field is set to to send as a date:
 GetSQLValueString($HTTP_POST_VARS['Sch_StartDate'], date)

 So how do I send dates to MySQL so that it stores it correctly?

MySQL expects the date in a -MM-DD or MMDD format. You can actually
use other characters as the delimiter instead of the dash (-) character, as
long as the year, month, and day are in the right order. As you've seen, you
can also pass it a two digit year and it'll assume what century you mean.

---John Holmes...


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



Re: [PHP-DB] date functions

2003-03-04 Thread 1LT John W. Holmes
 I am looking for a way to take a date stored in a mysql database... and
find
 out the date seven days later.

 how would i do this?!

too easy...

SELECT date_column + INTERVAL 7 DAY FROM your_table ...

---John Holmes...


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



Re: [PHP-DB] date functions

2003-03-04 Thread 1LT John W. Holmes
 I want to use it in this function that i am creating (it's for a
resteraunt
 automated tips system, to work out how much tips each staff member is
 entitled to.

 
 function tips($weekstart){
 /* JUST BELOW HERE IS WHERE I NEED TO GET THE DATE OF 6
 DAYS AFTER THE
 SPECIFIED DATE OF THE START OF THE WEEK */
 $weekend = date($weekstart +6);

 $query = SELECT * FROM Rota WHERE date = $weekstart
  AND date = $weekend ORDER BY staffid;

 etc...

What format is $weekstart in? Maybe you said already, I can't remember.

You could try

$weekend = strtotime($weekstart . ' +6 days');

Since I think your 'date' column is a TIMESTAMP, you'll need to format
$weekstart and $weekend as MMDD in order to get what you have above to
work.

Maybe try this:

function tips($weekstart){
  $start = date('Ymd',strtotime($weekstart));

  $query = SELECT * FROM Rota WHERE date = $start and date = ($start +
INTERVAL 6 DAY) ORDER BY staffid;

  etc...

---John Holmes...


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



Re: [PHP-DB] Mysql compress text field?

2003-03-04 Thread 1LT John W. Holmes
 I have a new project where i need show pages of report on demmand.
That
 reports are created in the batch process, and the whole file size is about
5
 Gb. (thats includes all the reports in a month, I need save about 12
month).

 I think in two alternatives :

 1. I save the links in a mysql database, but the files are compressed
 (in zip format) in several directories, one directorie by day, so when the
 user request one report, I query the database, go to the path, decompress
 the file and return to the user.

Use this method.

 2. I save the reports on the mysql database, so when the user request
 one report, I query the database and return the report. But if MySql don't
 compress the text field, that way is not practicable (HDD is limited).

You'd have to zip the files, then read the data to insert into the table.
Then, to retrieve, you'd have to select the data out, write it to a file and
unzip it before you sent it to the user. (According to your remarks) Sounds
like a lot of wasted time to me.

---John Holmes...


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



Re: [PHP-DB] date functions (generates parse error)

2003-03-04 Thread 1LT John W. Holmes
 Here is the whole code of my function

 Whenever i run it, it say's there is a parse error on line 6, can't see
what
 is the problem
 the format of $weekstart (as it is stored in the Database) is -MM-DD

 =
 ?
 function tips($weekstart){

 $start = date('Ymd',strtotime($weekstart));

 $query = SELECT * FROM Rota WHERE date = $start and date = ($start +
 INTERVAL 6 DAY) ORDER BY staffid;
 $result = mysql_query($query);
 while ($row = mysql_fetch_array($result)){

 if ( isset ( $tips ) ){

 if (isset ( $tips[$row[staffid]] ) ){

 $hours = $row[finish] - $row[start];
 $tips[$row[staffid]] = $tips[$row[staffid]] + $hours;

 }

 else{

 $tips[$row[staffid]] = $row[finish] - $row[start];

 }
 }

 else{

 $tips = array('$row[staffid]' =( $row[finish] - $row[start] ) );

 }

 }

 return $tips;

 }

I cut and pasted your exact code here and didn't get a parse error.

---John Holmes...


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



Re: [PHP-DB] Problem with php and mysql

2003-03-05 Thread 1LT John W. Holmes
 One of our customers has written a php application that we are hosting.

 Basically, there is a province/state table which populates a combo box.
 When the form containing this combo box is submitted, the information is
 added into the database.

 The problem is that when nothing is selected from the combo box, it adds a
 number which seems to be random in the database, rather than the
 province/state ID which it references from the province table. Obviously
 there are many methods of avoiding this such as javascript to make sure
 something is selected, or even giving the combo box a default value, but I
 was wondering if anyone knew why the database itself isn't catching the
 error (foreign key violation) and accepting the data.

 Any ideas?

Are you using InnoDb tables? Otherwise there are no foreign key
restrictions.

How about some validation to make sure something is selected? Or, some
validation that'll give the value a default if nothing is selected.

Validate everything from the user!

---John Holmes...


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



Re: [PHP-DB] Subtraction of two units of time.

2003-03-06 Thread 1LT John W. Holmes
 I want to take away two times stored in the format 00:00:00 in a mysql
 database, i retrieve the times and take them away by using the following

 $total = $time1 - $time2 ;

 when i echo the total it is a whole number of the hours.. and does not
take
 the minutes into account, anyone have an idea of how to get an exact
answer
 to 2decimal places of the subtraction of the two times?

Read the manual. These two functions will probably come in handy (assuming
MySQL):

SEC_TO_TIME(seconds)
Returns the seconds argument, converted to hours, minutes, and seconds, as a
value in 'HH:MM:SS' or HHMMSS format, depending on whether the function is
used in a string or numeric context:
mysql SELECT SEC_TO_TIME(2378);
- '00:39:38'
mysql SELECT SEC_TO_TIME(2378) + 0;
- 3938

TIME_TO_SEC(time)
Returns the time argument, converted to seconds:
mysql SELECT TIME_TO_SEC('22:23:00');
- 80580
mysql SELECT TIME_TO_SEC('00:39:38');
- 2378So... SELECT
SEC_TO_TIME(TIME_TO_SEC(column1)-TIME_TO_SEC(column2)) AS Difference
...---John Holmes...


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



  1   2   >