php-general Digest 20 Sep 2010 11:35:25 -0000 Issue 6950

2010-09-20 Thread php-general-digest-help

php-general Digest 20 Sep 2010 11:35:25 - Issue 6950

Topics (messages 308199 through 308201):

Re: PHP Email Question
308199 by: Bostjan Skufca
308200 by: TR Shaw
308201 by: Joe Jackson

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
You should format the email message content first, like this:
$msgContent = Name: . $values['name'] .\n;
$msgContent .= Address: . $values['address'] .\n;

Then you should send a this content, like this:
mail('em...@address.com', 'Subject', $msgContent, From...);

b.


On 20 September 2010 00:00, Joe Jackson priory...@googlemail.com wrote:
 Hi

 Sorry for the simple question but I am trying to get my head around PHP.  I
 have a sample PHP script that I am trying to use to send a php powered email
 message.  The snippet of code is shown below

    mail('em...@address.com', 'Subject', $values['message'], From:
 \{$values['name']}\ {$values['emailaddress']});

 This works fine, but how can I add in other fields to the email that is
 recieved?

 For example in the form there are fields called, 'emailaddress',
 'telephone', 'address' and 'name' which I need to add into the form along
 with the message field

 Also with the formatting how can I change the format of the email to

 Name: $values['name'],
 Address: etc
 Message:

 TIA

---End Message---
---BeginMessage---

On Sep 19, 2010, at 6:00 PM, Joe Jackson wrote:

 Hi
 
 Sorry for the simple question but I am trying to get my head around PHP.  I
 have a sample PHP script that I am trying to use to send a php powered email
 message.  The snippet of code is shown below
 
mail('em...@address.com', 'Subject', $values['message'], From:
 \{$values['name']}\ {$values['emailaddress']});
 
 This works fine, but how can I add in other fields to the email that is
 recieved?
 
 For example in the form there are fields called, 'emailaddress',
 'telephone', 'address' and 'name' which I need to add into the form along
 with the message field
 
 Also with the formatting how can I change the format of the email to
 
 Name: $values['name'],
 Address: etc
 Message:
 

Joe

The mail command lets you send mail (an RFC2821 envelop). The function is:

bool mail ( string $to , string $subject , string $message [, string 
$additional_headers [, string$additional_parameters ]] )

$to is where you want it to go
$subject is whatever you want the subject to be
$message is the information you want to send
Ignore the other parameters unless you are very familiar with RFCs 2821, 2822 
and their associated RFCs

So if you want to send info from a form you might want to roll it up in xml and 
send it via the message part. when you receive it you can easily decode it. If 
you don't want to do that put it in a format that you can easily decode on the 
receiving end.

Basically mail is a way to deliver information in the $message body. How you 
format the information there is up to you. However, depending on your system's 
config you are probably constrained to placing only 7bit ascii in the $message 
body.

You might also move away from the mail function and look at phpmailer at sf.net 
if you need more complex capabilities.

Tom



---End Message---
---BeginMessage---
Hi

All I need is in the message body of the email is to include more data from
the form.  At present it only displays the 'message' field value in the body
of the email.  I need to add further information into the email from the
form such as 'address' 'name' and 'telephone number'
When I have tried to add them into the PHP script

 $values['message'], ['name'], ['address'], ['telephonenumber'],

I am getting PHP errors, what would be the correct syntax I would need to
use to get the following form field values into the email body.

I greatly appreciate all your expert advice and help.


On Sun, Sep 19, 2010 at 11:37 PM, TR Shaw ts...@oitc.com wrote:


  On Sep 19, 2010, at 6:00 PM, Joe Jackson wrote:

  Hi

 Sorry for the simple question but I am trying to get my head around PHP.  I
 have a sample PHP script that I am trying to use to send a php powered
 email
 message.  The snippet of code is shown below

mail('em...@address.com', 'Subject', $values['message'], From:
 \{$values['name']}\ {$values['emailaddress']});

 This works fine, but how can I add in other fields to the email that is
 recieved?

 For example in the form there are fields called, 'emailaddress',
 'telephone', 'address' and 'name' which I need to add into the form along
 with the message field

 Also with the formatting how can I change the format of the email to

 Name: $values['name'],
 Address: etc
 Message:


 Joe

 The mail command lets you send mail (an RFC2821 envelop). 

[PHP] not able to connect to MySQL

2010-09-20 Thread MikeB
I have defined (just for testing) a user in my SQL named pubuser and 
granted it access to a database publications. Of course I also created 
the database and two tables.


I can access and manipulate the tables via phpMyAdmin and I can log in 
to sql using pubuser via the command-line interface.


I have the following php code:

?php // login.php
$db_hostname = 'localhost';
$db_database = 'publications';
$db_username = 'pubuser';
$db_password = 'abc';
?


also I have a test web page:

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
html
head
meta http-equiv=Content-Type content=text/html;  charset=UTF-8
titleConnect to SQL/title
/head
body
?php
Echo Hello;
require_once 'login.php';
echo got require;
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if (!$db_server)
 die(Unable to connect to MySQL:  . mysql_error());
 echo Congrats, it seems you have connected to the server br /
   host: $db_hostnamebr /
   user: $db_usernamebr /
   password: $db_password br  /
   for database: $db_databasebr /;
 print_r($db_server);
 ?
/body
/html

If I try to run this, it briefly says connecting to localhost and then 
indefinitely it says waiting for localhost...


If I comment out the connect statement, the rest runs.  What should I 
look for?


Thanks
MikeB


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



Re: [PHP] Auto-generating HTML

2010-09-20 Thread Steve Staples
On Mon, 2010-09-20 at 14:56 -0400, Andy McKenzie wrote:
 Hey folks,
 
   I have the feeling this is a stupid question, but I can't even find
 anything about it.  Maybe I'm just not searching for the right things.
 
   Here's the problem.  I'm writing a lot of pages, and I hate going in
 and out of PHP.  At the same time, I want my HTML to be legible.  When
 you look at it, that's kind of a problem, though... for instance
 (assume this had some PHP in the middle, and there was actually a
 reason not to just put this in HTML in the first place):
 
 Simple PHP:
 ?php
 
 echo 'html';
 echo 'head';
 echo '  titlePage Title/title';
 echo '/head';
 echo 'body';
 echo 'pThis is the page body/p';
 echo '/body';
 echo '/html';
 
 ?
 
 
 Output page source:
 htmlhead  titlePage Title/title/headbodypThis is the
 page body/p/body/html
 
 
 Now, I can go through and add a newline to the end of each line (echo
 'html' . \n; and so on), but it adds a lot of typing.  Is there a
 way to make this happen automatically?  I thought about just building
 a simple function, but I run into problem with quotes -- either I
 can't use single quotes, or I can't use double quotes.  Historically,
 I've dealt with the issue by just having ugly output code, but I'd
 like to stop doing that.  How do other people deal with this?
 
 Thanks,
   Alex
 


Have you thought about SMARTY templates?

easy to use, it's just a class, and you write your html in template
files, which are easier to read than in your php files.

Just a thought... i personally LOVE smarty template.

Steve


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



Re: [PHP] Auto-generating HTML

2010-09-20 Thread Rick Pasotto
On Mon, Sep 20, 2010 at 03:02:35PM -0400, TR Shaw wrote:
 
 On Sep 20, 2010, at 2:56 PM, Andy McKenzie wrote:
 
  Hey folks,
  
   I have the feeling this is a stupid question, but I can't even find
  anything about it.  Maybe I'm just not searching for the right things.
  
   Here's the problem.  I'm writing a lot of pages, and I hate going in
  and out of PHP.  At the same time, I want my HTML to be legible.  When
  you look at it, that's kind of a problem, though... for instance
  (assume this had some PHP in the middle, and there was actually a
  reason not to just put this in HTML in the first place):
  
  Simple PHP:
  ?php
  
  echo 'html';
  echo 'head';
  echo '  titlePage Title/title';
  echo '/head';
  echo 'body';
  echo 'pThis is the page body/p';
  echo '/body';
  echo '/html';
  
  ?
  
  
  Output page source:
  htmlhead  titlePage Title/title/headbodypThis is the
  page body/p/body/html
  
  
  Now, I can go through and add a newline to the end of each line (echo
  'html' . \n; and so on), but it adds a lot of typing.  Is there a
  way to make this happen automatically?  I thought about just building
  a simple function, but I run into problem with quotes -- either I
  can't use single quotes, or I can't use double quotes.  Historically,
  I've dealt with the issue by just having ugly output code, but I'd
  like to stop doing that.  How do other people deal with this?
  
  Thanks,
   Alex
 
 Alex
 
 Just add a \n at the end as
 
 echo 'html\n';

That will not work. Single quotes means that the '\n' is not interpreted
as a new line so you'll see a bunch of '\n' in the output.

What I sometimes do is:

$out = array();
$out[] = 'html';
$out[] = 'head';
$out[] = '  titlePage Title/title';
$out[] = '/head';
$out[] = 'body';
$out[] = 'pThis is the page body/p';
$out[] = '/body';
$out[] = '/html';
echo join(\n,$out);

-- 
Act as if you were already happy and that will tend to make you happy.
-- Dale Carnegie
Rick Pasottor...@niof.nethttp://www.niof.net

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



Re: [PHP] Auto-generating HTML

2010-09-20 Thread Andy McKenzie
On Mon, Sep 20, 2010 at 3:47 PM, Steve Staples sstap...@mnsi.net wrote:
 On Mon, 2010-09-20 at 14:56 -0400, Andy McKenzie wrote:
 Hey folks,

   I have the feeling this is a stupid question, but I can't even find
 anything about it.  Maybe I'm just not searching for the right things.

   Here's the problem.  I'm writing a lot of pages, and I hate going in
 and out of PHP.  At the same time, I want my HTML to be legible.  When
 you look at it, that's kind of a problem, though... for instance
 (assume this had some PHP in the middle, and there was actually a
 reason not to just put this in HTML in the first place):

 Simple PHP:
 ?php

 echo 'html';
 echo 'head';
 echo '  titlePage Title/title';
 echo '/head';
 echo 'body';
 echo 'pThis is the page body/p';
 echo '/body';
 echo '/html';

 ?


 Output page source:
 htmlhead  titlePage Title/title/headbodypThis is the
 page body/p/body/html


 Now, I can go through and add a newline to the end of each line (echo
 'html' . \n; and so on), but it adds a lot of typing.  Is there a
 way to make this happen automatically?  I thought about just building
 a simple function, but I run into problem with quotes -- either I
 can't use single quotes, or I can't use double quotes.  Historically,
 I've dealt with the issue by just having ugly output code, but I'd
 like to stop doing that.  How do other people deal with this?

 Thanks,
   Alex



 Have you thought about SMARTY templates?

 easy to use, it's just a class, and you write your html in template
 files, which are easier to read than in your php files.

 Just a thought... i personally LOVE smarty template.

 Steve



I've never used it, but I may take a closer look.  Overall I tend to
find templates and pre-built frameworks frustrating, but it may be
time to break down and learn to use them.

-Alex

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



Re: [PHP] Auto-generating HTML

2010-09-20 Thread Andy McKenzie
On Mon, Sep 20, 2010 at 3:50 PM, Rick Pasotto r...@niof.net wrote:
 On Mon, Sep 20, 2010 at 03:02:35PM -0400, TR Shaw wrote:

 On Sep 20, 2010, at 2:56 PM, Andy McKenzie wrote:

  Hey folks,
 
   I have the feeling this is a stupid question, but I can't even find
  anything about it.  Maybe I'm just not searching for the right things.
 
   Here's the problem.  I'm writing a lot of pages, and I hate going in
  and out of PHP.  At the same time, I want my HTML to be legible.  When
  you look at it, that's kind of a problem, though... for instance
  (assume this had some PHP in the middle, and there was actually a
  reason not to just put this in HTML in the first place):
 
  Simple PHP:
  ?php
 
  echo 'html';
  echo 'head';
  echo '  titlePage Title/title';
  echo '/head';
  echo 'body';
  echo 'pThis is the page body/p';
  echo '/body';
  echo '/html';
 
  ?
 
 
  Output page source:
  htmlhead  titlePage Title/title/headbodypThis is the
  page body/p/body/html
 
 
  Now, I can go through and add a newline to the end of each line (echo
  'html' . \n; and so on), but it adds a lot of typing.  Is there a
  way to make this happen automatically?  I thought about just building
  a simple function, but I run into problem with quotes -- either I
  can't use single quotes, or I can't use double quotes.  Historically,
  I've dealt with the issue by just having ugly output code, but I'd
  like to stop doing that.  How do other people deal with this?
 
  Thanks,
   Alex

 Alex

 Just add a \n at the end as

 echo 'html\n';

 That will not work. Single quotes means that the '\n' is not interpreted
 as a new line so you'll see a bunch of '\n' in the output.

 What I sometimes do is:

 $out = array();
 $out[] = 'html';
 $out[] = 'head';
 $out[] = '  titlePage Title/title';
 $out[] = '/head';
 $out[] = 'body';
 $out[] = 'pThis is the page body/p';
 $out[] = '/body';
 $out[] = '/html';
 echo join(\n,$out);


Interesting.  I hadn't thought of that, but it could work.  It'd still
be quite a bit of extra typing, but at least I find it more
readable...

-Alex

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



Re: [PHP] Auto-generating HTML

2010-09-20 Thread Peter Lind
On 20 September 2010 21:56, Andy McKenzie amckenz...@gmail.com wrote:
 On Mon, Sep 20, 2010 at 3:50 PM, Rick Pasotto r...@niof.net wrote:
 On Mon, Sep 20, 2010 at 03:02:35PM -0400, TR Shaw wrote:

 On Sep 20, 2010, at 2:56 PM, Andy McKenzie wrote:

  Hey folks,
 
   I have the feeling this is a stupid question, but I can't even find
  anything about it.  Maybe I'm just not searching for the right things.
 
   Here's the problem.  I'm writing a lot of pages, and I hate going in
  and out of PHP.  At the same time, I want my HTML to be legible.  When
  you look at it, that's kind of a problem, though... for instance
  (assume this had some PHP in the middle, and there was actually a
  reason not to just put this in HTML in the first place):
 
  Simple PHP:
  ?php
 
  echo 'html';
  echo 'head';
  echo '  titlePage Title/title';
  echo '/head';
  echo 'body';
  echo 'pThis is the page body/p';
  echo '/body';
  echo '/html';
 
  ?
 
 
  Output page source:
  htmlhead  titlePage Title/title/headbodypThis is the
  page body/p/body/html
 
 
  Now, I can go through and add a newline to the end of each line (echo
  'html' . \n; and so on), but it adds a lot of typing.  Is there a
  way to make this happen automatically?  I thought about just building
  a simple function, but I run into problem with quotes -- either I
  can't use single quotes, or I can't use double quotes.  Historically,
  I've dealt with the issue by just having ugly output code, but I'd
  like to stop doing that.  How do other people deal with this?
 
  Thanks,
   Alex

 Alex

 Just add a \n at the end as

 echo 'html\n';

 That will not work. Single quotes means that the '\n' is not interpreted
 as a new line so you'll see a bunch of '\n' in the output.

 What I sometimes do is:

 $out = array();
 $out[] = 'html';
 $out[] = 'head';
 $out[] = '  titlePage Title/title';
 $out[] = '/head';
 $out[] = 'body';
 $out[] = 'pThis is the page body/p';
 $out[] = '/body';
 $out[] = '/html';
 echo join(\n,$out);


 Interesting.  I hadn't thought of that, but it could work.  It'd still
 be quite a bit of extra typing, but at least I find it more
 readable...


Ash already mentioned it: heredoc format. Much easier, less typing,
easier to read, keeps formatting, etc, etc etc.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype

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



Re: [PHP] not able to connect to MySQL

2010-09-20 Thread Bastien Koert
On Mon, Sep 20, 2010 at 3:37 PM, MikeB mpbr...@gmail.com wrote:
 I have defined (just for testing) a user in my SQL named pubuser and
 granted it access to a database publications. Of course I also created the
 database and two tables.

 I can access and manipulate the tables via phpMyAdmin and I can log in to
 sql using pubuser via the command-line interface.

 I have the following php code:

    ?php // login.php
    $db_hostname = 'localhost';
    $db_database = 'publications';
    $db_username = 'pubuser';
    $db_password = 'abc';
    ?


 also I have a test web page:

 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
 html
 head
 meta http-equiv=Content-Type content=text/html;  charset=UTF-8
 titleConnect to SQL/title
 /head
 body
 ?php
 Echo Hello;
 require_once 'login.php';
 echo got require;
 $db_server = mysql_connect($db_hostname, $db_username, $db_password);
 if (!$db_server)
  die(Unable to connect to MySQL:  . mysql_error());
  echo Congrats, it seems you have connected to the server br /
       host: $db_hostnamebr /
       user: $db_usernamebr /
       password: $db_password br  /
       for database: $db_databasebr /;
  print_r($db_server);
  ?
 /body
 /html

 If I try to run this, it briefly says connecting to localhost and then
 indefinitely it says waiting for localhost...

 If I comment out the connect statement, the rest runs.  What should I look
 for?

 Thanks
 MikeB


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



If you gave the priv through phpmyadmin, you might want to try running
FLUSH PRIVILEGES to get those new ones to take effect.

-- 

Bastien

Cat, the other other white meat

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



[PHP] Re: Auto-generating HTML

2010-09-20 Thread Carlos Medina

Am 20.09.2010 20:56, schrieb Andy McKenzie:

Hey folks,

   I have the feeling this is a stupid question, but I can't even find
anything about it.  Maybe I'm just not searching for the right things.

   Here's the problem.  I'm writing a lot of pages, and I hate going in
and out of PHP.  At the same time, I want my HTML to be legible.  When
you look at it, that's kind of a problem, though... for instance
(assume this had some PHP in the middle, and there was actually a
reason not to just put this in HTML in the first place):

Simple PHP:
?php

echo 'html';
echo 'head';
echo 'titlePage Title/title';
echo '/head';
echo 'body';
echo 'pThis is the page body/p';
echo '/body';
echo '/html';

?


Output page source:
htmlhead   titlePage Title/title/headbodypThis is the
page body/p/body/html


Now, I can go through and add a newline to the end of each line (echo
'html' . \n; and so on), but it adds a lot of typing.  Is there a
way to make this happen automatically?  I thought about just building
a simple function, but I run into problem with quotes -- either I
can't use single quotes, or I can't use double quotes.  Historically,
I've dealt with the issue by just having ugly output code, but I'd
like to stop doing that.  How do other people deal with this?

Thanks,
   Alex

Hi Alex,
yes you can build a lot of classes to build the html you want and 
produce elegant and clean code. But, the job to do that is enorm, and 
sincerly i dont know what is better.


You can use some templating system like Zend Framwork and if not 
possible consider to use str_replace() to parse your Template and 
replace the variables in there. You can use a token like ###VAR_NAME### 
to address a variable like $var_name or something like this.


Regards

Carlos

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



[PHP] Invalid chars in XML

2010-09-20 Thread robert mena
Hi,

I am trying to parse a XML file with simplexml_load but it gave me error.
 While inspecting the contents I found a  inside the value of a tag.
tagsomething  something/tag.

After I've removed the  everything went fine.  So which chars I should not
put in my file?   Should I use some conversion function like html_entities?

Does the receiver of the XML has to do anything to convert is back?


Re: [PHP] Auto-generating HTML

2010-09-20 Thread Andy McKenzie
On Mon, Sep 20, 2010 at 3:59 PM, Peter Lind peter.e.l...@gmail.com wrote:
 On 20 September 2010 21:56, Andy McKenzie amckenz...@gmail.com wrote:
 On Mon, Sep 20, 2010 at 3:50 PM, Rick Pasotto r...@niof.net wrote:
 On Mon, Sep 20, 2010 at 03:02:35PM -0400, TR Shaw wrote:

 On Sep 20, 2010, at 2:56 PM, Andy McKenzie wrote:

  Hey folks,
 
   I have the feeling this is a stupid question, but I can't even find
  anything about it.  Maybe I'm just not searching for the right things.
 
   Here's the problem.  I'm writing a lot of pages, and I hate going in
  and out of PHP.  At the same time, I want my HTML to be legible.  When
  you look at it, that's kind of a problem, though... for instance
  (assume this had some PHP in the middle, and there was actually a
  reason not to just put this in HTML in the first place):
 
  Simple PHP:
  ?php
 
  echo 'html';
  echo 'head';
  echo '  titlePage Title/title';
  echo '/head';
  echo 'body';
  echo 'pThis is the page body/p';
  echo '/body';
  echo '/html';
 
  ?
 
 
  Output page source:
  htmlhead  titlePage Title/title/headbodypThis is the
  page body/p/body/html
 
 
  Now, I can go through and add a newline to the end of each line (echo
  'html' . \n; and so on), but it adds a lot of typing.  Is there a
  way to make this happen automatically?  I thought about just building
  a simple function, but I run into problem with quotes -- either I
  can't use single quotes, or I can't use double quotes.  Historically,
  I've dealt with the issue by just having ugly output code, but I'd
  like to stop doing that.  How do other people deal with this?
 
  Thanks,
   Alex

 Alex

 Just add a \n at the end as

 echo 'html\n';

 That will not work. Single quotes means that the '\n' is not interpreted
 as a new line so you'll see a bunch of '\n' in the output.

 What I sometimes do is:

 $out = array();
 $out[] = 'html';
 $out[] = 'head';
 $out[] = '  titlePage Title/title';
 $out[] = '/head';
 $out[] = 'body';
 $out[] = 'pThis is the page body/p';
 $out[] = '/body';
 $out[] = '/html';
 echo join(\n,$out);


 Interesting.  I hadn't thought of that, but it could work.  It'd still
 be quite a bit of extra typing, but at least I find it more
 readable...


 Ash already mentioned it: heredoc format. Much easier, less typing,
 easier to read, keeps formatting, etc, etc etc.

 Regards
 Peter

 --
 hype
 WWW: http://plphp.dk / http://plind.dk
 LinkedIn: http://www.linkedin.com/in/plind
 BeWelcome/Couchsurfing: Fake51
 Twitter: http://twitter.com/kafe15
 /hype


You may well be right;  it's a format I haven't used much, but it may
well be the right choice here.


I think the main thing I'm seeing is that there isn't a single,
accepted, simple way to do this:  no matter what I do, it will be a
workaround of some type.  Either I'm adding complexity (a function to
convert everything), or I'm adding lines (heredoc/nowdoc seem to
require that the opening and closing tags be on lines without any of
the string on them), or I'm adding typing (adding ' . \n' to the end
of every line of HTML).  Perhaps I'll put some effort into building a
function to do it, but not this week... I think for now I'll keep
appending those newlines, and just have more code to fix at a later
date.  It's reasonably clean, it's just mildly annoying.

Thanks, all, and if anyone comes up with a really elegant solution,
please let me know!

-Alex

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



Re: [PHP] Auto-generating HTML

2010-09-20 Thread Andy McKenzie
Here's a related question maybe one of you can answer:  is there any
place in HTML (not PHP, but actually in HTML) where there's a
difference between a single quote and a double quote?  As nearly as I
can tell, it shouldn't ever matter.  If that's the case, using
double-quotes to enclose an echo gets a lot simpler...

-Alex

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



Re: [PHP] Invalid chars in XML

2010-09-20 Thread Bastien Koert
On Mon, Sep 20, 2010 at 4:07 PM, robert mena robert.m...@gmail.com wrote:
 Hi,

 I am trying to parse a XML file with simplexml_load but it gave me error.
  While inspecting the contents I found a  inside the value of a tag.
 tagsomething  something/tag.

 After I've removed the  everything went fine.  So which chars I should not
 put in my file?   Should I use some conversion function like html_entities?

 Does the receiver of the XML has to do anything to convert is back?



The following should not be used inside XML

 ampersand
' single quote
 double quote
 greater than
 less than

you could simply wrap all your data in CDATA tags
-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] Auto-generating HTML

2010-09-20 Thread Bastien Koert
On Mon, Sep 20, 2010 at 4:52 PM, Andy McKenzie amckenz...@gmail.com wrote:
 Here's a related question maybe one of you can answer:  is there any
 place in HTML (not PHP, but actually in HTML) where there's a
 difference between a single quote and a double quote?  As nearly as I
 can tell, it shouldn't ever matter.  If that's the case, using
 double-quotes to enclose an echo gets a lot simpler...

 -Alex

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



The standard suggests that double quotes are to be used for HTML
attributes. It might be easier to use single quotes to wrap the whole
set and therefore allow the user of double quotes in your output.

My personal preference in what you are talking about is to have a view
function that takes an array of data and perhaps errors and then shows
the form with no other processing than maybe a loop. That way I can
create the HTML as I please, copy and paste it into the function, and
then do what ever I need to, to process the data before turning that
into an array and passing it into the function

function showForm($data, $errors){
?
Name: input type=text value=?php echo $data['name']; ? name=name

?php

}//end function

?
-- 

Bastien

Cat, the other other white meat

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



[PHP] Re: not able to connect to MySQL

2010-09-20 Thread MikeB

Bastien Koert wrote:

On Mon, Sep 20, 2010 at 3:37 PM, MikeBmpbr...@gmail.com  wrote:

I have defined (just for testing) a user in my SQL named pubuser and
granted it access to a database publications. Of course I also created the
database and two tables.

I can access and manipulate the tables via phpMyAdmin and I can log in to
sql using pubuser via the command-line interface.

I have the following php code:

?php // login.php
$db_hostname = 'localhost';
$db_database = 'publications';
$db_username = 'pubuser';
$db_password = 'abc';
?


also I have a test web page:

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
html
head
meta http-equiv=Content-Type content=text/html;  charset=UTF-8
titleConnect to SQL/title
/head
body
?php
Echo Hello;
require_once 'login.php';
echo got require;
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if (!$db_server)
  die(Unable to connect to MySQL:  . mysql_error());
  echo Congrats, it seems you have connected to the serverbr /
   host: $db_hostnamebr /
   user: $db_usernamebr /
   password: $db_passwordbr  /
   for database: $db_databasebr /;
  print_r($db_server);
  ?
/body
/html

If I try to run this, it briefly says connecting to localhost and then
indefinitely it says waiting for localhost...

If I comment out the connect statement, the rest runs.  What should I look
for?

Thanks
MikeB


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




If you gave the priv through phpmyadmin, you might want to try running
FLUSH PRIVILEGES to get those new ones to take effect.



I did that - in fact, I shut down apache and mysql and restarted then as 
well.



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



[PHP] Building SoapClient as an extension

2010-09-20 Thread Jon Drukman
Is it possible to build SoapClient as a loadable extension?  For various
reasons, I don't want to have to recompile PHP from scratch.  It would be much
simpler to just distribute another .so and .ini file.

How would I do that, if it's possible?

-jsd-


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



Re: [PHP] Invalid chars in XML

2010-09-20 Thread Ellis Antaya
CDATA tags is what you need

---
Ellis
(Sent from my iPod)

On 2010-09-20, at 16:57, Bastien Koert phps...@gmail.com wrote:

 On Mon, Sep 20, 2010 at 4:07 PM, robert mena robert.m...@gmail.com wrote:
 Hi,
 
 I am trying to parse a XML file with simplexml_load but it gave me error.
  While inspecting the contents I found a  inside the value of a tag.
 tagsomething  something/tag.
 
 After I've removed the  everything went fine.  So which chars I should not
 put in my file?   Should I use some conversion function like html_entities?
 
 Does the receiver of the XML has to do anything to convert is back?
 
 
 
 The following should not be used inside XML
 
  ampersand
 ' single quote
  double quote
 greater than
  less than
 
 you could simply wrap all your data in CDATA tags
 -- 
 
 Bastien
 
 Cat, the other other white meat
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



Re: [PHP] Building SoapClient as an extension

2010-09-20 Thread Phpster
It's already done

http://wso2.com/products/web-services-framework/php/



Bastien

Sent from my iPod

On Sep 20, 2010, at 19:20, Jon Drukman j...@cluttered.com wrote:

 Is it possible to build SoapClient as a loadable extension?  For various
 reasons, I don't want to have to recompile PHP from scratch.  It would be much
 simpler to just distribute another .so and .ini file.
 
 How would I do that, if it's possible?
 
 -jsd-
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



[PHP] Re: Building SoapClient as an extension

2010-09-20 Thread Jon Drukman
Phpster phpster at gmail.com writes:

 
 It's already done
 
 http://wso2.com/products/web-services-framework/php/
 

I don't know what that has to do with what I asked.

I found the answer on my own:

./configure --enable-soap=shared

Produces a modules/soap.so file that can be loaded in to php at run time.



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