Re: [PHP-DB] Manipulating text

2005-12-08 Thread Ron Piggott (PHP)
Thanks for telling me the 'explode' command.  Ron

On Fri, 2005-12-09 at 08:07 +0530, Amol Hatwar wrote:
> On Thu, 2005-12-08 at 21:25 -0500, Ron Piggott (PHP) wrote:
> > If I have
> > 
> > $variable = "play_time";
> > 
> > how may I remove "play_" from $variable and just have $variable equal to
> > "time"?
> > 
> 
> If you are hinting at '_' as a delimitter, you can use explode(). Learn
> more about it here:
> http://php.net/explode
> 
> Regards,
> 
> ah
> 

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



[PHP-DB] One final question regarding FTP :-)

2005-12-08 Thread Chris Payne
Hi there everyone,

 

I found the PERFECT JAVA Applet for my PHP needs, it allows me to drag and
drop and it uploads via FTP to the server very nicely with progress bar etc
 however, with this it doesn't send the file name to PHP which is what I
urgently need.

 

How can I list a directory and grab the latest file that has been added to
it?  I don't have to worry about multiple files being uploaded as once they
upload THEN they are moved to their final resting place on the server :-)

 

Basically I need to know with FTP how I can grab the filename of the most
recent save file, then my boss will be happy as I'd have solved his problem
on his pet project and I can breath again :-)

 

Thank you all for your help throughout the past couple of years, you are all
wonderful and I promise this is the last message unless it's directly DB
related (It is technically as I have to add the filename to a DB, but it's
not in the sense it should be and I'm sorry).

 

Chris



RE: [PHP-DB] Manipulating text

2005-12-08 Thread Bastien Koert

str_replace

$var = "play-time";

$var = str_replace("play-","",$var);

regex

$var = eregi_replace("[play-]","",$var);

B



From: "Ron Piggott (PHP)" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: PHP DB 
Subject: [PHP-DB] Manipulating text
Date: Thu, 08 Dec 2005 21:25:39 -0500

If I have

$variable = "play_time";

how may I remove "play_" from $variable and just have $variable equal to
"time"?

Ron

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



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



[PHP-DB] Manipulating text

2005-12-08 Thread Ron Piggott (PHP)
If I have

$variable = "play_time";

how may I remove "play_" from $variable and just have $variable equal to
"time"?

Ron

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



[PHP-DB] Re: SQL Insert INTO question

2005-12-08 Thread Frank Flynn

Geekgirl,

Let me expand on the answers so far...

There are two things you can do here: add a new record or update an  
existing one.  In SQL this makes a big difference and in your  
question you've confused the two (MySQL has a trick which kind of  
mixes the two and it is limited).  I'm not exactly sure what you  
really intend to do so I'll show you are three and explain each:


A schema which might be like yours:

CREATE TABLE reviews
( review_id int NOT NULL auto_increment,
   review_txt text,
   primary key (review_id))

- To insert a new row
   INSERT INTO reviews (review_txt)
VALUES  ('$_POST[review]')

This will create a new record and will automatically generate the new  
review_id,  if you want to specify the review_id you can do this

   INSERT INTO reviews (review_id , review_txt)
VALUES  ( $id, '$_POST[review]')

But this review_id must NOT exist or you will get a 'duplicate key'  
error.


-To update an existing row use this:
  UPDATE reviews
 SET review_txt = '$_POST[review]'
WHERE review_id = $id

If the row with that review_id does not exist you will not get an  
error - but nothing will get saved; if the row with that review_id  
exists it will get updated.


-Finally there is a way to mix the two (I believe this is MySQL only):
   REPLACE INTO reviews (review_id , review_txt)
VALUES  ( $id, '$_POST[review]')

This works just like INSERT except if this review_id exists the old  
one will get deleted (this is because it is defined as the key in the  
create table statement).  There is an important difference between  
this and the UPDATE statement; this is if you have other columns  
which are not mentioned in an UPDATE statement they will stay  
unchanged but REPLACE will delete the old row so all other columns  
will be their default values or NULL.


Feel free to write with more questions,

Good Luck,
Frank

On Dec 7, 2005, at 9:42 PM, geekgirl1 wrote:



This is the problem.  I want to add the value of $_POST[review] to the
reviews table where the unique id from the reviews table equals the
review id on my form.  The statement below does not work.  Should I
use UPDATE instead?

"INSERT INTO reviews (review_txt)
VALUES
('$_POST[review]') WHERE review_id = $id";

Marian




Re: [PHP-DB] Quick question

2005-12-08 Thread Amol Hatwar
** Comments Inline **

*chop*
> Basically I need to be able to upload 1gig files via FTP which is based on

Whoa! Did I read ONE GIG? By FTP I understand *the* File Transfer
Protocol. How is it based on PHP?

> PHP, when the file uploads successfully it then adds the info to a mysql
> database so that the administration program can control the programs
> uploaded, but I can't upload any large files only small ones.

On FTP? Or from a PHP generated Web page?

> Any help would REALLY be appreciated as this is quite urgent and I've
> searched the net for examples but couldn't find what I needed.

For this answer I am assuming that you want to stick One Gig-o-files
using a PHP script. Let me know if this isn't the case. There are two
things to consider here:
1. The PHP script time-out (usually 30 secs) and the max-upload (2 MB)
2. The Apache Process recycle-time (look for settings in httpd.conf)

You can try playing around with these values. However, it is not good
for your scripts,Apache and PHP to stay in memory for such a long time
(till your huge file gets uploaded). They simply aren't designed to do
that. They are designed to just serve the requested page and shut up.

I'd suggest you use some different mechanism like SCP (if you don't want
to touch FTP) or rsync over SSH if you'd like the thing run unattended.

Regards,

ah

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



Re: [PHP-DB] Re: SQL Insert INTO question

2005-12-08 Thread Graham Cossey

How about:

$review = $_POST['review'];
$sql = "SELECT * FROM reviews WHERE review_id = '$id'";
$res = mysql_query($sql) or die ("Query failed: " . mysql_error());
if (mysql_num_rows($res) > 0)
{
 $sql_upd = "UPDATE reviews
   SET review_text = '$review'
 WHERE review_id = '$id' ";
 $res_upd = mysql_query($sql_upd) or die ("Query failed: " . mysql_error());
 }else{
  $sql_ins = "INSERT INTO reviews (review_id, review_text)
 VALUES('$id', '$review')";
  $res_ins = mysql_query($sql_ins) or die ("Query failed: " .
mysql_error());
}

--
Graham

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



[PHP-DB] Emails Bouncing

2005-12-08 Thread Joseph Crawford
I keep getting the following, can someone from the staff rectify this please


Your message

 To:
  Subject: Re: [PHP-DB] Restricting What's Retreived
 Sent: Thu Dec 08 09:56:44 2005


did not reach the following recipient(s):
[EMAIL PROTECTED] on Thu Dec 08 09:56:44 2005

 The e-mail account does not exist at the organization this message
 was sent to.  Check the e-mail address, or contact the recipient
 directly to find out the correct address.
 

Thanks,

--
Joseph Crawford Jr.
Zend Certified Engineer
Codebowl Solutions, Inc.
1-802-671-2021
[EMAIL PROTECTED]


Re: [PHP-DB] Quick question

2005-12-08 Thread Joseph Crawford
ini_set('max_execution_time', 9600);
that's how you set the max_execution_time, i would assume the rest follow
the same format.

notice the time is in seconds.


--
Joseph Crawford Jr.
Zend Certified Engineer
Codebowl Solutions, Inc.
1-802-671-2021
[EMAIL PROTECTED]


Re: [PHP-DB] Restricting What's Retreived

2005-12-08 Thread Joseph Crawford
you can try this
select SUBSTRING(field,0,100) from table

--
Joseph Crawford Jr.
Zend Certified Engineer
Codebowl Solutions, Inc.
1-802-671-2021
[EMAIL PROTECTED]


[PHP-DB] Quick question

2005-12-08 Thread Chris Payne
Hi there everyone,

 

How do I set the following items with ini_set()?  I looked at the manual but
when I try nothing happens:

 

*   file_uploads
*   upload_max_filesize
*   max_input_time
*   memory_limit
*   max_execution_time
*   post_max_size

 

Basically I need to be able to upload 1gig files via FTP which is based on
PHP, when the file uploads successfully it then adds the info to a mysql
database so that the administration program can control the programs
uploaded, but I can't upload any large files only small ones.

 

Any help would REALLY be appreciated as this is quite urgent and I've
searched the net for examples but couldn't find what I needed.

 

Help me o-b-1, you're my only hope :-)

 

Thanks everyone.

 

Chris



Re: [PHP-DB] Re: SQL Insert INTO question

2005-12-08 Thread dpgirago

In full agreement here. I scratched my head this morning, then looked up
"INSERT" in the MySQL Docs for a sanity check. It must be an UPDATE
statement to work as indicated below.

David

<< Sorry David Mitchell >>

==

Is that a syntax supported by MySQL?  That is, an INSERT with WHERE clause?
I tried it against Oracle, and it doesn't work (can you imagine how
upsetting it would have been to have learned that, after having worked with
SQL for several years, one can do an update using an INSERT statement?).
I'm pretty sure it doesn't work against MS SQL Server, DB2, etc (not 100%
certain, but 99.9%).

On 12/8/05, El Bekko <[EMAIL PROTECTED]> wrote:
>
> geekgirl1 wrote:
> > First time poster.
> >
> > This is the problem.  I want to add the value of $_POST[review] to the
> > reviews table where the unique id from the reviews table equals the
> > review id on my form.  The statement below does not work.  Should I
> > use UPDATE instead?
> >
> > "INSERT INTO reviews (review_txt)
> >   VALUES
> >   ('$_POST[review]') WHERE review_id = $id";
> >
> > Marian
>
> "INSERT INTO reviews (review_txt)
>VALUES
>('$_POST[\'review\']') WHERE review_id = '$id'";
>
> There, now it should work :)
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



[PHP-DB] Restricting What's Retreived

2005-12-08 Thread Dave W
Does anyone know when you get info from a DB, can you restrict how many
characters it gets from it? say you had a paragraph 1,000 letters but you
only wont it to get 100 how would you do that?


Re: [PHP-DB] connect vs pconnect

2005-12-08 Thread Robert Twitty
Based on my understanding of pconnect, it is a poor man's implementation
of connection pooling.  Connection pooling requires a mediator server
between the client and database in order to maintain a connection for
reuse by another client. PHP does not provide such a server, so it uses
the web server as the mediator.  When you call pconnect, the connection
resource will be retained within the web server's process space. Thus, the
connection will live as long as the web server lives.

-- bob

On Thu, 8 Dec 2005, Benjamin Adams wrote:

> I'm trying to figure out if running mysql_connect or mysql_pconnect
> would be faster.
> Can someone explain the difference?
> Picking one for a very high traffic website with a 10 G database.
>
> --
> 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] Re: SQL Insert INTO question

2005-12-08 Thread David Mitchell
Is that a syntax supported by MySQL?  That is, an INSERT with WHERE clause?
I tried it against Oracle, and it doesn't work (can you imagine how
upsetting it would have been to have learned that, after having worked with
SQL for several years, one can do an update using an INSERT statement?).
I'm pretty sure it doesn't work against MS SQL Server, DB2, etc (not 100%
certain, but 99.9%).

On 12/8/05, El Bekko <[EMAIL PROTECTED]> wrote:
>
> geekgirl1 wrote:
> > First time poster.
> >
> > This is the problem.  I want to add the value of $_POST[review] to the
> > reviews table where the unique id from the reviews table equals the
> > review id on my form.  The statement below does not work.  Should I
> > use UPDATE instead?
> >
> > "INSERT INTO reviews (review_txt)
> >   VALUES
> >   ('$_POST[review]') WHERE review_id = $id";
> >
> > Marian
>
> "INSERT INTO reviews (review_txt)
>VALUES
>('$_POST[\'review\']') WHERE review_id = '$id'";
>
> There, now it should work :)
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


RE: [PHP-DB] Session handler - Info wanted

2005-12-08 Thread Bastien Koert

great article at www.phpbuilder.com

http://phpbuilder.com/columns/ying2602.php3?aid=19

Bastien



From: Craig Hoffman <[EMAIL PROTECTED]>
To: php-db@lists.php.net
Subject: [PHP-DB] Session handler - Info wanted
Date: Thu, 8 Dec 2005 11:04:29 -0600

Hi There,
I'm going to write my own session handler for an upcoming project.I 
would like to store the session data in MySQL.  I've never written  one 
before; so if anyone has any tips, suggestions, in-sight, etc...  please 
share.


Thanks,
Craig
___
Craig Hoffman
www.eclimb.net

[EMAIL PROTECTED]
iChat / AIM: m0untaind0g
___

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



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



[PHP-DB] Session handler - Info wanted

2005-12-08 Thread Craig Hoffman

Hi There,
I'm going to write my own session handler for an upcoming project.
I would like to store the session data in MySQL.  I've never written  
one before; so if anyone has any tips, suggestions, in-sight, etc...  
please share.


Thanks,
Craig
___
Craig Hoffman
www.eclimb.net

[EMAIL PROTECTED]
iChat / AIM: m0untaind0g
___

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



Re: [PHP-DB] connect vs pconnect

2005-12-08 Thread Miles Thompson
Read the comments following the formal description at 
http://www.php.ca/mysql_pconnect


They're pretty illuminating, and probably resulted from hard-earned experience.

Miles

At 11:47 AM 12/8/2005, Benjamin Adams wrote:

I'm trying to figure out if running mysql_connect or mysql_pconnect
would be faster.
Can someone explain the difference?
Picking one for a very high traffic website with a 10 G database.

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



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



[PHP-DB] connect vs pconnect

2005-12-08 Thread Benjamin Adams
I'm trying to figure out if running mysql_connect or mysql_pconnect  
would be faster.

Can someone explain the difference?
Picking one for a very high traffic website with a 10 G database.

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



RE: [PHP-DB] inserting data into Oracle tables

2005-12-08 Thread roy . a . jones

You also need to consider your character
set.  VARCHAR2(60 BYTE) means it only allows 60 bytes not 60 characters.
 Some character sets use multiple bytes (2 or 3) for some characters.
 You could define your table as VARCHAR2(60 CHAR) or set your nls_length_semantics
to CHAR.

I would also suggest that you setup a free
account at OracleTechnologyNetwork (OTN) ... http://www.oracle.com/technology/index.html
... there is a lot of good information there.


Roy A. Jones 

US Pharma Database Administration

GlaxoSmithKline Inc. US
Pharma IT, Data Warehousing Technology 
"Remember -  
is your friend!" 





"Bastien Koert"
<[EMAIL PROTECTED]> 
08-Dec-2005 09:25
       




To
[EMAIL PROTECTED], php-db@lists.php.net


cc



Subject
RE: [PHP-DB] inserting data
into Oracle tables








check the length of your vairables before you insert...if
its web based app, 
then you should limit the input anyway and validate it that it matches
the 
desired data

Bastien


>From: "David Skyers" <[EMAIL PROTECTED]>
>To: "php-db" 
>Subject: [PHP-DB] inserting data into Oracle tables
>Date: Thu, 8 Dec 2005 10:31:40 -
>
>Is there a standard for inserting data into Oracle tables from a user
input 
>field in PHP?
>
>Most Oracle tables will have a limit on the amount characters such
as
>
>Name VARCHAR2(60 BYTE) - this means the maximum amount of characters

>allowed is 60.
>
>If you use special characters in PHP such as entering the following
into a 
>input box
>
>¬!"£$%^&*()[EMAIL PROTECTED]<>?|\,./;'#][=-¦abcdefghijklmnopqrstuvwxyzA
>
>When this gets passed to Oracle it takes the overall characters in
the 
>insert statement to 64, which then fails because it is over the Oracle

>table limit. Is there a standard way of dealing with something like
this.
>
>Regards,
>David
>
>--
>David Skyers
>Support Analyst
>Management Systems, UCL
>[EMAIL PROTECTED]
>020 7679 1849 (internal 41849)
>
>--
>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] inserting data into Oracle tables

2005-12-08 Thread Bastien Koert
check the length of your vairables before you insert...if its web based app, 
then you should limit the input anyway and validate it that it matches the 
desired data


Bastien



From: "David Skyers" <[EMAIL PROTECTED]>
To: "php-db" 
Subject: [PHP-DB] inserting data into Oracle tables
Date: Thu, 8 Dec 2005 10:31:40 -

Is there a standard for inserting data into Oracle tables from a user input 
field in PHP?


Most Oracle tables will have a limit on the amount characters such as

Name VARCHAR2(60 BYTE) - this means the maximum amount of characters 
allowed is 60.


If you use special characters in PHP such as entering the following into a 
input box


¬!"£$%^&*()[EMAIL PROTECTED]<>?|\,./;'#][=-¦abcdefghijklmnopqrstuvwxyzA

When this gets passed to Oracle it takes the overall characters in the 
insert statement to 64, which then fails because it is over the Oracle 
table limit. Is there a standard way of dealing with something like this.


Regards,
David

--
David Skyers
Support Analyst
Management Systems, UCL
[EMAIL PROTECTED]
020 7679 1849 (internal 41849)

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



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



[PHP-DB] Re: ftp_put

2005-12-08 Thread El Bekko

Chris Payne wrote:

Hi there everyone,

 


I'm using FTP to upload a file from a form, the information is stored in a
MySQL DB and then FTP'd to the server.  Is it possible - without altering
the php.ini file as I don't have access to this on my clients server - to be
able to upload large files rather than small ones?  I know with POST there
are limits, but we're talking about megabytes rather than KB's needing to be
uploaded.  They HAVE to be uploaded via some kind of form as it sends the
data to a database such as the file name and location so that it can easily
be found by the system otherwise I'd just tell them to use normal FTP
software.

 


What's the best way of achieving this?  I'm talking file 5-20megs in size.

 


Thanks everyone.

 


Chris


Max size defined in PHP.ini is 2MB, and I don't think you can change 
that without having access to the file...


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



[PHP-DB] Re: SQL Insert INTO question

2005-12-08 Thread El Bekko

geekgirl1 wrote:

First time poster.

This is the problem.  I want to add the value of $_POST[review] to the
reviews table where the unique id from the reviews table equals the
review id on my form.  The statement below does not work.  Should I
use UPDATE instead?

"INSERT INTO reviews (review_txt)
VALUES
('$_POST[review]') WHERE review_id = $id";

Marian


"INSERT INTO reviews (review_txt)
VALUES
('$_POST[\'review\']') WHERE review_id = '$id'";

There, now it should work :)

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



[PHP-DB] inserting data into Oracle tables

2005-12-08 Thread David Skyers
Is there a standard for inserting data into Oracle tables from a user input 
field in PHP?

Most Oracle tables will have a limit on the amount characters such as 

Name VARCHAR2(60 BYTE) - this means the maximum amount of characters allowed is 
60.

If you use special characters in PHP such as entering the following into a 
input box

¬!"£$%^&*()[EMAIL PROTECTED]<>?|\,./;'#][=-¦abcdefghijklmnopqrstuvwxyzA 

When this gets passed to Oracle it takes the overall characters in the insert 
statement to 64, which then fails because it is over the Oracle table limit. Is 
there a standard way of dealing with something like this.

Regards,
David

--
David Skyers
Support Analyst
Management Systems, UCL
[EMAIL PROTECTED]
020 7679 1849 (internal 41849) 

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