[PHP] xslt_process() error
Hi Guys, I am trying to replicate a ColdFusion custom tag I wrote for transforming an XML doc with XSLT and having major problems. When I use xslt_process() I get the following error: Warning: Sablotron error on line 1: XML parser error 4: not well-formed (invalid token) in The XML XSL files all display correctly in browsers and it all works with CF, what can the problem be? I have read articles about a bug in the Sablotron libraries so the XSL file must not have any headers, this makes no difference. Can anyone help? Thanks in advance, --- Phil Ewington 43 Plc - Ashdale House 35 Broad Street, Wokingham Berkshire RG40 1AU T: +44 (0)1189 789 500 F: +44 (0)1189 784 994 E: mailto:[EMAIL PROTECTED] W: www.soyouthink.com -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.11.2 - Release Date: 02/05/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] FW: xslt_process() error
Hi All, I am trying to replicate a ColdFusion custom tag I wrote for transforming an XML doc with XSLT and having major problems. When I use xslt_process() I get the following error: Warning: Sablotron error on line 1: XML parser error 4: not well-formed (invalid token) in The XML XSL files all display correctly in browsers and it all works with CF, what can the problem be? I have read articles about a bug in the Sablotron libraries so the XSL file must not have any headers, this makes no difference. Can anyone help? Thanks in advance, --- Phil Ewington 43 Plc - Ashdale House 35 Broad Street, Wokingham Berkshire RG40 1AU T: +44 (0)1189 789 500 F: +44 (0)1189 784 994 E: mailto:[EMAIL PROTECTED] W: www.soyouthink.com -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.11.3 - Release Date: 03/05/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] reading/writing files outside of web root
Jason Wong wrote: On Wednesday 09 February 2005 02:31, Richard Lynch wrote: Phil Ewington - 43 Plc wrote: For some reason user_prefs will not open for read/write even when I tested it under apache.apache and chmod'd to 755, perhaps because /home is owned by root? Something went wrong with this test. You SHOULD have been able to read/write that file in PHP, assuming 'apache' is the user PHP runs as. Use http://php.net/phpinfo to confirm that it really *IS* 'apache' user that's running apache/php. It *will* fail if apache has no access to $HOME! I stand corrected. In addition to read/write access to the file itself, Apache must have at least eXecute (directory listing) permission to the directory containing that file. /home being owned by root is not the issue -- But if it's not something the apahce user can 'ls /home' and get the contents of, then you've got a problem. Thanks for all the input guys. The cron job suggestion is a great idea and I will go with this over using sudo. Thanks again. - Phil Ewington. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.8.8 - Release Date: 14/02/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] reading/writing files outside of web root
Hi All, I am revisiting a previous question posted here as after lots of investigation and code testing I cannot get what I want. I want to use PHP to read/write files that are outside of the web root and not owned by apache. To be specific... $HOME/.procmailrc $HOME/.spamassassin/user_prefs .procmailrc must be owned by root.root and chmod'd to 600 or is does not work, user_prefs can be owned by anyone, it does not seem to care who or what the permissions are. The first problem is .procmailrc, someone on this list suggested to use chown/chmod in PHP to change the file so it can be read/written to by PHP, this I soon realized was not an option as the file owned by root cannot be changed. For some reason user_prefs will not open for read/write even when I tested it under apache.apache and chmod'd to 755, perhaps because /home is owned by root? So my question is can I easily/safely edit files outside of the web root using PHP or is there a 3rd party command line tool to do this? TIA --- Phil Ewington 43 Plc - Ashdale House 35 Broad Street, Wokingham Berkshire RG40 1AU T: +44 (0)1189 789 500 F: +44 (0)1189 784 994 E: mailto:[EMAIL PROTECTED] W: www.soyouthink.com -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.8.6 - Release Date: 07/02/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Permissions
Hi All, I have a need for a PHP application to read/write Linux system files that have root.root ownership. At present reading not a problem but writing obviously is denied. I know there are probably some serious security issues here, but what should I be doing to allow this behaviour. I am running PHP 4.3.8 on Linux Redhat Fedora 1 installed as an Apache module. TIA --- Phil Ewington 43 Plc - Ashdale House 35 Broad Street, Wokingham Berkshire RG40 1AU T: +44 (0)1189 789 500 F: +44 (0)1189 784 994 E: mailto:[EMAIL PROTECTED] W: www.soyouthink.com --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.797 / Virus Database: 541 - Release Date: 15/11/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] WDDX functions not working!!
Hi All, I have been running 4.3.4 on a Cobalt RaQ 4 for some months and have been using the WDDX functions with great effect. I have recently moved all our sites to a new server (Linux RedHat ES 3 running PHP 4.3.6) and found that the WDDX functions do not work! No errors just nothing happens. I checked the phpinfo and it clearly shows that wddx is enabled (as I would expect with the --enable-wddx configure option). I have found this to be the case for 4.3.6, 4.3.8 4.3.9. What's going on?? $wddx_string = wddx_deserialize($wddx_packet); This should generate an array but does not! Has anyone else found this? What version does it work on? Installing PHP 5 is not an option at the moment as all our classes would need re-writing to conform to the new standards. TIA - Phil. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.769 / Virus Database: 516 - Release Date: 24/09/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Bespoke Email Solutions
Hi All, I have been using a Windows platform for generating and sending bespoke emails from .csv format lists but have had to swap to a Linux solution. We are using Postfix instead of Visnetic as our mail server but need a replacement for our email generation software (WorldMerge). Does anyone know of any PHP scripts that will generate emails from a database of email addresses and an HTML template with bespoke content I.E greetings, unsubscribe email address links, etc... and send to an SMTP server? TIA Phil Ewington. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.725 / Virus Database: 480 - Release Date: 19/07/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Scheduling a PHP script
Hi All, I have a PHP script that I need to call from both web browsers from a crontab but whichever route I choose I hit a problem. Here are the options I have tried along with problems encountered... PHP - /usr/bin/php /home/sites/home/web/schedules/index.php arg1 arg2 arg3 After resolving include path issues using ini_set() I get... Call to undefined function: mysql_connect(). I assume that all mysql functions are unavailable?? curl - /usr/bin/curl -u username:password http://www.domain.com/script.php?arg1=aarg2=barg3=c This gives me a PHP error... Undefined index: arg2 Only the first argument is available wget - /usr/bin/wget --http-user=username --http-passwd=password http://www.domain.com/script.php?arg1=aarg2=barg3=c This does not give an error but gives a message... `index.php?fuseaction=NewMembers.1' saved [557] Again it looks like query string is ignored. The database changes and email report that are supposed to occur on successful execution are unavailable! lynx - /usr/bin/lynx -dump -auth=username:password http://www.domain.com/script.php?arg1=aarg2=barg3=c This gives me a PHP error... Undefined index: arg2 Only the first argument is available again! Any ideas anyone? TIA - Phil. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.705 / Virus Database: 461 - Release Date: 12/06/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Scheduling a PHP script
On Mon, 14 Jun 2004 12:10:30 +0100 Phil Ewington - 43 Plc [EMAIL PROTECTED] wrote: PHP - /usr/bin/php /home/sites/home/web/schedules/index.php arg1 arg2 arg3 After resolving include path issues using ini_set() I get... Call to undefined function: mysql_connect(). I assume that all mysql functions are unavailable?? Is your commandline php executable compiled --with-mysql ? My PHP installation (4.3.6) was configured with: with-mysql=shared curl - /usr/bin/curl -u username:password http://www.domain.com/script.php?arg1=aarg2=barg3=c When issuing commands through bash (or alike) you need to surround the string with double-quotes (), because is a bash-operator, meaning put into background. With the command above you will execute /usr/bin/curl -u username:password http://www.domain.com/script.php?arg1=a; in the background, arg2=b in the background, and arg3=c in the foreground ;) That worked a treat! Thanks. The correct command is: /usr/bin/curl -u username:password http://www.domain.com/script.php?arg1=aarg2=barg3=c; This also applies to wget, lynx and all other commandline tools you can imagine ;-) -- Dennis Freise [EMAIL PROTECTED] GnuPG key: 2DE8 CCEF 6E20 11D4 3B27 21EC B0BA 1749 D2C8 38ED Available at: http://www.final-frontier.ath.cx/?key-plain --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.705 / Virus Database: 461 - Release Date: 12/06/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Changing the directory that PHP runs from (CLI)
Hi All, I have read the manual page for 'Using PHP from the command line' thoroughly and cannot find the answer to my problem. I have a script that needs to be accessed from both the command line and from web browsers. I tested the script from the command line and all worked well. As soon as I set the script to run from the crontab, all my includes fail because of paths. I believe the manual tries to cover forcing PHP to run from an alternative location but makes no sense to me. Can anyone tell me what changes I need to make to the following crontab entry... 0 23 * * * /usr/bin/php /path/to/my/script.php arg1 arg2 arg3 /dev/null TIA - Phil. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Changing the directory that PHP runs from (CLI)
Justin, I think I will go for the ini_set() option, seems to be the best bet to not affect anything else. Thanks. - Phil. -Original Message- From: Justin Patrin [mailto:[EMAIL PROTECTED] Sent: 11 June 2004 15:42 To: [EMAIL PROTECTED] Subject: [PHP] Re: Changing the directory that PHP runs from (CLI) Phil Ewington - 43 Plc wrote: Hi All, I have read the manual page for 'Using PHP from the command line' thoroughly and cannot find the answer to my problem. I have a script that needs to be accessed from both the command line and from web browsers. I tested the script from the command line and all worked well. As soon as I set the script to run from the crontab, all my includes fail because of paths. I believe the manual tries to cover forcing PHP to run from an alternative location but makes no sense to me. Can anyone tell me what changes I need to make to the following crontab entry... 0 23 * * * /usr/bin/php /path/to/my/script.php arg1 arg2 arg3 /dev/null TIA - Phil. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 Well, you could put your includes in a central location and set the include_path correctly in your php.ini. If that won't work for you, you can use chdir(dirname(realpath(__FILE))) to change to the script's directory. You could also use ini_set to add whatever directory you need ot the script's include_path. -- paperCrane Justin Patrin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Passing args to a PHP script from the command line
Hi All, Can anyone tell me how to pass arguments to a PHP script from the command line? I know I need to use the -args option but how exactly, I have tried the following... /usr/bin/php myscript.php -args key=value but this does not work, the script executes but key is not available as $_GET[key] in my script. Any pointers will be much appreciated. TIA Phil. --- Phil Ewington - Technical Director 43 Plc - Ashdale House 35 Broad Street, Wokingham Berkshire RG40 1AU T: +44 (0)1189 789 500 F: +44 (0)1189 784 994 E: mailto:[EMAIL PROTECTED] W: www.soyouthink.com --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Passing args to a PHP script from the command line
Phil Ewington - 43 Plc wrote on donderdag 10 juni 2004 12:58: Hi All, Can anyone tell me how to pass arguments to a PHP script from the command line? I know I need to use the -args option but how exactly, I have tried the following... /usr/bin/php myscript.php -args key=value You don't have to call the -args argument. just run the script from command line like this: php myscript.php value Where value is the argument you want to use in the script. These arguments are stored in an arrray ($argv). Do a print_r($argv) and you can see the content. OK, but if no param name is passed in, I assume that the order they are passed in as must be correct or the script will not know what values belong to which parameters? This seems a little odd, I assume that $argv only exists when accessed from the command line? My script needs to be excuted from both command line and from web browsers. but this does not work, the script executes but key is not available as $_GET[key] in my script. Any pointers will be much appreciated. TIA Phil. --- Phil Ewington - Technical Director 43 Plc - Ashdale House 35 Broad Street, Wokingham Berkshire RG40 1AU T: +44 (0)1189 789 500 F: +44 (0)1189 784 994 E: mailto:[EMAIL PROTECTED] W: www.soyouthink.com --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Passing args to a PHP script from the command line
Phil Ewington - 43 Plc wrote on donderdag 10 juni 2004 14:27: Phil Ewington - 43 Plc wrote on donderdag 10 juni 2004 12:58: Hi All, Can anyone tell me how to pass arguments to a PHP script from the command line? I know I need to use the -args option but how exactly, I have tried the following... /usr/bin/php myscript.php -args key=value You don't have to call the -args argument. just run the script from command line like this: php myscript.php value Where value is the argument you want to use in the script. These arguments are stored in an arrray ($argv). Do a print_r($argv) and you can see the content. OK, but if no param name is passed in, I assume that the order they are passed in as must be correct or the script will not know what values belong to which parameters? This seems a little odd, I assume that $argv only exists when accessed from the command line? My script needs to be excuted from both command line and from web browsers. How do you mean the order must be correct. Use some code like this to give it an index value. for ($counter=0; $counter $argc; $counter++) { list($key, $value) = each($argv); echo (key . $key . has value : . $value . \n); } Your example was... php myscript.php value That is just a value, no parameter name as with a query string, take this example... php myscript.php a b Let's say that this was requested from a browser like myscript.php?1=a2=b PHP uses 1 2 to refer to the values, but the values would get mixed up if I was to use... $argv[0] $argv[1] and the order of a and b were different when the script was called. Does that make sense? I find it odd that I need to write more code to 1) check $_GET and 2) check $argv, also simple error checking will fail for command line stuff when checking that all the required params are present. From what i understand the argv argc are only avaliable when the script is run from commandline. Just do a check on this and if not there get some $_POST or $_GET variables. but this does not work, the script executes but key is not available as $_GET[key] in my script. Any pointers will be much appreciated. TIA Phil. --- Phil Ewington - Technical Director 43 Plc - Ashdale House 35 Broad Street, Wokingham Berkshire RG40 1AU T: +44 (0)1189 789 500 F: +44 (0)1189 784 994 E: mailto:[EMAIL PROTECTED] W: www.soyouthink.com --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Passing args to a PHP script from the command line
Phil Ewington - 43 Plc wrote on donderdag 10 juni 2004 15:11: Phil Ewington - 43 Plc wrote on donderdag 10 juni 2004 14:27: Phil Ewington - 43 Plc wrote on donderdag 10 juni 2004 12:58: Hi All, Can anyone tell me how to pass arguments to a PHP script from the command line? I know I need to use the -args option but how exactly, I have tried the following... /usr/bin/php myscript.php -args key=value You don't have to call the -args argument. just run the script from command line like this: php myscript.php value Where value is the argument you want to use in the script. These arguments are stored in an arrray ($argv). Do a print_r($argv) and you can see the content. OK, but if no param name is passed in, I assume that the order they are passed in as must be correct or the script will not know what values belong to which parameters? This seems a little odd, I assume that $argv only exists when accessed from the command line? My script needs to be excuted from both command line and from web browsers. How do you mean the order must be correct. Use some code like this to give it an index value. for ($counter=0; $counter $argc; $counter++) { list($key, $value) = each($argv); echo (key . $key . has value : . $value . \n); } Your example was... php myscript.php value That is just a value, no parameter name as with a query string, take this example... php myscript.php a b Let's say that this was requested from a browser like myscript.php?1=a2=b PHP uses 1 2 to refer to the values, but the values would get mixed up if I was to use... $argv[0] $argv[1] and the order of a and b were different when the script was called. Does that make sense? I find it odd that I need to write more code to 1) check $_GET and 2) check $argv, also simple error checking will fail for command line stuff when checking that all the required params are present. ic now i understand what you mean :) Why not just pass the arguments on commandline like this: php myscript.php 1=a 2=b and then just split on '=' to get key value. That will do for me! Still more coding than I would like and not how I think it should be implemented, but hey we don't actually live in an ideal world do we ;o) Thanks for your help, it is much appreciated. - Phil. From what i understand the argv argc are only avaliable when the script is run from commandline. Just do a check on this and if not there get some $_POST or $_GET variables. but this does not work, the script executes but key is not available as $_GET[key] in my script. Any pointers will be much appreciated. TIA Phil. --- Phil Ewington - Technical Director 43 Plc - Ashdale House 35 Broad Street, Wokingham Berkshire RG40 1AU T: +44 (0)1189 789 500 F: +44 (0)1189 784 994 E: mailto:[EMAIL PROTECTED] W: www.soyouthink.com --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fsockopen() throwing errors
Hi All, How can I stop fsockopen() throwing an error and killing my script when it cannot connect? I have tried the following: $this-_Socket = fsockopen($s_server, $this-_Port, $i_errno, $s_errstr, $this-_Timeout); if (!$this-_Socket) { ... code to handle connection failure } and ... if (!$this-_Socket = fsockopen($s_server, $this-_Port, $i_errno, $s_errstr, $this-_Timeout)) { ... code to handle connection failure } I have also tried prefixing fsockopen() with @ but when it fails to connect it kills my script by throwing an error. Any advise here will be much appreciated as this code is mission critical. TIA - Phil. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.690 / Virus Database: 451 - Release Date: 22/05/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: fsockopen() errors.
Tom, Thought about that one or simply trying to catch the error in my site wide error handler, will give it a try, thanks. -- Phil. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 08 March 2004 15:53 To: PHP Subject: [PHP] Re: fsockopen() errors. On 8 Mar 2004 Phil Ewington - 43 Plc wrote: Can anyone tell me the best way to avoid errors using fsockopen(). I have tried wrapping the function call in a conditional statement, and have also tried calling the function and then testing the return. Here's an approach I have used to avoid any error messages at all -- presumably you could also set a flag in the error handler to indicate what happened, if you need that. . $olderr = error_reporting(0); set_error_handler(ignoreerrhandler); $fp = fsockopen(.) restore_error_handler(); error_reporting($olderr); if ($fp) { [worked] } else { [failed] } . function ignoreerrhandler($errno, $errstr, $errfile, $errline) { return; } -- Tom -- 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] fsockopen() errors.
Hi All, Can anyone tell me the best way to avoid errors using fsockopen(). I have tried wrapping the function call in a conditional statement, and have also tried calling the function and then testing the return. Example 1: $sckHandle = fsockopen($server, 25, $errNo, $errString); if ($sckHandle) { code here... } Example 2: if ($sckHandle = fsockopen($server, 25, $errNo, $errString)) { code here... } both give this error on failing to connect to a given server: fsockopen(): unable to connect to mx3.hotmail.com:25 I was under the impression that example 2 would not trigger an error if fsockopen() failed. Any help will be greatly appreciated. Phil. --- Phil Ewington - Technical Director 43 Plc - Ashdale House 35 Broad Street, Wokingham Berkshire RG40 1AU T: +44 (0)1189 789 500 F: +44 (0)1189 784 994 E: mailto:[EMAIL PROTECTED] W: www.soyouthink.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fsockopen() errors.
Hi Miguel, I am giving it a test at the moment, thanks. -- Phil. -Original Message- From: Miguel J. Jiménez [mailto:[EMAIL PROTECTED] Sent: 08 March 2004 12:29 To: Phil Ewington - 43 Plc Cc: PHP Subject: Re: [PHP] fsockopen() errors. Is it an error or a warning? If it is a warning you can try use @ before fsockopen() to avoid echoing warning messages [EMAIL PROTECTED](...)]. -- Miguel J. Jiménez ISOTROL, S.A. (Área de Internet) Avda. Innovación nº1, 3ª - 41020 Sevilla (ESPAÑA) [EMAIL PROTECTED] TLFNO. 955036800 ext. 111 -- 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] fsockopen() errors.
Hmm, added @ to fsockopen() function, still happens, can anyone shed any light on this? TIA Phil. -Original Message- From: Phil Ewington - 43 Plc [mailto:[EMAIL PROTECTED] Sent: 08 March 2004 12:57 To: Miguel J. Jiménez Cc: PHP Subject: RE: [PHP] fsockopen() errors. Hi Miguel, I am giving it a test at the moment, thanks. -- Phil. -Original Message- From: Miguel J. Jiménez [mailto:[EMAIL PROTECTED] Sent: 08 March 2004 12:29 To: Phil Ewington - 43 Plc Cc: PHP Subject: Re: [PHP] fsockopen() errors. Is it an error or a warning? If it is a warning you can try use @ before fsockopen() to avoid echoing warning messages [EMAIL PROTECTED](...)]. -- Miguel J. Jiménez ISOTROL, S.A. (Área de Internet) Avda. Innovación nº1, 3ª - 41020 Sevilla (ESPAÑA) [EMAIL PROTECTED] TLFNO. 955036800 ext. 111 -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] sorting multi-dimensional arrays
Hi All, I am trying to sort a multi-dimensional array using a value in the second dimension. I have looked at the usort examples but don't fully understand what usort is actually doing so am struggling. I have tried the following: if (! getmxrr($this-_Domain, $as_hosts, $ai_weights)) { return false; } for ($i = 0; $i count($as_hosts); $i++) { $this-MXRecs[] = array($as_hosts[$i], $ai_weights[$i]); } function IsBestMX($a, $b) { if ($a[1] == $b[1]) { return 0; } return ($a[1] $b[1]) ? -1 : 1; } usort($this-MXRecs); Can anyone point me in the right direction? TIA Phil. --- Phil Ewington - Technical Director 43 Plc - Ashdale House 35 Broad Street, Wokingham Berkshire RG40 1AU T: +44 (0)1189 789 500 F: +44 (0)1189 784 994 E: mailto:[EMAIL PROTECTED] W: www.soyouthink.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] sorting multi-dimensional arrays
Ooops, forgot to specify the compare function with usort(); all working now. Phil. -Original Message- From: Phil Ewington - 43 Plc [mailto:[EMAIL PROTECTED] Sent: 22 December 2003 14:08 To: [EMAIL PROTECTED] Subject: [PHP] sorting multi-dimensional arrays Hi All, I am trying to sort a multi-dimensional array using a value in the second dimension. I have looked at the usort examples but don't fully understand what usort is actually doing so am struggling. I have tried the following: if (! getmxrr($this-_Domain, $as_hosts, $ai_weights)) { return false; } for ($i = 0; $i count($as_hosts); $i++) { $this-MXRecs[] = array($as_hosts[$i], $ai_weights[$i]); } function IsBestMX($a, $b) { if ($a[1] == $b[1]) { return 0; } return ($a[1] $b[1]) ? -1 : 1; } usort($this-MXRecs); Can anyone point me in the right direction? TIA Phil. --- Phil Ewington - Technical Director 43 Plc - Ashdale House 35 Broad Street, Wokingham Berkshire RG40 1AU T: +44 (0)1189 789 500 F: +44 (0)1189 784 994 E: mailto:[EMAIL PROTECTED] W: www.soyouthink.com -- 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] ftp_connect() issues
I can still connect to the ftp server from my client machine using any number of FTP apps, I also created an ftp test tool, on the same server as I am currently having problems, that lets you enter an ftp host, username password to see if it can connect and login. I can login to other ftp servers just not the one I want to. Strangely I managed to get a connection to the suspect ftp server a couple of times then nothing again. Seems to be an intermittent problem, but it would be nice to know whether it was a connection that was being dropped by the remote server or whether there were network issues that stopped the request reaching the target server. Phil. -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED] Sent: 10 October 2003 17:51 To: [EMAIL PROTECTED] Subject: Re: [PHP] ftp_connect() issues On Saturday 11 October 2003 00:01, Phil Ewington - 43 Plc wrote: A script that has been running successfully for over 18 months has suddenly stopped working due to ftp_connect() failing. I have been assured that nothing has changed on the ftp server so now need to try and find out why this is happening. And have you verified that you can still connect to the ftp server via other means? And have you verified that the script can connect to other ftp servers? -- 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 -- /* It is more rational to sacrifice one life than six. -- Spock, The Galileo Seven, stardate 2822.3 */ -- 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] ftp_connect() issues
Hi All, A script that has been running successfully for over 18 months has suddenly stopped working due to ftp_connect() failing. I have been assured that nothing has changed on the ftp server so now need to try and find out why this is happening. ftp_connect seems to only return true or false, no specific RFC error codes :o( Can anyone suggest where I can start looking for a resolution to this matter? Running PHP 4.2.3 on a Cobalt RAQ4. TIA Phil. Phil Ewington - Technical Director -- 43 Plc 35 Broad Street, Wokingham Berkshire RG40 1AU T: +44 (0)118 978 9500 F: +44 (0)118 978 4994 E: mailto:[EMAIL PROTECTED] W: http://www.43plc.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fsockopen()
Hi All, I am having problems with fsockopen() and wondered if anyone else has encountered this behaviour. My problem is that when connecting to an invalid domain I cannot trap the errors. I have tried setting a variable then testing the value, which prints a warning to the screen... $sck_handle = fsockopen($hostname, $port, $errno, $errstr, $timeout); if (!$sck_handle) { // socket could not be opened. $http_statuscode = Error: . $errno . - . $errstr; } else { ... } How can I get $errno $errstr, are these for read/write errors rather than socket initialisation? I need to know why the socket could not be opened so I can give an appropriate error message. TIA Phil Ewington - Technical Director -- 43 Plc 35 Broad Street, Wokingham Berkshire RG40 1AU T: +44 (0)118 978 9500 F: +44 (0)118 978 4994 E: mailto:[EMAIL PROTECTED] W: http://www.43plc.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fsockopen()
Positive, I am deliberately using invalid domains to test how to catch errors when users misspell their domain. -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED] Sent: 30 September 2003 12:01 To: [EMAIL PROTECTED] Subject: Re: [PHP] fsockopen() On Tuesday 30 September 2003 18:46, Phil Ewington - 43 Plc wrote: I am having problems with fsockopen() and wondered if anyone else has encountered this behaviour. My problem is that when connecting to an invalid domain I cannot trap the errors. Have you checked that it is really an invalid domain and not simply been hijacked by Versign: http://www.techweb.com/tech/network/20030926_network -- 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 -- /* H. L. Mencken's Law: Those who can -- do. Those who can't -- teach. Martin's Extension: Those who cannot teach -- administrate. */ -- 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] fsockopen()
Sorry Jason, I did read the article but must have been away with the fairies for a moment. I was testing domains that are complete rubbish but they were all .com and .net so yes you were right and I am a complete fool ;o). Now getting an error message 'No such file or directory' when testing on another TLD, strange message for 'domain cannot be found', but hey life would be boring if everyone thought along the same lines :o) -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED] Sent: 30 September 2003 15:51 To: [EMAIL PROTECTED] Subject: Re: [PHP] fsockopen() On Tuesday 30 September 2003 20:39, Phil Ewington - 43 Plc wrote: Positive, I am deliberately using invalid domains to test how to catch errors when users misspell their domain. Did you read that article (or are you aware of what it is about)? And what invalid domains have you tried? -- 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 -- /* Life is the childhood of our immortality. -- Goethe */ -- 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