[PHP] Regexp
I am reading in a comments file from a Perl program I have been using, and I will be converting the comments' text files into a MySQL database...but that is unimportant. In the files, I have something (after i strip_tags()) like this: ## $file = " # 4 Name: Vigilante E-mail: [EMAIL PROTECTED] Date: Monday, July 24, 2000, 5:28 PM ip: Hidden Comment Hmm. Even that link doesn't work anymore. Looks like they took that comic down (booo). Anyone save it? # 3 Name: Anonymous Unregistered E-mail: [EMAIL PROTECTED] Date: Monday, July 24, 2000, 8:57 AM ip: 209.181.217.205 Comment http://www.pvponline.com/archive.php3?archive=2723 The URL changed because it was yesterday's comic :) "; ### What I want to do is break it down so it looks like this (NOTE: "``x" would be the break between comments) $file = " # 4 Name: Vigilante E-mail:[EMAIL PROTECTED] Date:Monday, July 24, 2000, 5:28 PM ip:Hidden Comment:Hmm. Even that link doesn't work anymore. Looks like they took that comic down (booo). Anyone save it? ``x # 3 Name:Anonymous Unregistered E-mail:[EMAIL PROTECTED] Date:Monday, July 24, 2000, 8:57 AM ip:209.181.217.205 Comment:http://www.pvponline.com/archive.php3?archive=2723brThe URL changed because it was yesterday's comic :) "; # Then I could parse it easier. So, I guess i need a regexp to remove all the \n and :space: chars. Thanks, David Balatero -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] strip_tags()
I have a document with !--ktalk newpost-- in it, which I want to KEEP in the document. (it's being read into $fp). How can I use strip_tags() to remove all tags, but keep !--ktalk newpost-- in the document? I tried $filedata = strip_tags($filedata, "!--ktalk newpost--"); Then re-writing it to the file, but it still takes out the !--ktalk newpost-- tag! Please help! Thanks, David Balatero -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] regex help...again
Ok, i have a text file with lines that looks like this: 14```value```value2`value3 This would be fine, except...there are sometimes more than in other columns, so id like it to be 14``value``value2``value3 So I can explode() it into a mysql database. Can anyone offer a regexp for this? Thanks! David Balatero -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] ARGGG! File uploading on a local Windows box.
Hi, I am running PHP 4.10 off my Win2000 box, and I am trying to upload a file to it (Apache is running off the same box I'm uploading from). I have the following form: = FORM method=POST action=catalog_admin.php?action=additemsave enctype=multipart/form-data INPUT type=hidden name=MAX_FILE_SIZE value=1 INPUT type=file name=userfile input type=submit name=additem_submit value=Add Product input type=reset name=reset value=Reset Form /FORM and the php script that handles it: ?php $sql = INSERT INTO products (category_id, item_name, item_company, item_price, item_listprice, item_discount, dimensions_height, dimensions_width, dimensions_length, dimensions_weight_lbs, number_in_stock, product_description) values('$category_id','$item_name','$item_company','$item_price','$item_list price','$item_discount','$dimensions_height', '$dimensions_width','$dimensions_length','$dimensions_weight_lbs','$number_i n_stock','$product_description'); $result = mysql_query($sql, $dbconn) or die(mysql_error()); $item_id = mysql_insert_id(); $array = explode(/, $userfile_type); if ($array[1] == pjpeg || $array[1] == jpeg) { $array[1] = jpg; } $ext = $array[1]; $new_file = $imagedir . \\ . $item_id.$ext; if (!move_uploaded_file($userfile, $new_file)) { $sql = DELETE FROM products WHERE (item_id = '$item_id'); $result = mysql_query($sql); metadie(Unable to move the uploaded image file to the new directory ($imagedir) ($new_file) ($userfile). Image type was .$array[1]); } $sql = UPDATE products SET image_src='$new_file' WHERE (item_id = '$item_id'); $result = mysql_query($sql); ? == My problem is, whenever I upload an image, $userfile is always none. I know I'm uploading it on the form end, but it doesn't seem to register it on the PHP script's end. Any help here? Thanks, David Balatero ([EMAIL PROTECTED]) -- PHP General 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] foreach statement
Nope, the exact syntax is foreach ($emails as $this_is_one_address) { } ...With that as in there. HTH David Balatero [EMAIL PROTECTED] - Original Message - From: Chris Grigor [EMAIL PROTECTED] To: [EMAIL PROTECTED]; Php-General [EMAIL PROTECTED] Sent: Tuesday, January 08, 2002 11.44 PM Subject: RE: [PHP] foreach statement Hey Niklas yea thats what I want, just one thing foreach($emails as $this_is_one_address) { would it be foreach($emails) { or am I missing something in there ? ? ? $sms_list = test_number; // This is the file with one e-mail address per line? $emails = file($sms_list); foreach($emails as $this_is_one_address) { // Do what ever you want to. // $this_is_one_address contains one element from $emails }; Niklas -Original Message- From: Chris Grigor [mailto:[EMAIL PROTECTED]] Sent: 9. tammikuuta 2002 8:59 To: 'Php-General-List (E-mail)' Subject: [PHP] foreach statement Okay lets see who has there thinking caps on today (cos I really dont) I have a list of email addresses stored in a text file. I am able to run the script and get all the mail addresses in the list mailed but thats all in one mail. I want to be able to open the file, chop each line and send individual messages to each address.. okay who is confused as Im not giving you much description here, well okay heres what the script looks like #!/usr/bin/php -q ? $sms_list = test_number; $emails = file($sms_list); for ($i=0; $i count($emails); $i++) $emails[$i] = trim($emails[$i]); $recipient = implode(,, $emails); print $recipient; { $mail_subject=test this; $mail_body=testing; mail($recipient, $mail_subject, $mail_body); print mail sent\n; } ? Im just thinking(trying to at least) I need some sort of foreach statement like in perl, right? so that it would say foreach($recipient) { send mail } anyone that could maybe guide me? Thanks in advance C-Ya Chris Grigor -- Client Services Call Center: 0860 100 154 Fax: +27 11 340 7345 E-Mail: [EMAIL PROTECTED] -- M-WEB Business Solutions Making it happen. Go shopping @ http://shopping.mweb.co.za Get your business online @ http://business.mweb.com We all know Linux is great...it does infinite loops in 5 seconds. - Linus Torvalds -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General 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]