php-general Digest 7 Nov 2005 08:03:07 -0000 Issue 3780

Topics (messages 225210 through 225223):

use SMB share to run php files
        225210 by: Ross

Re: PGP 5 start up issue
        225211 by: Unknown Unknown
        225212 by: Vizion

PHP 5.1 release ?
        225213 by: Dan Rossi

Line breaks in mail function?
        225214 by: Murray . PlanetThoughtful
        225215 by: Jasper Bryant-Greene
        225216 by: Richard Leclair
        225218 by: Murray . PlanetThoughtful

Mysql & php & Load Data Infiles
        225217 by: Vizion

Re: preg for unicode strings?
        225219 by: Niels Ganser

Making functions available from another script
        225220 by: Richard Leclair

Mcrypt 3DES encrypt/decrypt Help
        225221 by: yangguang1981.gmail.com

Re: Template style question
        225222 by: Stephen Leaf

Creating PDF from a Image
        225223 by: Manoj Kr. Sheoran

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Ok been looking into in and know a bit of terminology now.


I have an SMB share on my mac which is my WWWROOT folder on my windows 
computer. These files have all permissions enabled so I can edit in 
dreamweaver (on mac). All I want to so is setup PHP/Apache so it recognises 
the WWWROOT folder and everything under it (folders and files) so it runs 
the php.

Do I have to change the userdir in httpd.conf ?? If so how?

Can I have my current folder (http://127.0.0.1/~myname/index.php) in my 
Sites folder and add an extra php enabled folder??

Thanks,


Ross 

--- End Message ---
--- Begin Message ---
I don't mean the php.ini file, I mean the extension directive setting in
php.ini

--- End Message ---
--- Begin Message ---
On Sunday 06 November 2005 12:14,  the author Unknown Unknown contributed to 
the dialogue on-
 Re: [PHP] PGP 5 start up issue: 

>I don't mean the php.ini file, I mean the extension directive setting in
>php.ini
Yep I thought that was what you meant -- it is not the cause.. I should have 
posted that I found a solution which was to use the pear functions dor those 
extensions. It seems, for some reason, that the extensions do not work on 
php5 but the pear equivalents do.. at least for me.
david
-- 
40 yrs navigating and computing in blue waters.
English Owner & Captain of British Registered 60' bluewater Ketch S/V Taurus.
 Currently in San Diego, CA. Sailing bound for Europe via Panama Canal after 
completing engineroom refit.

--- End Message ---
--- Begin Message --- Hi there just wondering when there may be a php 5.1 release ? I just went into the downloads on the php site and the link to RC1 has been removed ??
--- End Message ---
--- Begin Message ---
Hi All,

I'm building a site on a new web host and am currently working on feedback forms.

I'm using the mail() function to send the feedback to the destination mail account, and I'm having problems getting the body of the email to line break.

I've tried constructing the body with both "\n\n" and "\r\n\r\n" terminating lines where I want line breaks to appear, but both return an email with the body in one long string showing the actual "\n\n" or "\r\n\r\n" characters, as opposed to interpreting them as line breaks.

Example code:

   $body = 'From: ' . $name . '\r\n\r\n';
   $body .= 'Email:' . $email . '\r\n\r\n';
   $body .= 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . '\r\n\r\n';
   $body .= 'Feedback:\r\n\r\n';
   $body .= $feedback;
mail("[EMAIL PROTECTED]", "Feedback", $body, "From: $email\r\nReply-To: $email\r\nX-Mailer: PHP/" . phpversion());

As I said above, I've also tried using "\n\n" instead of "\r\n\r\n".

Can anyone give me some advive on how to get the linebreak characters interpreted as linebreaks?

Many thanks and much warmth,

Murray

--- End Message ---
--- Begin Message ---
On Mon, 2005-11-07 at 12:20 +1000, Murray @ PlanetThoughtful wrote:
> Example code:
> 
>     $body = 'From: ' . $name . '\r\n\r\n';
>     $body .= 'Email:' . $email . '\r\n\r\n';
>     $body .= 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . '\r\n\r\n';
>     $body .= 'Feedback:\r\n\r\n';
>     $body .= $feedback;
>     mail("[EMAIL PROTECTED]", "Feedback", $body, "From: 
> $email\r\nReply-To: $email\r\nX-Mailer: PHP/" . phpversion());
> 
> As I said above, I've also tried using "\n\n" instead of "\r\n\r\n".
> 
> Can anyone give me some advive on how to get the linebreak characters 
> interpreted as linebreaks?

Use double quotes around the parts that have \r and \n characters if you
want them to be interpreted.

-- 
Jasper Bryant-Greene
General Manager
Album Limited

e: [EMAIL PROTECTED]
w: http://www.album.co.nz/
b: http://jbg.name/
p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
a: PO Box 579, Christchurch 8015, New Zealand

--- End Message ---
--- Begin Message ---
Hi Murray,

Try doing something like this:

-------------------------------------------------------------------
$body = "From: $name
Email: $email
IP Address: $_SERVER['REMOTE_ADDR']

Feedback:

$feedback
";

$fromaddr = "$email
Reply-To: $email
X-Mailer: PHP/" . phpversion();

mail("[EMAIL PROTECTED]", "Feedback", $body, $fromaddr);
-------------------------------------------------------------------

I haven't tested this 'actual' piece of code, but I've used similar in other
emailing scripts.

Regards,
Richie !

> -----Original Message-----
> From: Murray @ PlanetThoughtful [mailto:[EMAIL PROTECTED]
> Sent: Monday, 7 November 2005 10:21 am
> To: [email protected]
> Subject: [PHP] Line breaks in mail function?
> 
> Hi All,
> 
> I'm building a site on a new web host and am currently working on
> feedback forms.
> 
> I'm using the mail() function to send the feedback to the destination
> mail account, and I'm having problems getting the body of the email to
> line break.
> 
> I've tried constructing the body with both "\n\n" and "\r\n\r\n"
> terminating lines where I want line breaks to appear, but both return an
> email with the body in one long string showing the actual "\n\n" or
> "\r\n\r\n" characters, as opposed to interpreting them as line breaks.
> 
> Example code:
> 
>     $body = 'From: ' . $name . '\r\n\r\n';
>     $body .= 'Email:' . $email . '\r\n\r\n';
>     $body .= 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . '\r\n\r\n';
>     $body .= 'Feedback:\r\n\r\n';
>     $body .= $feedback;
>     mail("[EMAIL PROTECTED]", "Feedback", $body, "From:
> $email\r\nReply-To: $email\r\nX-Mailer: PHP/" . phpversion());
> 
> As I said above, I've also tried using "\n\n" instead of "\r\n\r\n".
> 
> Can anyone give me some advive on how to get the linebreak characters
> interpreted as linebreaks?
> 
> Many thanks and much warmth,
> 
> Murray
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--- End Message ---
--- Begin Message ---
Jasper Bryant-Greene wrote:

On Mon, 2005-11-07 at 12:20 +1000, Murray @ PlanetThoughtful wrote:
Example code:

   $body = 'From: ' . $name . '\r\n\r\n';
   $body .= 'Email:' . $email . '\r\n\r\n';
   $body .= 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . '\r\n\r\n';
   $body .= 'Feedback:\r\n\r\n';
   $body .= $feedback;
mail("[EMAIL PROTECTED]", "Feedback", $body, "From: $email\r\nReply-To: $email\r\nX-Mailer: PHP/" . phpversion());

As I said above, I've also tried using "\n\n" instead of "\r\n\r\n".

Can anyone give me some advive on how to get the linebreak characters interpreted as linebreaks?

Use double quotes around the parts that have \r and \n characters if you
want them to be interpreted.

Ah, damn you Jasper, I should have noticed that myself.

Don't you hate it when you've been staring at code too long to notice the obvious?

Thank you!

Much warmth,

Murray

--- End Message ---
--- Begin Message ---
While I think this is primarily a mysql  syntax problem I have asked on the 
mysql forum but not got a reply. I am trying using php to set up a system for 
loading a new data base using the Load Data Infile statement. I could not get 
it to work properly with php so I thought I would try some command line test.

Does anyone know the loaction of a suitable php script that would handle a 
list of files and tables for loading into a database (preferably doing an 
initial dummy run using temporary tables with an error report). If not when I 
get this wretched syntax issue solved I guess I might have one available 
fairly soon.

Here are my notes:

This exercise was a test in preparation for a plan to use Load Data Infile for  
initallising a new database comprising over 80 tables. The database currently 
has no data. The first field is auto-increment. 

What am I doing wrong here? 

If I cannot do it using Load Data Infile what alternatives would you suggest? 

___________________________________________________________ 
Here is mysql command line dialogue on a win XP development machine: 
____________________________________________________________ 
Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 85 to server version: 5.0.13-rc-nt-log 

Type 'help;' or '\h' for help. Type '\c' to clear the buffer. 

mysql> use NewBuddies; 
Database changed 

mysql> load data local infile 
'E:/Development/LBuddies/Documemntation/lbcm_diet_ 
types.txt' REPLACE into table lbcm_diet_types fields terminated by ',' 
ENCLOSED 
by '"'; 
ERROR 1265 (01000): Data truncated for column 'Help' at row 1 
mysql> describe lbcm_diet_types; 
+-----------------+-------------+------+-----+-------------+----------------+ 
| Field | Type | Null | Key | Default | Extra | 
+-----------------+-------------+------+-----+-------------+----------------+ 
| Diet_Type_ID | int(11) | NO | PRI | NULL | auto_increment | 
| Diet_Type_Title | varchar(30) | NO | UNI | Enter Title | | 
| Diet_Type_Descr | text | NO | | | | 
| Help | int(11) | NO | | 1 | | 
+-----------------+-------------+------+-----+-------------+----------------+ 
4 rows in set (0.01 sec) 

mysql> select * from lbcm_diet_types; 
Empty set (0.00 sec) 

mysql> 
_______________________________________________________________________________ 
Here is the content of the first file created as a text file using editor 
macromedia: 
_______________________________________________________________________________ 

"1","Unlimited","Anything goes","1" 
"2","Lacto-Vegetarian","Vegetarian consuming milk products, no meat, no 
fish","1" 
"3","Fish_Lacto-Vegetarian","Lacto Vegetarian plus fish","1" 
I then realized my obvious mistake two "'"s in the third field on line two. I 
removed "REPLACE" from the command and ran it again: 

mysql> load data local infile 
'E:/Development/LBuddies/Documemntation/lbcm_diet_ 
types.txt' into table lbcm_diet_types fields terminated by ',' ENCLOSED by 
'"'; 

Query OK, 2 rows affected, 3 warnings (0.00 sec) 
Records: 2 Deleted: 0 Skipped: 0 Warnings: 3 

mysql> select * from lbcm_diet_types; 
+--------------+-----------------------+----------------------------+------+ 
| Diet_Type_ID | Diet_Type_Title | Diet_Type_Descr | Help | 
+--------------+-----------------------+----------------------------+------+ 
| 1 | Unlimited | Anything goes | 1 | 
| 3 | Fish_Lacto-Vegetarian | Lacto Vegetarian plus fish | 0 | 
+--------------+-----------------------+----------------------------+------+ 
2 rows in set (0.00 sec) 

/* OK we have progress BUT */ 
/*What happened to line 2? */ 
/* Why 0 for the help ID on line 3? */ 


/* So I amended the file to read: */ 

"4","Diabetic","See Diet Sheet","1" 
"5","Glutenfree","No wheat products or other glutenous grains","1" 
"6","Nut allergic","Avoid all nut products","1" 

/* and with the command:*/ 

mysql> load data local infile 
'E:/Development/LBuddies/Documemntation/lbcm_diet_ 
types.txt' into table lbcm_diet_types fields terminated by ',' ENCLOSED by 
'"'; 

Query OK, 2 rows affected, 3 warnings (0.00 sec) 
Records: 2 Deleted: 0 Skipped: 0 Warnings: 3 

/* I got:*/ 
mysql> select * from lbcm_diet_types; 
+--------------+-----------------------+----------------------------+------+ 
| Diet_Type_ID | Diet_Type_Title | Diet_Type_Descr | Help | 
+--------------+-----------------------+----------------------------+------+ 
| 1 | Unlimited | Anything goes | 1 | 
| 3 | Fish_Lacto-Vegetarian | Lacto Vegetarian plus fish | 0 | 
| 4 | Diabetic | See Diet Sheet | 1 | 
| 6 | Nut allergic | Avoid all nut products | 0 | 
+--------------+-----------------------+----------------------------+------+ 
4 rows in set (0.00 sec) 

mysql> 
/* showing that the second line from this file is again being dropped and the 
last line gets 0 for help! - I must be missing something obvious but I am 
damned if I can see it <groans> 

/* So I realize it might be due to the windows CR/LF oddity therefore I try: 
*/ 

mysql> load data local infile 
'E:/Development/LBuddies/Documemntation/lbcm_diet_ 
types.txt' into table lbcm_diet_types fields terminated by ',' ENCLOSED by 
'"'L 
ines terminated by '\r\n'; 

Query OK, 1 row affected (0.00 sec) 
Records: 3 Deleted: 0 Skipped: 2 Warnings: 0 

/* This sounds more promising */ 

mysql> select * from lbcm_diet_types; 
+--------------+-----------------------+----------------------------------------
 
-----+------+ 
| Diet_Type_ID | Diet_Type_Title | Diet_Type_Descr 
| Help | 
+--------------+-----------------------+----------------------------------------
 
-----+------+ 
| 1 | Unlimited | Anything goes 
| 1 | 
| 3 | Fish_Lacto-Vegetarian | Lacto Vegetarian plus fish 
| 0 | 
| 4 | Diabetic | See Diet Sheet 
| 1 | 
| 5 | Glutenfree | No wheat products or other glutenous gr 
ains | 1 | 
| 6 | Nut allergic | Avoid all nut products 
| 0 | 
+--------------+-----------------------+----------------------------------------
 
-----+------+ 
5 rows in set (0.00 sec) 

/* Part of the problem solved - but what about those darned zeros? */ 

Any ideas? 

Thanks in advance 

david

-- 
40 yrs navigating and computing in blue waters.
English Owner & Captain of British Registered 60' bluewater Ketch S/V Taurus.
 Currently in San Diego, CA. Sailing bound for Europe via Panama Canal after 
completing engineroom refit.

--- End Message ---
--- Begin Message ---
Andy,

try that one: /^[a-zA-Z]{3}|\p{Sc}$/u

You don't want to put \p{Sc} in square brackets as \p{Sc} itself already 
is a character class. Umm.. Kinda don't make myself clear here, do I? 
You just don't want to, it's 5am in the morning here I gotta go to the 
next bed ;p

Regards,
Niels



Andy Pieters:
> Hi
>
> Thank you for your reply.
>
> My regexp was
>
> /^([a-zA-Z]{3,}|[\W])/
>
> Meaning match any string that is either
> 3 letters
> or
> 1 word character
>
> I'd like to change this to
> 3 letters
> or
> 1 currency character
>
> So I changed the regexp accordingly
> /^([a-zA-Z]{3,}|[\p{Sc}])/u
>
> And I tested with £
>
> but it fails.
>
> Any ideas?

--- End Message ---
--- Begin Message ---
Hi PHP-ers,

Here's an easy one:
Q: How can I make a function available from within another php script?

Eg. B.php contains:

<?php include ".../fns.php" ?>

Which has a function fn($x);

Later on, I want to include this function in B.php somewhere.

In short:  B.php wants to use fn($x) found in A.php.

Regards,
Richie !

--- End Message ---
--- Begin Message ---
Hi all:
I wan't to use php_mcrpyt to encrypt data,but have a problem in it !

Hint:
Warning: mcrypt_encrypt(): Size of key is too large for this algorithm

Algorithm : 3DES
Key: 48bit

<?php
// Designate string to be encrypted
$string =3D "Applied Cryptography, by Bruce Schneier, is a wonderful
cryptography reference.";

// Encryption/decryption key
$key =3D "C770634F437346D7FC8FA22F9287849E741A33438EEDEAAD";

// Encryption Algorithm
$cipher_alg =3D MCRYPT_3DES;

// Create the initialization vector for added security.
$iv =3D mcrypt_create_iv(mcrypt_get_iv_size($cipher_alg,
MCRYPT_MODE_ECB), MCRYPT_RAND);

// Output original string
print "Original string: $string ";

// Encrypt $string
$encrypted_string =3D mcrypt_encrypt($cipher_alg, $key, $string,
MCRYPT_MODE_CBC, $iv);

// Convert to hexadecimal and output to browser
print "Encrypted string: ".bin2hex($encrypted_string)." ";
$decrypted_string =3D mcrypt_decrypt($cipher_alg, $key,
$encrypted_string, MCRYPT_MODE_CBC, $iv);

print "Decrypted string: $decrypted_string";
?>

--- End Message ---
--- Begin Message ---
One idea that you might try. is XSL.
instead of doing %var1% and doing a replace. you can do things like
<xsl:value-of select="var1"/>
Doing this also completely separates presentation logic from the code.
you can do other fun things like loops also.
I will warn you by saying that XSL in the beginning is a real headache to 
figure out. but after you get things down, it's very nice.
I currently have things in my sites setup to init an Object that when echo'd 
will do the XSL translation for me.
After that all I do is gather the data into an XML document and stylize it.
Simplifies websites considerably. Gather the data you need... stylize it how 
you want it.. and if you want to swap out the entire layout on the fly.

On Saturday 05 November 2005 01:10 pm, Leonard Burton wrote:
> Greetings,
>
> HI All, I hope all is well.
>
> I have set up a template parser.  Basically, it parses the template
> and finds tags with tag_name.dat file and then includes the
> tag_name.dat file.  I have considered a few other options but as of
> now I think I like what I have come up with.
>
> The only problem that I have in my design is that I have to hard code
> tables in the dat file mixing php and html.  I would prefer to be able
> to do something like:
>
> [[tag with db query]]
> <table>
> <tr><td>colname</td><td>colname</td><td>colname</td></tr>
> <tr><td>%var1%</td><Td>%var2%</td><td>%var3%</td></tr>
> </table>
> [[/tag with db query]]
>
> I would like it to be able to parse the line with the %var1% (which is
> the column name with % or some other indicator on each side) in it and
> then have it generate how many ever rows as nessecary.
>
> Currently, my parsing engine loads the template, preg_splits() it so
> each template tag is on a new line, and then passes through the
> resulting array and executes the code for whatever tag is chosen.
>
> There are a couple ideas that I have thought of but have not thought
> of any real good way so I am turning to the list.
>
> Thanks for all of your help on this list!
>
> --
> Leonard Burton, N9URK
> [EMAIL PROTECTED]
>
>
> "The prolonged evacuation would have dramatically affected the
> survivability of the occupants."

--- End Message ---
--- Begin Message ---
Hi All, 
To create  fdf with text info is very simple but I am wondering how to convert 
a PNG image into pdf file?  

Any suggestion?

Regards,
Manoj 

--- End Message ---

Reply via email to