php-general Digest 7 Dec 2004 15:52:30 -0000 Issue 3156
Topics (messages 203656 through 203668):
Re: inserting html within a mail body
203656 by: Ramil Sagum
Re: Parsing multiple XML documents as strings. Inbox
203657 by: Christian Stocker
searching with mutable criteria
203658 by: Richard Kurth
203668 by: Richard Kurth
Re: Problem with code
203659 by: Ryan King
Links displaying in Table cells
203660 by: Tomar Rajeev (ext)
Sessions and multiple windows
203661 by: Rory McKinley
203664 by: Jason Wong
203666 by: Ford, Mike
203667 by: Rory McKinley
FCK Editor
203662 by: Ryan A
Magic Quotes Issue
203663 by: Shaun
203665 by: Gareth Williams
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 ---
On Tue, 7 Dec 2004 02:31:10 -0000, Ross Hulford <[EMAIL PROTECTED]> wrote:
> Hi,
> I am using the mail() function in php andI am looking for a quick and easy
> way to make the mail_body of an auto response email with HTML tags in it so
> I can add some style to it.
Hi!
The PHPs manual page on the mail function shows an example of sending HTML mail.
http://www.php.net/manual/en/function.mail.php
I've also attached it below:
<snip>
<?php
/* recipients */
$to = "[EMAIL PROTECTED]" . ", " ; // note the comma
$to .= "[EMAIL PROTECTED]";
/* subject */
$subject = "Birthday Reminders for August";
/* message */
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
/* additional headers */
$headers .= "To: Mary <[EMAIL PROTECTED]>, Kelly <[EMAIL PROTECTED]>\r\n";
$headers .= "From: Birthday Reminder <[EMAIL PROTECTED]>\r\n";
$headers .= "Cc: [EMAIL PROTECTED]";
$headers .= "Bcc: [EMAIL PROTECTED]";
/* and now mail it */
mail($to, $subject, $message, $headers);
?>
</snip>
HTH
--
ramil
http://ramil.sagum.net
--- End Message ---
--- Begin Message ---
On Mon, 6 Dec 2004 23:10:15 +0100, Goformusic Support
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> We worked with Sablotron before but switched over to the libxslt
> library on PHP5 to perform XSL transformations. We used the wrapper
> code found on http://be.php.net/xsl so that our old xslt_ functions
> continued to work.
>
> Now, with Sablotron we used to parse multiple XML documents as strings
> and one XSL file from disk. With libxslt it doesn't seem possible
> parsing XML documents as strings.
>
> This is the old method which worked fine, using Sablotron:
>
> $args["/list_docu"] = "<content>some xml</content>";
> $result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $args, $params);
>
> This node could then be access with XSL:
> <xsl:for-each select="document('arg:/list_docu')/content">
>
> When I run this code using libxslt/PHP5 and the wrapper I get the error:
> Warning: I/O warning : failed to load external entity "arg:/list_docu"
>
> This is because the XML documents must be saved on disk I guess.
> Isn't there any way to load the XML documents as strings???
I don't know your wrapper class, but it's perfectly possible to load
XML documents from strings:
see
http://ch.php.net/manual/en/ref.xsl.php
and
http://ch.php.net/manual/en/function.dom-domdocument-loadxml.php
for further details.
chregu
>
> Grtz,
>
> Bart
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71
http://www.bitflux.ch | [EMAIL PROTECTED] | gnupg-keyid 0x5CE1DECB
--- End Message ---
--- Begin Message ---
I am having a problem with this script what it does is write the sql
needed to search for data based on mutable criteria. It works fine if
you search with all the different fields but if you only search with
one or two of the fields it creates a sql that looks like this
SELECT * FROM listing WHERE state = 'WA' AND LIMIT 0,5
It adds the AND before the limit if you use all three fields it does
not add the AND. How can I change this so it will not add the AND if
there is only a search on one or two of the fields
$cond = "AND";
$sql = 'SELECT * FROM listing ';
if($_POST["state"] != "" || $_POST["types"] != "" || $_POST["county"] !=
""){$sql .= "WHERE ";
if($_POST["state"] != ""){
$sql .= "state = '". $_POST["state"] ."'";
if($_POST["state"] != "" || $_POST["types"] != "" || $_POST["county"] !=
""){$sql .= " $cond ";}
}
if($_POST["type"] != ""){
$sql .= "types = '". $_POST["types"] ."'";
if($_POST["state"] != "" || $_POST["types"] != "" || $_POST["county"] != "")
{$sql .= " $cond ";}
}
if($_POST["county"] != ""){
$sql .= "county = '". $_POST["county"] ."'";
if($_POST["state"] != "" || $_POST["types"] != "" || $_POST["county"] !=
""){$sql.= " $cond "; }
}
)
$sql .= " LIMIT " . $from . "," . $max_results;
echo $sql
--
Best regards,
Richard mailto:[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
I am having a problem with this script what it does is write the sql
needed to search for data based on mutable criteria. It works fine if
you search with all the different fields but if you only search with
one or two of the fields it creates a sql that looks like this
SELECT * FROM listing WHERE state = 'WA' AND LIMIT 0,5
It adds the AND before the limit if you use all three fields it does
not add the AND. How can I change this so it will not add the AND if
there is only a search on one or two of the fields
$cond = "AND";
$sql = 'SELECT * FROM listing ';
if($_POST["state"] != "" || $_POST["types"] != "" || $_POST["county"] !=
""){$sql .= "WHERE ";
if($_POST["state"] != ""){
$sql .= "state = '". $_POST["state"] ."'";
if($_POST["state"] != "" || $_POST["types"] != "" || $_POST["county"] !=
""){$sql .= " $cond ";}
}
if($_POST["type"] != ""){
$sql .= "types = '". $_POST["types"] ."'";
if($_POST["state"] != "" || $_POST["types"] != "" || $_POST["county"] != "")
{$sql .= " $cond ";}
}
if($_POST["county"] != ""){
$sql .= "county = '". $_POST["county"] ."'";
if($_POST["state"] != "" || $_POST["types"] != "" || $_POST["county"] !=
""){$sql.= " $cond "; }
}
)
$sql .= " LIMIT " . $from . "," . $max_results;
echo $sql
--
Best regards,
Richard mailto:[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
On Dec 5, 2004, at 9:05 PM, Richard Kurth wrote:
I am having a problem with the code below it provides the first page
with out any problem but when I select the next page it shows all the
results from the first page and the results from the second page. It
does the same thing on the third page also. I have been looking at it
for two days and can not fined the error in the code
<?php
include("include/common.php");
include("$config[template_path]/user_top.html");
I don't see where you set $page. And I'm betting that you don't.
Variables are not persistent from one page-load to the next.
try adding this line in here:
$page = $_GET['page'];
// If current page number, use it
// if not, set one!
if(!isset($page)){
$page = 1;
} else {
$page = $page;
}
--- End Message ---
--- Begin Message ---
Dear All,
After clicking on a link of a menu in a PHP page, I want to display that
link in cell of a table. Please let me know how to open this link in a table
cell.
Thanking in anticipation.
Thanks and Regards,
Rajeev Tomar
--- End Message ---
--- Begin Message ---
Hi List
I am afraid that this is going to be a long complicated question. And to
start off with I have RTFM, STFA, STFW - and have yet to find the answer
I am looking for - unless, perhaps I am asking the wrong question?
But back to the subject - I have an app that allows users to open
multiple windows to perform certain tasks. Even though the user has
multiple windows, from the point of view of the app it is classified as
a single session.
For this app I have an object stored in a session variable that I use
to administer logins, permissions etc. - call it $_SESSION['policeman'].
This object stores information that is common to all windows (e.g. path
to common error logging, current user id etc).
A simpler version fo this app did not allow for the opening of multiple
windows and I needed to check if the user was logged in every time
he/she went to a new page. I did this by putting a call to the
checkLogin method inside $_SESSION['policeman']'s __wakeup method. Then
, every time PHP unserialized $_SESSION['policeman'] it checked for the
login.
I would like to do a similar thing with the more complex apps, but i do
not know enough to be sure that it won't cause a problem and to be quite
honest, I am not even entirely sure how to test it. My problen lies in
a scenario such as this:
User clicks through to page_3.php from page_2.php.
Page_3.php starts, unserializes $_SESSION['policeman'], and begins a
lengthy SQL query that will take a few minutes to complete.
The user wants to do something else so he\she opens a new window for
page_9.php (at this point page_3.php has yet to complete).
Now, the question is, what will PHP do when it starts with page_9? Will
it unserialize $_SESSION['policeman'] again, even though it already has
an unserialized instance of $_SESSION['policeman']? If it does
unserialize, does that mean that it creates a second instance of
$_SESSION['policeman'], thereby breaking the common link that I am
trying to provide?
I hope someone will be able to point me in the right direction...
TIA
--
Rory McKinley
Nebula Solutions
+27 21 555 3227 - office
+27 21 551 0676 - fax
+27 82 857 2391 - mobile
www.nebula.co.za
====================
--- End Message ---
--- Begin Message ---
On Tuesday 07 December 2004 20:50, Rory McKinley wrote:
> User clicks through to page_3.php from page_2.php.
>
> Page_3.php starts, unserializes $_SESSION['policeman'], and begins a
> lengthy SQL query that will take a few minutes to complete.
When Page_3.php does its business it will have locked the session data file
and only that instance of Page_3.php will have access to it. It will
automatically release the lock when the page finishes executing or when you
explicitly issue a session_write_close().
> The user wants to do something else so he\she opens a new window for
> page_9.php (at this point page_3.php has yet to complete).
>
> Now, the question is, what will PHP do when it starts with page_9?
As Page_3.php is still doing its business the session data file is locked and
when page_9.php tries to session_start() and finds it has no access to it
will suspend execution until the lock is relinquished by Page_3.php.
> Will
> it unserialize $_SESSION['policeman'] again,
Yes ...
> even though it already has
> an unserialized instance of $_SESSION['policeman']?
... because by the time it has access to the session data that unserialized
instance of $_SESSION['policeman'] has already gone ...
> If it does
> unserialize, does that mean that it creates a second instance of
> $_SESSION['policeman'], thereby breaking the common link that I am
> trying to provide?
Only one instance of $_SESSION['policeman'] can be in existence for a
particular session_id.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
<rcw> liiwi: printk("CPU0 on fire
");
*/
--- End Message ---
--- Begin Message ---
To view the terms under which this email is distributed, please go to
http://disclaimer.leedsmet.ac.uk/email.htm
On 07 December 2004 12:50, Rory McKinley wrote:
[....]
> Page_3.php starts, unserializes $_SESSION['policeman'], and begins a
> lengthy SQL query that will take a few minutes to complete.
>
> The user wants to do something else so he\she opens a new window for
> page_9.php (at this point page_3.php has yet to complete).
>
> Now, the question is, what will PHP do when it starts with
> page_9? Will
> it unserialize $_SESSION['policeman'] again, even though it
> already has
> an unserialized instance of $_SESSION['policeman']? If it does
> unserialize, does that mean that it creates a second instance of
> $_SESSION['policeman'], thereby breaking the common link that I am
> trying to provide?
Basically, this is a "that's not how it works" answer. The fundamental
point you have to realise is that every php page is completely independent,
and nothing you can do in one can directly affect anything in another (even
if they use the same script to generate their output). The ways of sending
information from one (invocation of a) script to another all use some
external medium: POST or GET variables, a SESSION, a database, or COOKIES.
Of these, only the database is purely server-side; the session very nearly
is, maintaining only the session id client-side; whilst GET, POST and
COOKIES all involve a full round-trip to the client. (On the client side,
of course, you can use JavaScript to affect multiple windows, but that has
nothing to do with server-side PHP.)
So the answers to your specific questions are: yes, page_9 will unserialize
again (because it knows nothing of the page_3 instance -- whatever the "it"
is you're thinking of that "already has an unserialized instance", it
doesn't exist); and yes, a second, completely independent, instance will be
created, because there is no such common link in the way you appear to be
thinking of it.
Another kicker is that only one script can access the session data at any
one time -- in your scenario, page_9 will stall at session_start() until
page_3 releases the session lock. This will be at the end of the page_3
script, unless you explicitly release it earlier with a
session_write_close(), for example. If you do this, and the page_9 script
starts before the page_3 script has finished, you will have two, completely
separate, local instances of $_SESSION['policeman'].
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
--- End Message ---
--- Begin Message ---
Jason Wong wrote:
On Tuesday 07 December 2004 20:50, Rory McKinley wrote:
<snip>
As Page_3.php is still doing its business the session data file is locked and
when page_9.php tries to session_start() and finds it has no access to it
will suspend execution until the lock is relinquished by Page_3.php.
<snip>
... because by the time it has access to the session data that unserialized
instance of $_SESSION['policeman'] has already gone ...
<snip>
Hi Jason
Thanks for the rapid response.
So if I understand you correctly if the first page takes a half hour to
complete its queries, then the second page is going to sit for a half an
hour before it can access the session variables?
So the only way for the user to be able to do anything while the first
page is at work is to get a new session id for each new window?
In such a case, is there any way to pass information between sets of
session variables in such a case? (I.e from $_SESSION['policeman'] of
session number 1 and $_SESSIOn['policeman'] of session number 2)
TIA
--
Rory McKinley
Nebula Solutions
+27 21 555 3227 - office
+27 21 551 0676 - fax
+27 82 857 2391 - mobile
www.nebula.co.za
====================
--- End Message ---
--- Begin Message ---
Hey all,
I came accross this free dhtml editor while browsing the net for popular
projects, anybody else using FCK Editor?
If yes, any problems? if no, heres the url 'case you want to check it out
yourself: http://www.fckeditor.net/
Cheers,
Ryan
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.289 / Virus Database: 265.4.6 - Release Date: 12/5/2004
--- End Message ---
--- Begin Message ---
Hi,
I have been investigating the problem of apostrphes in a mysql insert /
update. I use a db_query function for all my queries:
function db_query($query) {
$qid = mysql_query($query);
return $qid;
}
It appears after some research that the best way around the problem is to
check whether magic_qoutes_gpc is off and if so use addslashes(). I have
altered the function to this:
function db_query($query) {
if(!magic_quotes_gpc()){
$qid = mysql_query(addslashes($query));
} else {
$qid = mysql_query($query);
}
return $qid;
}
But this adds too many slashes! Has anyone come to a better solution
regarding this?
Thanks
--- End Message ---
--- Begin Message ---
Try
$string = mysql_real_escape_string($string);
On 7 Dec 2004, at 14:12, Shaun wrote:
Hi,
I have been investigating the problem of apostrphes in a mysql insert /
update. I use a db_query function for all my queries:
function db_query($query) {
$qid = mysql_query($query);
return $qid;
}
It appears after some research that the best way around the problem is
to
check whether magic_qoutes_gpc is off and if so use addslashes(). I
have
altered the function to this:
function db_query($query) {
if(!magic_quotes_gpc()){
$qid = mysql_query(addslashes($query));
} else {
$qid = mysql_query($query);
}
return $qid;
}
But this adds too many slashes! Has anyone come to a better solution
regarding this?
Thanks
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---