RE: [PHP-DB] Insert/Update help needed

2003-07-17 Thread Hutchins, Richard
Mike,

Pretty sure your solution is to addslashes() around whatever data might
contain the apostrophes.

HTH,
Rich

 -Original Message-
 From: Mike Baerwolf [mailto:[EMAIL PROTECTED]
 Sent: Thursday, July 17, 2003 11:33 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Insert/Update help needed
 
 
 Hello all,
 
 I've been able to get the below to work pretty much. The only 
 problem I 
 have is when there is an apostrophe in the data of one of the fields 
 like (You're the One).  When this occurs nothing gets updated or 
 inserted(tried both).  I've done other things from forms 
 inserting/updating with data that contained apostrophes and 
 never had a 
 problem.  This is my first attempt at inserting/updating from 
 a string 
 match.
 Any help would be appreciated.
 
 $grab = preg_match_all(/(([\w]+)[^]*)(.*)(\/\\2)/, 
 $file, $matches);
 
 $a_1 = $matches[3][48];
 $a_2 = $matches[3][49];
 $a_3 = $matches[3][50];
 $sql = UPDATE charts SET artist='$a_1' , song='$a_2' , label='$a_3' 
 WHERE charts_id=1 or die(mysql_error());
 if ($result = mysql_query($sql)){
 
 Here is my table structure:
 charts_id(tinyint(3),NOT NULL)
 artist(varchar(150),NULL)
 song(varchar(100),NULL)
 label(varchar(75),NULL)
 
 Thanks in advance,
 Mike
 
 
 
 -- 
 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 Update

2001-08-04 Thread Patrik Wallstrom

On Sat, 4 Aug 2001, Joris Kluivers wrote:

 is there a mysql query that inserts into a database, but if the item
 already exists it does not insert but updates?

replace into

--
 patrik wallstrom |  f o o d f i g h t
 tel: +46-8-6188428   |  s t o c k h o l m
 gsm: +46-709580442   |  - - - - - - - - -


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




Re: [PHP-DB] Insert Update

2001-08-04 Thread Leo de Kleijn

Use REPLACE

- Oorspronkelijk bericht -
Van: Joris Kluivers [EMAIL PROTECTED]
Aan: [EMAIL PROTECTED]
Verzonden: zaterdag 4 augustus 2001 18:20
Onderwerp: [PHP-DB] Insert Update


is there a mysql query that inserts into a database, but if the item already
exists it does not insert but updates?

Joris



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