php-general Digest 2 Mar 2008 02:30:58 -0000 Issue 5324
Topics (messages 270802 through 270819):
Re: Calculating dates
270802 by: Nathan Nobbe
Re: RewriteRule help
270803 by: Greg Donald
270804 by: Per Jessen
Re: PHP on Windows
270805 by: Andrés Robinet
270806 by: chetan rane
Re: Making sure an include file works
270807 by: Daniel Brown
270808 by: Al
Pear
270809 by: movies.biblescramble.com
270813 by: Nathan Nobbe
270815 by: movies.biblescramble.com
270816 by: Nathan Nobbe
270817 by: movies.biblescramble.com
270819 by: Rick Pasotto
reading incoming xml
270810 by: Larry Brown
270811 by: Nathan Nobbe
270812 by: Larry Brown
270814 by: Nathan Nobbe
Importing and exporting from MySQL, escape slash problem
270818 by: Dave M G
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 Sat, Mar 1, 2008 at 8:42 AM, Brice <[EMAIL PROTECTED]> wrote:
> I like this way too but it will not work with a date before the first
> January 1901.
>
> Do you have another method?
the DateTime class uses an unsigned 64 bit integer to represent the unix
timestamp internally. as a result it can handle such dates w/o a problem.
php > $dt1 = date_create('1856-02-27');
php > $dt2 = date_create('1855-12-03');
php > echo ($dt1->format('U') - $dt2->format('U')) / 86400;
86
-nathan
--- End Message ---
--- Begin Message ---
On 3/1/08, Shelley <[EMAIL PROTECTED]> wrote:
> Anybody knows what apache RewriteRule to use if I want url:
> http://www.aaa.comm/user/aaaa/
> be rewritten as:
> http://www.aaa.comm/user/index.php/aaaa/
RewriteRule ^user/([-a-zA-Z0-9]+)$ /index.php?user=$1 [NC,L]
--
Greg Donald
http://destiney.com/
--- End Message ---
--- Begin Message ---
Shelley wrote:
> Hi all,
>
> Anybody knows what apache RewriteRule to use if I want url:
> http://www.aaa.comm/user/aaaa/
> be rewritten as:
> http://www.aaa.comm/user/index.php/aaaa/
>
RewriteRule /user/([^/]+)/ /user/index.php/$1/
/Per Jessen, Zürich
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Erik SJMN [mailto:[EMAIL PROTECTED]
> Sent: Friday, February 29, 2008 9:41 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] PHP on Windows
>
> I'm completely new to php and I'm trying to setup an online trouble ticket
> system. After the user logs in and submits the ticket, they're supposed to
> receive an email confirmation with the ticket number. I have my Exchange
> server setup on another server in the same domain that I'm trying to use to
> send these emails - this server requires SMTP authentication. So I've
> installed the PEAR Mail package, as it was my understanding that this would
> allow me to do the authentication for the SMTP server - I installed it in
> the C:\PHP5\PEAR directory. Do I need this mail package for the
> authentication? In any case, where do I setup the authentication variables
> to send this email? I tried adding the authentication vars to the
> smtp.phpfile in the C:\PHP5\PEAR\Mail directory, but still not
> authenticating. I'm
> completely lost, any help is greatly appreciated.
>
> ; PHP 5.2.5 installed on Windows Server 2003 with IIS 6
> ; Mail-1.1.14 mail pkg with Net_SMTP-1.2.11 pkg
>
> --Erik
Did you try this http://email.about.com/od/emailprogrammingtips/qt/et073006.htm
?
Regards,
Rob
Andrés Robinet | Lead Developer | BESTPLACE CORPORATION
5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 |
TEL 954-607-4207 | FAX 954-337-2695 |
Email: [EMAIL PROTECTED] | MSN Chat: [EMAIL PROTECTED] | SKYPE: bestplace |
Web: bestplace.biz | Web: seo-diy.com
--- End Message ---
--- Begin Message ---
hi
try XAMMP from xampp.org it is packaged with apace PHp mysql and filezilla
On Sat, Mar 1, 2008 at 9:51 PM, Andrés Robinet <[EMAIL PROTECTED]>
wrote:
> > -----Original Message-----
> > From: Erik SJMN [mailto:[EMAIL PROTECTED]
> > Sent: Friday, February 29, 2008 9:41 PM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] PHP on Windows
> >
> > I'm completely new to php and I'm trying to setup an online trouble
> ticket
> > system. After the user logs in and submits the ticket, they're supposed
> to
> > receive an email confirmation with the ticket number. I have my
> Exchange
> > server setup on another server in the same domain that I'm trying to use
> to
> > send these emails - this server requires SMTP authentication. So I've
> > installed the PEAR Mail package, as it was my understanding that this
> would
> > allow me to do the authentication for the SMTP server - I installed it
> in
> > the C:\PHP5\PEAR directory. Do I need this mail package for the
> > authentication? In any case, where do I setup the authentication
> variables
> > to send this email? I tried adding the authentication vars to the
> > smtp.phpfile in the C:\PHP5\PEAR\Mail directory, but still not
> > authenticating. I'm
> > completely lost, any help is greatly appreciated.
> >
> > ; PHP 5.2.5 installed on Windows Server 2003 with IIS 6
> > ; Mail-1.1.14 mail pkg with Net_SMTP-1.2.11 pkg
> >
> > --Erik
>
> Did you try this
> http://email.about.com/od/emailprogrammingtips/qt/et073006.htm
> ?
>
> Regards,
>
> Rob
>
>
> Andrés Robinet | Lead Developer | BESTPLACE CORPORATION
> 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL
> 33308 |
> TEL 954-607-4207 | FAX 954-337-2695 |
> Email: [EMAIL PROTECTED] | MSN Chat: [EMAIL PROTECTED] | SKYPE:
> bestplace |
> Web: bestplace.biz | Web: seo-diy.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Have A pleasant Day
Chetan. D. Rane
Location: India
Contact: +91-9986057255
other ID: [EMAIL PROTECTED]
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
On Fri, Feb 29, 2008 at 10:02 PM, Richard S. Crawford
<[EMAIL PROTECTED]> wrote:
> On Friday 29 February 2008 11:58:16 Daniel Brown wrote:
> > Get a new host that knows how to administer a web server. PHP 4.3
> > was released 27 December, 2002, with the latest from the 4.3 branch
> > (4.3.11) being released 31 March, 2005. The CHANGELOG should give you
> > an idea of how *horrible* this is: http://www.php.net/ChangeLog-4.php
>
> Ah, if only I could. The choice of host was made by my boss, and he loves
> them.
And if they truly love him in return, they'll let him go....
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
--- End Message ---
--- Begin Message ---
Put this at the top of of your include files
// ******************* Debug Only ***************/
if(TRUE) // TRUE for debug only
{
ini_set("display_errors", "on"); //use off if users will see them
error_reporting(E_ALL);
echo '<span style="color:red">Error display and logging on</span> ';
//This reminds you to turn it off when done
}
Richard S. Crawford wrote:
I'm trying to figure out a way to make sure an included PHP file has no syntax
errors before actually including it as a part of project. Is this even
possible? I'm running into brick walls.
--- End Message ---
--- Begin Message ---
Dear PHP List Experts,
I'm trying to use Pear at my host, Leadhoster.
This line:
require_once('DB.php');
Gets this error:
Warning: main(DB.php): failed to open stream: No such file or directory in
/home/www/everoriginal.onlinewebshop.net/connect04.php on line 4
Fatal error: main(): Failed opening required 'DB.php'
(include_path='.:/usr/local/php4/share/pear') in
/home/www/everoriginal.onlinewebshop.net/connect04.php on line 4
I suspect I need to set up a path to Pear. If so, any help would be
appreciated.
This program:
<?php
phpinfo();
?>
seems to indicate that Pear is there.
This is my first post to this list, so please let me know if I'm not doing
it right. I couldn't find the archive, so I guess consider that my second
question.
Thanks in advance!
Jerry Kassebaum
--- End Message ---
--- Begin Message ---
On Sat, Mar 1, 2008 at 3:41 PM, <[EMAIL PROTECTED]> wrote:
> Dear PHP List Experts,
>
> I'm trying to use Pear at my host, Leadhoster.
>
> This line:
>
> require_once('DB.php');
>
> Gets this error:
>
> Warning: main(DB.php): failed to open stream: No such file or directory in
> /home/www/everoriginal.onlinewebshop.net/connect04.php on line 4
>
> Fatal error: main(): Failed opening required 'DB.php'
> (include_path='.:/usr/local/php4/share/pear') in
> /home/www/everoriginal.onlinewebshop.net/connect04.php on line 4
maybe try
find /usr/local/php4/share/pear -name 'DB.php'
to see if you have that component of pear installed. pear is a component
based system, which means even if you have pear installed, there are tons of
libraries you can use it to install. if you type
pear info DB
and nothing comes up, then likely you need to install it with
pear install DB
>
also, regarding the archives, i think there are several archives out there,
i always look at marc tho; http://marc.info/?l=php-general
-nathan
--- End Message ---
--- Begin Message ---
Thanks for your help, Nathan!
> maybe try
>
> find /usr/local/php4/share/pear -name 'DB.php'
I tried putting that in my script, and got:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in
/home/www/everoriginal.onlinewebshop.net/connect04.php on line 6
I'm thinking "find" is a Linux or Unix command to run on my host's
machine. I'm hoping that I can get this solved without getting Putty set
up, but am willing to make the effort if necessary.
Doesn't this error:
Fatal error: main(): Failed opening required 'DB.php'
(include_path='.:/usr/local/php4/share/pear') in
/home/www/everoriginal.onlinewebshop.net/connect04.php on line 4
show that Pear is there, and where to find it?
> if you type
>
> pear info DB
>
> and nothing comes up, then likely you need to install it with
>
> pear install DB
Likewise, that is from the Linux or Unix command line, right? If Pear is
not installed, wouldn't the host have to do that? Or is that something
customers can do when they have a host?
> also, regarding the archives, i think there are several archives out
> there,
> i always look at marc tho; http://marc.info/?l=php-general
Thanks!
Jerry Kassebaum
--- End Message ---
--- Begin Message ---
On Sat, Mar 1, 2008 at 6:24 PM, <[EMAIL PROTECTED]> wrote:
> Thanks for your help, Nathan!
>
> > maybe try
> >
> > find /usr/local/php4/share/pear -name 'DB.php'
>
> I tried putting that in my script, and got:
>
> Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in
> /home/www/everoriginal.onlinewebshop.net/connect04.php on line 6
>
> I'm thinking "find" is a Linux or Unix command to run on my host's
> machine. I'm hoping that I can get this solved without getting Putty set
> up, but am willing to make the effort if necessary.
yes, find is a *nix command. it will recursively search the filesystem from
the specified point for the pattern (in this case 'Db.php').
> Doesn't this error:
>
> Fatal error: main(): Failed opening required 'DB.php'
> (include_path='.:/usr/local/php4/share/pear') in
> /home/www/everoriginal.onlinewebshop.net/connect04.php on line 4
>
> show that Pear is there, and where to find it?
>
it does indicate that there is an include path w/ pear as one of the
directories, which strongly suggests that pear is installed, but it does not
absolutely garuntee it. when you run you phpinfo script that you mentioned
in your first post, do you see pear in one of the sections there (not just
in the include path)? also, as i said pear is a modular system, so even if
pear is installed, the DB package may not be installed.
> > if you type
> >
> > pear info DB
> >
> > and nothing comes up, then likely you need to install it with
> >
> > pear install DB
>
> Likewise, that is from the Linux or Unix command line, right? If Pear is
> not installed, wouldn't the host have to do that? Or is that something
> customers can do when they have a host?
yes, you will have to use putty to connect to the host and issue unix
commands if you want to get to the bottom of this w/o emails or a phone call
to your host. the find command is a crude way to determine if the pear DB
package is installed. you are likely better off to use the pear cli program
to determine if its installed as in above.
-nathan
--- End Message ---
--- Begin Message ---
> when you run you phpinfo script that you mentioned
> in your first post, do you see pear in one of the sections there (not just
> in the include path)?
A search on "pear" only yields this line:
include_path .:/usr/local/php4/share/pear .:/usr/local/php4/share/pear
Here is the page, so you can check it out if you want:
http://everoriginal.onlinewebshop.net/phpInfo.php
> also, as i said pear is a modular system, so even
> if
> pear is installed, the DB package may not be installed.
Is there something I could "include" from pear that would have an
extremely high possibility of being installed?
> yes, you will have to use putty to connect to the host and issue unix
> commands if you want to get to the bottom of this
Probably a good idea anyway, eh? I'll work on it...
..."SSH Manager section is not available for your hosting plan!"
I get free hosting at this place. I'd like to test it out before I buy,
but maybe I'll just have to bite the bullet.
--- End Message ---
--- Begin Message ---
It is quite possible (ie, I've done it) to install the PEAR modules you
need within your own web space. You just have to get the directory
structure and your include line right.
The PEAR system is just a bunch of php files so if you've got php you've
got all you really need.
--
"... most legislators ... as they rarely make any moral distinctions,
they are as likely to serve the devil, without intending it, as God."
-- Henry David Thoreau
Rick Pasotto [EMAIL PROTECTED] http://www.niof.net
--- End Message ---
--- Begin Message ---
I am running apache with php. I set up a curl script to send an xml
request to the php page I'm authoring and want to handle the xml on the
incoming message. My $_POST array is empty though. Is there some other
place I should be looking? $_SERVER shows the incoming message as a
post but again the data isn't there. Does apache/php place the xml in
some other location for me to access?
Larry
--- End Message ---
--- Begin Message ---
On Sat, Mar 1, 2008 at 4:12 PM, Larry Brown <
[EMAIL PROTECTED]> wrote:
> I am running apache with php. I set up a curl script to send an xml
> request to the php page
did you use a request header to somehow set a mime type to indicate youre
looking for xml? could you show us this request, im not sure how to request
for xml specifically..
> My $_POST array is empty though.
is this on the system where the xml will be sent from? you have to
populate the post fields in the request by using the curl option
CURLOPT_POST to indicate you are posting, and CURLOPT_POSTFIELDS, to pass an
array of parameters that will be used as post fields. then the $_POST array
will be populated on the provider system.
Is there some other
> place I should be looking? $_SERVER shows the incoming message as a
> post but again the data isn't there.
still curious if youre looking on the consumer (system sending curl request)
or the provider, (system providing the xml data via response).
> Does apache/php place the xml in
> some other location for me to access?
>
depending on how you configure curl, the data can be in different places.
the easiest way (i think) is to use the CURLOPT_RETURNTRANSFER option. then
the response will be returned from curl_exec() (rather than a boolean
success flag).
here is sample code from a consumer and a provider; theyre up on my server
so you can try using the consumer if you want.
CONSUMER
-------------------
<?php
$curlHandle = curl_init('http://nathan.moxune.com/postXml.php');
curl_setopt_array($curlHandle, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => array(
'token' => 1
)
));
$response = curl_exec($curlHandle);
if(!empty($response)) {
try {
$sxml = new SimpleXmlElement($response);
echo $sxml->asXML();
} catch(Exception $e) {
die($e->getMessage());
}
}
?>
PROVIDER
-----------------
<?php
if($_POST['token'] == 1) { ?>
<someString>
<moreHere>
<lessHere />
</moreHere>
</someString>
<?php } ?>
-nathan
--- End Message ---
--- Begin Message ---
I'm sending from a php cli with:
$post = '<?xml version="1.0"
encoding="UTF-8"?><Data>'.$vendorCompanyID.'</Data>';
$message = generatePage($page, $post);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://myserver/mytestpage.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $message);
$data=curl_exec($ch);
I've the server page (mytestpage.php) set up as:
echo "hello\n";
print_r($_SERVER);
where I replace SERVER with POST etc and I can't find the string '<?xml
version="1.0" encoding="UTF-8"?><Data>'.$vendorCompanyID.'</Data>' in
the $data output. I do get the hello so I know I am hitting the server
and when it is set to $_SERVER as listed above I get the expected array
but $_POST is empty.
Larry
On Sat, 2008-03-01 at 16:59 -0500, Nathan Nobbe wrote:
> On Sat, Mar 1, 2008 at 4:12 PM, Larry Brown <
> [EMAIL PROTECTED]> wrote:
>
> > I am running apache with php. I set up a curl script to send an xml
> > request to the php page
>
>
> did you use a request header to somehow set a mime type to indicate youre
> looking for xml? could you show us this request, im not sure how to request
> for xml specifically..
>
>
> > My $_POST array is empty though.
>
>
> is this on the system where the xml will be sent from? you have to
> populate the post fields in the request by using the curl option
> CURLOPT_POST to indicate you are posting, and CURLOPT_POSTFIELDS, to pass an
> array of parameters that will be used as post fields. then the $_POST array
> will be populated on the provider system.
>
> Is there some other
> > place I should be looking? $_SERVER shows the incoming message as a
> > post but again the data isn't there.
>
>
> still curious if youre looking on the consumer (system sending curl request)
> or the provider, (system providing the xml data via response).
>
>
> > Does apache/php place the xml in
> > some other location for me to access?
> >
>
> depending on how you configure curl, the data can be in different places.
> the easiest way (i think) is to use the CURLOPT_RETURNTRANSFER option. then
> the response will be returned from curl_exec() (rather than a boolean
> success flag).
>
> here is sample code from a consumer and a provider; theyre up on my server
> so you can try using the consumer if you want.
>
> CONSUMER
> -------------------
> <?php
> $curlHandle = curl_init('http://nathan.moxune.com/postXml.php');
> curl_setopt_array($curlHandle, array(
> CURLOPT_RETURNTRANSFER => true,
> CURLOPT_POST => true,
> CURLOPT_POSTFIELDS => array(
> 'token' => 1
> )
> ));
>
> $response = curl_exec($curlHandle);
> if(!empty($response)) {
> try {
> $sxml = new SimpleXmlElement($response);
> echo $sxml->asXML();
> } catch(Exception $e) {
> die($e->getMessage());
> }
> }
> ?>
>
> PROVIDER
> -----------------
> <?php
> if($_POST['token'] == 1) { ?>
> <someString>
> <moreHere>
> <lessHere />
> </moreHere>
> </someString>
> <?php } ?>
>
> -nathan
--
Larry Brown <[EMAIL PROTECTED]>
--- End Message ---
--- Begin Message ---
On Sat, Mar 1, 2008 at 5:17 PM, Larry Brown <
[EMAIL PROTECTED]> wrote:
> I'm sending from a php cli with:
>
> $post = '<?xml version="1.0"
> encoding="UTF-8"?><Data>'.$vendorCompanyID.'</Data>';
>
> $message = generatePage($page, $post);
>
> $ch = curl_init();
> curl_setopt($ch,
> CURLOPT_URL,'https://myserver/mytestpage.php'<https://myserver/mytestpage.php%27>
> );
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
> curl_setopt($ch, CURLOPT_TIMEOUT, 4);
> curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $message);
>
> $data=curl_exec($ch);
>
>
> I've the server page (mytestpage.php) set up as:
>
> echo "hello\n";
>
> print_r($_SERVER);
>
> where I replace SERVER with POST etc and I can't find the string '<?xml
> version="1.0" encoding="UTF-8"?><Data>'.$vendorCompanyID.'</Data>' in
> the $data output. I do get the hello so I know I am hitting the server
> and when it is set to $_SERVER as listed above I get the expected array
> but $_POST is empty.
hmm, it looks to me like you want to post a bunch of raw data to the
server. im not sure exactly how to do that w/ the php curl functions...
everything ive seen uses CURLOPT_POSTFIELDS to supply an associative array
of data to be posted. in this case you could easily send you data across by
choosing a name for the index, something like 'postdata', anything will do,
then it will be accessible on the system youre posting to via
$_POST['postdata'].
also, inlooking at your usage of CURLOPT_CUSTOMREQUEST, i dont believe youre
using it correctly, i think youre just supposed to put a string
representing the desired http method in there, so something like 'HEAD',
'PUT', or in this case 'POST'. then you would supply the data as i said
earlier, using CURLOPT_POSTFIELDS. so in all, i think something like this
would work for you,
$post = '<?xml version="1.0"
encoding="UTF-8"?><Data>'.
>
> $vendorCompanyID.'</Data>';
>
> $message = generatePage($page, $post);
>
> $ch = curl_init();
> curl_setopt($ch,
> CURLOPT_URL,'https://myserver/mytestpage.php'<https://myserver/mytestpage.php%27>
> );
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
> curl_setopt($ch, CURLOPT_TIMEOUT, 4);
> curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, array('postdata' => $message));
>
> $data=curl_exec($ch);
and also, in reading the warning about CURLOPT_CUSTOMREQUEST, you might just
go with CURLOPT_POST => true, since you arent using an obscure http method.
im not sure exactly how to determine if the server supports this method or
not. anyway, i found this in 'man curl_easy_setopt' (thats the manpage for
the c function php uses for the CURLOPT_CUSTOMREQUEST option).
Many people have wrongly used this option to replace the
entire request with their own, including multiple headers and POST contents.
While that might
work in many cases, it will cause libcurl to send invalid
requests and it could possibly confuse the remote server badly. Use
CURLOPT_POST and CUR-
LOPT_POSTFIELDS to set POST data. Use CURLOPT_HTTPHEADER to
replace or extend the set of headers sent by libcurl. Use
CURLOPT_HTTP_VERSION to change
HTTP version.
-nathan
--- End Message ---
--- Begin Message ---
PHP List, MySQL List
In my PHP environment, I have "Magic Quotes" turned off, and I use the
mysql_real_escape_string() function clean strings of SQL syntax before
inserting them into my database.
So the data stored in my database does not have escape characters in it.
Particularly, double and single quotes don't have slashes in front of them.
This seems to work fine so long as I'm reading data into and out of the
database from within my scripts.
However, when I backup and import databases - I use the phpMyAdmin
interface - they have escape slashes in front of every double and single
quote characters. I'm not sure if it's on the export or import where
they get added in.
I've looked through the phpMyAdmin online documentation, and I can't see
any option to control the presence of escape slashes. It seems to me
that if it adds them in when exporting, it should take them out when
importing. Or vice versa, but in either case be consistent.
I just want my database to be exactly as it is before any export or
import options.
I'm a little muddled as to where I'm making the mistake. Can anyone
advice on the best practice for preserving my database as is when
backing up and restoring?
Thanks for any advice.
--
Dave M G
--- End Message ---