RES: [PHP] From 24/7/2013 to 2013-07-24
Use this: echo preg_replace('#(\d{2})/(\d{2})/(\d{4})#' , \\3-\\2-\\1, '24/07/2013' ); RESULT = 2013-07-24 Alejandro M.S -Mensagem original- De: Jim Giner [mailto:jim.gi...@albanyhandball.com] Enviada em: sexta-feira, 26 de julho de 2013 11:12 Para: php-general@lists.php.net Assunto: Re: [PHP] From 24/7/2013 to 2013-07-24 On 7/26/2013 10:10 AM, Jim Giner wrote: I think you should change from using 'rsort' ( a SORT function) to 'array_reverse', a simple reverse function. Your example of what you desire is wrong. 24-7-2013 will give you the 2013-24-7 that you want. oops. I meant to say will NOT give you the 2013-2407 that you want. -- 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
RES: [PHP] From 24/7/2013 to 2013-07-24
jomali: Use this: echo preg_replace('#(\d{2})/(\d{2})/(\d{4})#' , \\3-\\2-\\1, '24/07/2013' ); RESULT = 2013-07-24 Alejandro M.S -Mensagem original- De: jomali [mailto:jomali3...@gmail.com] Enviada em: sexta-feira, 26 de julho de 2013 17:38 Para: Robert Cummings Cc: Karl-Arne Gjersøyen; PHP Mailinglist Assunto: Re: [PHP] From 24/7/2013 to 2013-07-24 On Fri, Jul 26, 2013 at 1:08 PM, Robert Cummings rob...@interjinn.comwrote: On 13-07-26 11:42 AM, jomali wrote: On Fri, Jul 26, 2013 at 5:18 AM, Karl-Arne Gjersøyen karlar...@gmail.com wrote: Below is something I try that ofcourse not work because of rsosort. Here is my code: --- $lagret_dato = $_POST['lagret_dato']; foreach($lagret_dato as $dag){ $dag = explode(/, $dag); rsort($dag); $dag = implode(-, $dag); var_dump($dag); What I want is a way to rewrite contents of a variable like this: From 24/7/2013 to 2013-07-24 Is there a way in PHP to do this? Thank you very much. Karl $conv_date = str_replace('/', '-','24/7/2013'); echo date('Y-m-d', strtotime($conv_date)); Result: 2013-07-24 It would be better if you reformatted first since this is ambiguous when you have the following date: 6/7/2013 Here's a completely unambiguous solution: ?php $old = '24/7/2013'; $paddy = function( $bit ){ return str_pad( $bit, 2, '0', STR_PAD_LEFT ); }; $new = implode( '-', array_map( $paddy, array_reverse( explode( '/', $old ) ) ) ); echo $new.\n; ? Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. The original question was about reformatting a European (Day/Month/Year) date. Your solution does not address this problem. Mine assumes the European date format explicitly. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RES: [PHP] cURL issues posting to an end point
Bastien: -Mensagem original- De: Bastien Koert [mailto:phps...@gmail.com] Enviada em: quinta-feira, 4 de outubro de 2012 11:54 Para: PHP-General Assunto: [PHP] cURL issues posting to an end point Hi All, I have a page that receives third party data into my app, xml data via https post. This works fine and I receive the data as expected. The issue I am facing is around posting XML data back as a synchronous response to the post I receive. I am using the following code: function sendXMLConfirmation($data) { /* * XML Sender/Client. */ // Get our XML. You can declare it here or even load a file. $xml_builder = '?xml version=1.0 encoding=utf-8? Envelope version=01.00 Sender Id/ Credential25412/Credential /Sender Recipient Id/ /Recipient TransactInfo transactType=response TransactId'.$hash.'/TransactId TimeStamp'.date(Y-m-d H:m ).'/TimeStamp Status Code200/Code ShortDescriptionSuccess/ShortDescription LongDescriptionCANDIDATE Data transfer was a success/LongDescription /Status /TransactInfo Packet PacketInfo packetType=response PacketId1/PacketId ActionSET/Action ManifestManifest Data/Manifest Status Code/ ShortDescription/ LongDescription/ /Status /PacketInfo Payload![CDATA[]]/Payload /Packet /Envelope '; // We send XML via CURL using POST with a http header of text/xml. $ch = curl_init(); $url = 'https://staging.somesite.com/Sprocessor/DispatchMessage.asmx'; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // for https curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 4); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_builder); - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml')); - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close')); --- NEW $sPost = '/Sprocessor/DispatchMessage.asmx'; $sHost = ' https://staging.somesite.com'; curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'User-Agent: My Program', 'Accept-Encoding: gzip, deflate', 'POST ' . $sPost . ' HTTP/1.1', 'Host: ' . $sHost, 'Content-type: application/soap+xml; charset=utf-8', 'Content-Length: ' . strlen($xml_builder) ); END NEW - //Execute the request and also time the transaction ( optional ) $start = array_sum(explode(' ', microtime())); $result = curl_exec($ch); curl_close($ch); // Print CURL result. echo $ch_result; } The endpoint recipient says they are not receiving the data and I am at a loss to figure out why. Any insight would be appreciated. Thanks, -- 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
RES: [PHP] cURL issues posting to an end point
Bastien: curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'User-Agent: My Program', 'Accept-Encoding: gzip, deflate', 'POST ' . $sPost . ' HTTP/1.1', 'Host: ' . $sHost, 'Content-type: application/soap+xml; charset=utf-8', 'Content-Length: ' . strlen($xml_builder) ) --- This is missing ); Alejandro M.S -Mensagem original- De: Bastien Koert [mailto:phps...@gmail.com] Enviada em: quinta-feira, 4 de outubro de 2012 15:49 Para: Alejandro Michelin Salomon Cc: PHP-General Assunto: Re: [PHP] cURL issues posting to an end point On Thu, Oct 4, 2012 at 1:35 PM, Alejandro Michelin Salomon amichel...@hotmail.com wrote: Bastien: -Mensagem original- De: Bastien Koert [mailto:phps...@gmail.com] Enviada em: quinta-feira, 4 de outubro de 2012 11:54 Para: PHP-General Assunto: [PHP] cURL issues posting to an end point Hi All, I have a page that receives third party data into my app, xml data via https post. This works fine and I receive the data as expected. The issue I am facing is around posting XML data back as a synchronous response to the post I receive. I am using the following code: function sendXMLConfirmation($data) { /* * XML Sender/Client. */ // Get our XML. You can declare it here or even load a file. $xml_builder = '?xml version=1.0 encoding=utf-8? Envelope version=01.00 Sender Id/ Credential25412/Credential /Sender Recipient Id/ /Recipient TransactInfo transactType=response TransactId'.$hash.'/TransactId TimeStamp'.date(Y-m-d H:m ).'/TimeStamp Status Code200/Code ShortDescriptionSuccess/ShortDescription LongDescriptionCANDIDATE Data transfer was a success/LongDescription /Status /TransactInfo Packet PacketInfo packetType=response PacketId1/PacketId ActionSET/Action ManifestManifest Data/Manifest Status Code/ ShortDescription/ LongDescription/ /Status /PacketInfo Payload![CDATA[]]/Payload /Packet /Envelope '; // We send XML via CURL using POST with a http header of text/xml. $ch = curl_init(); $url = 'https://staging.somesite.com/Sprocessor/DispatchMessage.asmx'; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // for https curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 4); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_builder); - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml')); - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close')); --- NEW $sPost = '/Sprocessor/DispatchMessage.asmx'; $sHost = ' https://staging.somesite.com'; curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'User-Agent: My Program', 'Accept-Encoding: gzip, deflate', 'POST ' . $sPost . ' HTTP/1.1', 'Host: ' . $sHost, 'Content-type: application/soap+xml; charset=utf-8', 'Content-Length: ' . strlen($xml_builder) ); END NEW - //Execute the request and also time the transaction ( optional ) $start = array_sum(explode(' ', microtime())); $result = curl_exec($ch); curl_close($ch); // Print CURL result. echo $ch_result; } The endpoint recipient says they are not receiving the data and I am at a loss to figure out why. Any insight would be appreciated. Thanks, -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks, Alejandro, So much closer that before, however I am getting an error on this. Unexpected ';' on line 151 which is the closing array ); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'User-Agent: My Program', 'Accept-Encoding: gzip, deflate
RES: [PHP] XML/PHP web service
Philip : Try this: Client: $client = new SoapClient( null, array( 'encoding' = 'utf-8', 'soap_version' = SOAP_1_2, 'trace' = 1, 'uri' = 'tns: Server', 'location' = 'php server URL here')); // Cut off ?xml version=1.0 encoding=utf-8?, to not have two xml start tag in the soap message. $xmlres = $client-__soapCall( 'ProXML', array( str_replace( '?xml version=1.0 encoding=utf-8?'.\n, '', $sXml ))); echo 'pre', $xmlres, '/pre'; // print the xml output or var_export($xmlres, true) if $xmlres is an array. SERVER: class Receiver { public function ProXML ( $sXML ) { libxml_use_internal_errors(true); // enabled use libxml errors // try..catch to cacth simplexmlelement errors try { $xml = new SimpleXMLElement( '?xml version=1.0 encoding=utf-8?' . $sXML ); // Try to create a xml object with the string passed } catch (Exception $e) { $aErrors = libxml_get_errors(); // get errors foreach ( $aErros as $oErro ) { switch ( $oErro-level ) { case LIBXML_ERR_WARNING: $sCod .= 'returncode' . $oErro-code . '/codemenssage' . utf8_encode( 'warning: ' . $oErro-message ) . '/menssage/return'; break; case LIBXML_ERR_ERROR: $sCod .= 'respostacodigo' . $oErro-code . '/codemenssage' . utf8_encode( 'Error: ' . $oErro-message ) . '/menssage/return'; break; case LIBXML_ERR_FATAL: $sCod .= 'respostacodigo' . $oErro-code . '/codemenssage' . utf8_encode( ' Fatal Error: ' . $oErro-message ) . '/menssage/return'; break; } } } work here ... } } $server = new SoapServer(null, array( 'uri' = 'tns: Server' )); $server-setClass('Receiver'); $server-handle(); Alejandro M.S -Mensagem original- De: Phillip Baker [mailto:phil...@freewolf.net] Enviada em: quarta-feira, 8 de agosto de 2012 19:12 Para: php-general@lists.php.net Assunto: [PHP] XML/PHP web service Greetings all, I am looking for some options here. I am in need of creating a service on our web server that will always be available and automated. It will accept an XML file. I will be checking to see if the XML file is valid and then passing it on to another server. But I need to accept this file without using a submit form. I have never done anything like this and looking for ideas. I am using a lamp environment and looking for suggestions. I am looking to set this up so that our vendors can set up scripts to automatically post XML files to our servers. Blessed Be Phillip In the Jim Crow South, for example, government failed and indeed refused to protect blacks from extra-legal violence. Given our history, it's stunning we fail to question those who would force upon us a total reliance on the state for defense. -- Robert J. Cottrol -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RES: [PHP] CURL -d
Hi try this : $ch = curl_init(); curl_setopt ( $ch, CURLOPT_URL, URL HERE ); curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 ); curl_setopt ( $ch, CURLOPT_HEADER, 1 ); curl_setopt ( $ch, CURLOPT_TIMEOUT, 10); curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false ); curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, false ); This to use SSL Certicade curl_setopt ( $ch, CURLOPT_SSLCERT, Public Key ); curl_setopt ( $ch, CURLOPT_SSLCERTPASSWD, ''); curl_setopt ( $ch, CURLOPT_SSLCERTTYPE, 'PEM' ); -- Type o certificade curl_setopt ( $ch, CURLOPT_SSLKEY, Private Key ); curl_setopt ( $ch, CURLOPT_SSLKEYPASSWD, Password of private key); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $ch, CURLOPT_POST, true ); curl_setopt ( $ch, CURLOPT_PORT , 443 ); -- port curl_setopt($ch, CURLOPT_POSTFIELDS, DATA HERE ); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'User-Agent: Some name', 'Accept-Encoding: gzip, deflate', 'POST some post data HTTP/1.1', 'Host: some host', 'Content-type: application/soap+xml; charset=utf-8', The content type 'Content-Length: ', length of data // This for soap action 'SOAPAction: action here ') ); $xResult = curl_exec($ch); Alejandro M.S. -Mensagem original- De: QI.VOLMAR QI [mailto:qi.vol...@gmail.com] Enviada em: segunda-feira, 26 de março de 2012 12:46 Para: PHP General Assunto: [PHP] CURL -d I have this lines: curl -H Content-Type: application/json -d hello world \ http://api.pusherapp.com/apps/17331/channels/test_channel/events?\ The option -d is for data. But How I can set it on the PHP CURL extension? I have found that if I set something like array('Hello Word', 'name' = 'my_name'), for the POST data may occurs. Can you give me a little help? -- 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
RES: [PHP] '?=' with PHP5.3.10
Leste Wrote: -Mensagem original- De: Lester Caine [mailto:les...@lsces.co.uk] Enviada em: segunda-feira, 5 de março de 2012 08:18 Para: php-general@lists.php.net Assunto: Re: [PHP] '?=' with PHP5.3.10 Ashley Sheridan wrote: You can set it in php.ini itself, or possibly from .htaccess. failing that, find/replace on the old short echo tags would do it. But I thought that '?=' was SUPPOSED to have been protected? When did that change ... Protected only in php 5.4.x, not in 5.3.x Php 5.3 a prior, the only safe tag is ?php, in 5.4.x safes tags are ?php and ?=. In my codes, i only use this ?php, 100% safe. Alejandro M.S. -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.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
RES: [PHP] What's Your Favorite Design Pattern?
Mike: My favorite are singleton ( database connection configuration ), and factory. Factory i use when need one code exporting or doing different process. Basically y have a base class with general code and a specific class that extend the base class with code specific to the process to be made. The main code only pass the type of format ant factory returns de right code for the operation. The main code remains untouched, when the factory chance each time a i need other type of process or exportation results. Alejandro M.S. -Mensagem original- De: Mike Mackintosh [mailto:mike.mackint...@angrystatic.com] Enviada em: terça-feira, 7 de fevereiro de 2012 16:57 Para: PHP General List Assunto: [PHP] What's Your Favorite Design Pattern? I was curious to see what everyones favorite design patterns were, if you use any, and why/when have you used it? Choices include slots and signals (observer), singleton, mvc, hmvc, factory, commander etc.. Thanks, -- Mike Mackintosh PHP, the drug of choice - www.highonphp.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RES: [PHP] Re: Getting Column Names from an AS400 Database
Cheryl: In the PHP Manual ; resource odbc_columns ( resource $connection_id [, string $qualifier [, string $schema [, string $table_name [, string $column_name ) Lists all columns in the requested range. Parameters connection_id The ODBC connection identifier, see odbc_connect() for details. qualifier The qualifier. schema The owner. table_name The table name. column_nameThe column name. I the first email you send: $outval = odbc_columns($conn, DB#LIBNAME, %, TABLENAME, %); $conn is truly a connection object ? You check if has no errors in the connection processes? Alejandro M.S. -Mensagem original- De: Cheryl Sullivan [mailto:csull...@shh.org] Enviada em: quinta-feira, 26 de janeiro de 2012 13:41 Para: Jim Giner; php-general@lists.php.net Assunto: RE: [PHP] Re: Getting Column Names from an AS400 Database Thanks for your response... I changed the $outval line to $outval = odbc_columns($rs, DB#LIBNAME, %, TABLENAME, %); ...but still got the same error - Warning: odbc_columns() expects parameter 1 to be resource, object given in D:\WAMP\www\directory\filename.php on line 13 -Original Message- From: Jim Giner [mailto:jim.gi...@albanyhandball.com] Sent: Thursday, January 26, 2012 10:31 AM To: php-general@lists.php.net Subject: [PHP] Re: Getting Column Names from an AS400 Database I'm thinking that it should read $rs = $conn-execute($q); $outval = odbc_columns($rs, DB#LIBNAME, %, TABLENAME, %); You need to provide the results of the query to the odbc_columns, not the connection object. Just my guess since I've never used this. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Notice: This communication, including attachments, may contain information that is confidential and protected. It constitutes non-public information intended to be conveyed only to the designated recipient(s). If you believe that you have received this communication in error, please notify the sender immediately by return e-mail and promptly delete this e-mail, including attachments without reading or saving them in any manner. The unauthorized use, dissemination, distribution, or reproduction of this e-mail, including attachments, is prohibited and may be unlawful. Thank you. -- 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
RES: [PHP] Printing
Jim: The TCPDF software library does not need php pdf functions. Is 100% php code. To use only put a require_once '/tcpdf/tcpdf.php'; lik this. Create a new instance: $pdf = new TCPDF( 'P', 'mm', 'A4', true, 'UTF-8', false); And call the methods. The library has a folder with a lot of examples. Alejandro MS -Mensagem original- De: Jim Giner [mailto:jim.gi...@albanyhandball.com] Enviada em: quinta-feira, 5 de janeiro de 2012 17:13 Para: Alejandro Michelin Salomon Assunto: Re: [PHP] Printing I don't know what you mean. How do I create a pdf with php? Do I have to have my host install a package or something? - Original Message - From: Alejandro Michelin Salomon amichel...@hotmail.com To: 'Jim Giner' jim.gi...@albanyhandball.com Sent: Thursday, January 05, 2012 2:01 PM Subject: RES: [PHP] Printing Jim: You do not need PDF printer drivers. This lib create a PDF file with 100% PHP code. When the creation is done, you chose what to do: Save a file to download or send directly to the browser. Example; // reset pointer to the last page $pdf-lastPage(); //Close and output PDF document if ( trim( $sFile ) != '' ) $pdf-Output( $sFile, 'F' ); // Save to file else $pdf-Output(); // Send to browser directly Alejandro MS -Mensagem original- De: Jim Giner [mailto:jim.gi...@albanyhandball.com] Enviada em: quinta-feira, 5 de janeiro de 2012 16:55 Para: Alejandro Michelin Salomon Assunto: Re: [PHP] Printing I have several pdf printer drivers. HOw do I use them in a hosted php script? - Original Message - From: Alejandro Michelin Salomon amichel...@hotmail.com To: 'Jim Giner' jim.gi...@albanyhandball.com Cc: Pgsql-General pgsql-gene...@postgresql.org Sent: Thursday, January 05, 2012 1:50 PM Subject: RES: [PHP] Printing Jim : TCPDF software library has excellent examples to teach you how to do the work http://www.tcpdf.org/ My legal documents mix images, barcode, etc. All the problems printing go to space Alejandro MS -Mensagem original- De: Jim Giner [mailto:jim.gi...@albanyhandball.com] Enviada em: quinta-feira, 5 de janeiro de 2012 16:46 Para: Alejandro Michelin Salomon Assunto: Re: [PHP] Printing a pdf would solve the problem. - Original Message - From: Alejandro Michelin Salomon amichel...@hotmail.com To: 'Jim Giner' jim.gi...@albanyhandball.com Cc: Pgsql-General pgsql-gene...@postgresql.org Sent: Thursday, January 05, 2012 1:43 PM Subject: RES: [PHP] Printing Jim: I think the problems is that trying to print directly from PHP is not a good idea. Example: My system is in a host that is located in other city, so the printer is near my, but the PHP code is running in other place almost 1800kms between the printer and the PHP system. My customer use the system a prints from html page generated. When a need specific printing, I create a PDF file on the fly with TCPDF software library. I use this lib to create a printable version of a legal document as PDF on the fly, open directly in the Firefox o IE Is your server running near the printer? Is so specific that create a PDF file does not resolve the problem? Alejandro MS -Mensagem original- De: Jim Giner [mailto:jim.gi...@albanyhandball.com] Enviada em: quinta-feira, 5 de janeiro de 2012 13:55 Para: php-general@lists.php.net Assunto: Re: [PHP] Printing I can't tell you much on this, because I don't use windows. You have to get the source at http://pecl.php.net/printer and compile it. I don't know the procedure, etc. -- Nilesh Govindarajan http://nileshgr.com That was a short trip. Clicked on the link for documentation and it takes me right back to the php manual pages that I'd already read. Clicked on the link to download the latest and it's a dead link. Does anyone print from their php websites?? -- 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
RES: [PHP] Installing PHP
Mateus: Para configurar o php no apache : 1) Adicionar estas linhas no httpd.conf Troca D:\PHP\ pelos dados da tua instalação. #BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL PHPIniDir D:\PHP\ LoadModule php5_module D:\PHP\php5apache2_2.dll AddHandler application/x-httpd-php .php #END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL 2 ) Trocar o directory index do apache IfModule dir_module DirectoryIndex index.html index.php adicionar index.php como um arquivo padrão para ele procurar /IfModule Inglish: Mateus: To configure php on apache: 1) Add this lines in httpd.conf Change this D:\PHP\ to yours instalation data. #BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL PHPIniDir D:\PHP\ LoadModule php5_module D:\PHP\php5apache2_2.dll AddHandler application/x-httpd-php .php #END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL 2 ) Change the directory index on apache IfModule dir_module DirectoryIndex index.html index.php == add index.php to be a default file to search /IfModule Alejandro M.S. PAO/RS Brasil -Mensagem original- De: Mateus Almeida [mailto:supor...@avanutri.com.br] Enviada em: segunda-feira, 19 de setembro de 2011 18:32 Para: php-general@lists.php.net Assunto: [PHP] Installing PHP Hello, I'm newbie and I'm trying to install PHP with Apache, but it doesn't work. Every time I try to run a test I receive the message Not Found The requested URL /php/php-cgi.exe/test.php was not found on this server. OR (when I try to change some options) Forbidden You don't have permission to access /php/php-cgi.exe/test.php on this server. I've tried to copy the recommended configurations from some sites, but it haven't worked. The machine runs Windows XP, I'm using an administrator account, no firewall is blocking me, PHP and Apache are the most recent versions. Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RES: [PHP] Installing PHP
Jim: In my Windows the install adds the lines : #BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL PHPIniDir C:\PHP\ LoadModule php5_module C:\PHP\php5apache2_2.dll AddHandler application/x-httpd-php .php #END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL Where is the apache version that you install? I have the apache 2.2.17 This php5apache2.dll is for the version 2.0.x And this php5apache2_2.dll for the version 2.2.x Maybe the dll files is in the brong version. Alejandro M.S. -Mensagem original- De: Jim Giner [mailto:jim.gi...@albanyhandball.com] Enviada em: segunda-feira, 4 de julho de 2011 09:40 Para: php-general@lists.php.net Assunto: [PHP] Installing PHP Hi all, (Hopefully I posted this in a place that can/will help me) I got curious about running php / apache on my own laptop in order to help my devl process, instead of writing, uploading and testing on my site. Found a nice pair of docs from thesitewizard.com that appeared to be pretty well-written instructions on installing each of these systems. btw- I'm running XpSp2. Chose the Apache 2.0 and PHP 5.2 (thread-safe?) per the recommendations. Went thru all instructions step-by-step, testing all the way. Apache works - PHP doesn't. When I bring up IE and type in localhost I get the default apache page as I was told I should see. When I type localhost/test.php I get a windows dialog asking what program should run the php script. In debugging I went to a cmd windows and ran c:\php\php-cgi test.php and got the expected result from my script - so PHP works. End result - they each work separately, but php is not working under apache. As part of the docs instructions I added the following code to the apache conf file: 1 - I chose the configure apache to run php as an apache module. 2 - added LoadModule php5_module c:/php/php5apache2.dll as last one of those lines 3 - added AddType application/x-httpd-php .php as the last of those lines 4 - added PHPIniDir c:/php as the last line of the conf file. Upon adding these lines apache will no longer restart. In fact adding any ONE of these lines breaks Apache. Ideas welcome. And for those who still love the USofA, Happy Independence Day! -- 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
RES: [PHP] Short tag: why is it bad practice?
Andre : As Joshua says, the only php tags that always is enabled is ?php ?, this is the default php tag, and never can be disabled. This ? ? is enabled if short_open_tag is on And this % % is enabled if asp_tags is on But the default is off for both. Use this ?php ?, and forgive configuration options. Alejandro M.S. -Mensagem original- De: Joshua Kehn [mailto:josh.k...@gmail.com] Enviada em: terça-feira, 10 de maio de 2011 12:19 Para: Andre Polykanine Cc: php-general@lists.php.net Assunto: Re: [PHP] Short tag: why is it bad practice? On May 10, 2011, at 11:11 AM, Andre Polykanine wrote: Hi everyone, Many times I heard that the following two peaces of code are written in a bad manner: 1. ? echo Hello, world!; ? 2. form action=script.php method=post pYour e-mail: input type=text id=uemail name=uemail value=?=$f['Email']?/p ... /form As for now, I use both quite often. Why is this considered not kosher, I mean, good coding practice? Thanks! -- With best regards from Ukraine, Andre Skype: Francophile Twitter: http://twitter.com/m_elensule Facebook: http://facebook.com/menelion Because short tags aren't always enabled and can cause things to break when deploying code to different environments. Best practice dictates that your code should be as environmentally independent as possible. It's another few characters, why neglect it? Regards, -Josh Joshua Kehn | josh.k...@gmail.com http://joshuakehn.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
RES: [PHP] Acentos en tpl
Lorena : Yo trabajo con idioma portugués y utilizo esto en mi código : !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns=http://www.w3.org/1999/xhtml; xml:lang=pt-br lang=pt-br head meta http-equiv=Content-Encoding content=gzip / meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 / meta http-equiv=Content-Style-Type content=text/css / meta http-equiv=Content-Script-Type content=text/javascript / ... Nunca e tenido problemas con caracteres especiales como é o ú. Y utilizo varios .tpl, deves fijarte en los .tpl para saber qual Content-Type estan utilizando. Otra cosa importante es saber si la información viene de una base de datos, y si esta utiliza LATIN1 como conjunto de caracteres o UTF-8. Para hacer las conversiones que fueren precisas Alejandro M.S. English version: Lorena : I work with portugues and use this in my code : !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns=http://www.w3.org/1999/xhtml; xml:lang=pt-br lang=pt-br head meta http-equiv=Content-Encoding content=gzip / meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 / meta http-equiv=Content-Style-Type content=text/css / meta http-equiv=Content-Script-Type content=text/javascript / ... I never have problems with special characters like é or ú. I use some .tpl, you have to look at .tpl to know what Content-Type the file are using. Other important thing if to know if the information is coming from the database, and if is using LATIN1 CHARACTER SET or UTF-8. To do the conversions that are needed. Alejandro M.S. -Mensagem original- De: Lorena Monroy O. [mailto:lorenamon...@yahoo.com] Enviada em: quinta-feira, 17 de março de 2011 12:55 Para: php-general@lists.php.net Assunto: [PHP] Acentos en tpl Hola a todos Tengo un formulario que tiene dos paneles (.tpl), el cual maneja variables que vienen de php con la funcion setVariable, pero en el panel del menu me carga las tildes correctamente y a la derecha me las carga como un rombo con interrogación. Manejo Firefox y probe cambiando la configuración de caracteres de UTF-8 a Occidental, pero a la izquierda se ve mal y a la derecha se ve bien. Si modifico en el codigo por oacute; ahi se ve bien, pero en otros combos no... como puedo hacer que en ese tpl se vea bien sin modificarlo desde el codigo. Gracias Lorenita Ing. Electrónica U. Bosque Ing. de Sistemas U. Bosque Especialista en Telecomunicaciones Móviles U.Distrital -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RES: [PHP] Bar Charts in PDFs
Tom: You can try: http://www.tcpdf.org/ to generate pdf. And http://jpgraph.net/ To generate chart. EX: to add a image to a pdf document: $pdf-Image( '/home/peter/test.png', 127.78, 15, // left and right 74.93, 6.42, // width and height 'PNG', '', 'T', false, 300 ); With this tcpdf i create a legal documents for Brazilian government. Alejandro MS -Mensagem original- De: Tom Barrett [mailto:t...@miramedia.co.uk] Enviada em: sexta-feira, 11 de fevereiro de 2011 06:55 Para: php-general@lists.php.net Assunto: [PHP] Bar Charts in PDFs Hi I need to generate some PDF reports (1000s). Part of the report is a set of bar charts (the results of a questionnaire). Each question has the same 5 answers (v.bad, bad, ok ,good, v.good) and the chart is the % distribution of the answers. My plan is to create a HTML version, using some graph drawing* (saving a copy of the HTML to disk), creating a PDF version using html2pdf (saving a copy to disk and emailing to the recipient). I think html2pdf can handle this. But I have not had much success finding something to draw my graphs. Any (free) simple libraries out there I could be pointed towards? Thanks! Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RES: [PHP] email address syntax checker
Donovan: Try this function EmailCheck ( $sEmail ) { $regexp=/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z ]{2,}$/i; if ( !preg_match($regexp, $sEmail) ) return false; return true; } Alejandro M.S. -Mensagem original- De: Donovan Brooke [mailto:li...@euca.us] Enviada em: quinta-feira, 20 de janeiro de 2011 01:14 Para: php-general@lists.php.net Assunto: [PHP] email address syntax checker Hi Guys, I'm waddling my way through database interaction and thought someone on the list may already have a simple email checker that they'd like to share... you know, looking for the @ char and dots etc.. I did a quick search of the archives and found a couple elaborate things.. but I'm looking for something simple. This job will have trusted users and the checker is more to help them catch mistakes when registering. Thanks!, Donovan -- D Brooke -- 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
RES: [PHP] Connecting to MySql with PHP
Sueandant : Goto your my.ini file In my case located in C:\Arquivos de programas\MySQL\MySQL Server 5.1 Search is this configuration option is enabled = skip-networking And comment to enabled listen on a TCP/IP port. Default port 3306 Or Put = enable-named-pipe to enable named pipes Alejandro M.S. -Mensagem original- De: sueandant [mailto:hollandsath...@tiscali.co.uk] Enviada em: segunda-feira, 4 de outubro de 2010 18:08 Para: php-general@lists.php.net Assunto: [PHP] Connecting to MySql with PHP I am running PHP 5.3.3, with Apache 2.0 Handler and MySql Server 5.1. My OS is Vista Home Premium 32 bit with SP2. MySql works fine from the command prompt, Apache is running and PHP works. But I cannot access the mysqli classes. This simple program: ?php $mysqli = new mysqli(localhost, root, ##, testDB);#I've deliberately obliterated the password if (mysqli_connect_errno()) { printf(Connect failed: %s\n, mysqli_connect_error()); exit(); } else { printf(Host information: %s\n, mysqli_get_host_info($mysqli)); } ? produces this error message: Warning: mysqli::mysqli() [mysqli.mysqli]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in C:\Apache\htdocs\mysqlconnect.php on line 3 Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\Apache\htdocs\mysqlconnect.php on line 3 Fatal error: Maximum execution time of 30 seconds exceeded in C:\Apache\htdocs\mysqlconnect.php on line 3 I guess PHP cannot find the mysqli classes. I've checked the phpinfo() output and discovered : Configuration File (php.ini) Path C:\Windows Loaded Configuration File C:\PHP\php.ini I don't know if this ok. I've tried changing the location of the loaded file to C:\Windows\php.ini, but to no avail, and I don't know how to change the location of the config file. I am obviously doing something wrong, but I don't know what. Can anyone help? Ironically, everything worked perfectly before I upgraded to PHP 5.3.3! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RES: [PHP] Connecting to MySql with PHP
Sueandant : Reading more carefully your email, and search for this error in the net. Y find this page http://coreygilmore.com/blog/2009/11/20/fix-php-5-3-hang-on-windows/ Try this Alejandro M.S. -Mensagem original- De: Alejandro Michelin Salomon [mailto:amichel...@hotmail.com] Enviada em: terça-feira, 5 de outubro de 2010 09:01 Para: 'sueandant' Cc: php-general@lists.php.net Assunto: RES: [PHP] Connecting to MySql with PHP Sueandant : Goto your my.ini file In my case located in C:\Arquivos de programas\MySQL\MySQL Server 5.1 Search is this configuration option is enabled = skip-networking And comment to enabled listen on a TCP/IP port. Default port 3306 Or Put = enable-named-pipe to enable named pipes Alejandro M.S. -Mensagem original- De: sueandant [mailto:hollandsath...@tiscali.co.uk] Enviada em: segunda-feira, 4 de outubro de 2010 18:08 Para: php-general@lists.php.net Assunto: [PHP] Connecting to MySql with PHP I am running PHP 5.3.3, with Apache 2.0 Handler and MySql Server 5.1. My OS is Vista Home Premium 32 bit with SP2. MySql works fine from the command prompt, Apache is running and PHP works. But I cannot access the mysqli classes. This simple program: ?php $mysqli = new mysqli(localhost, root, ##, testDB);#I've deliberately obliterated the password if (mysqli_connect_errno()) { printf(Connect failed: %s\n, mysqli_connect_error()); exit(); } else { printf(Host information: %s\n, mysqli_get_host_info($mysqli)); } ? produces this error message: Warning: mysqli::mysqli() [mysqli.mysqli]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in C:\Apache\htdocs\mysqlconnect.php on line 3 Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\Apache\htdocs\mysqlconnect.php on line 3 Fatal error: Maximum execution time of 30 seconds exceeded in C:\Apache\htdocs\mysqlconnect.php on line 3 I guess PHP cannot find the mysqli classes. I've checked the phpinfo() output and discovered : Configuration File (php.ini) Path C:\Windows Loaded Configuration File C:\PHP\php.ini I don't know if this ok. I've tried changing the location of the loaded file to C:\Windows\php.ini, but to no avail, and I don't know how to change the location of the config file. I am obviously doing something wrong, but I don't know what. Can anyone help? Ironically, everything worked perfectly before I upgraded to PHP 5.3.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
RES: [PHP] New to PHP and struggling with the basics
Col Day : Go to : C:\Arquivos de programas\Apache Software Foundation\Apache2.2\conf or the folder in your machine. Search for this file = httpd.conf Search for DocumentRoot D:/webroot put your work folder in my case D:/webroot. Search for this line and apply the same changes make in DocumentRoot # # This should be changed to whatever you set DocumentRoot to # Directory D:/webroot Search for DirectoryIndex, and add index.php to the list # # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # IfModule dir_module DirectoryIndex index.html index.php /IfModule Add on the end of the file this lines : My php installation folder is D:/PHP/, change D:/PHP/ to your installation folder. #BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL PHPIniDir D:/PHP/ # Php as Apache module LoadModule php5_module D:/PHP/php5apache2_2.dll Restart apache. Browse to localhost Alejandro M.S. -Mensagem original- De: Col Day [mailto:colind...@aol.com] Enviada em: segunda-feira, 4 de outubro de 2010 06:31 Para: php-general@lists.php.net Assunto: [PHP] New to PHP and struggling with the basics Hi all, Working with the PHP5 for Dummies book (yup real noob, feel free to ridicule (after telling me what I've done wrong)) and have installed Apache 2.2 and PHP 5.3.3 onto a laptop running Vista. (yes I know!!!). I've had Apache running fine with my basic web site created using Serif's Webplus10 but wanted to experiment with PHP as I want an uploadable area on my website for my friends and family to submit video/photos. I've checked the install of PHP using php -v and I get the output that PHP 5.3.3 (cli) (built: Jul 21 2010 20:10:20) but when I try and go to the test.php file (below) I get an http 403 webiste requires you to log in. Error message. html head titlePHP Test/title /head body pThis is an HTML line ?php echo pThis is a PHP line/p; phpinfo(); ? /body /html This is the text of the test.php file which I have plonked down in /apache/htdocs What have I missed? the Dummies book is quoting PHP 5.0.0 as the latest release so not too far away really. Thanks for your help. Cheers. Col Day -- 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
RES: [PHP] converting a mysql date value
David : Try this : $a = explode('-', '2010-01-23'); $b = array( $a[1], $a[2], $a[0] ); echo implode( '/', $b); // 01/23/2010 Alejandro M.S. -Mensagem original- De: David Mehler [mailto:dave.meh...@gmail.com] Enviada em: quarta-feira, 29 de setembro de 2010 16:12 Para: php-general Assunto: [PHP] converting a mysql date value Hello, I've got dates stored in a mysql database. The field is of type date so the value is something like: 2010-09-29 I'm wanting to display them as in U.S. dates as in month, day, year. I had a function that did this, now it is not working and I am perplexed as to why. Here's my echo statement: ?php echo sqlDateFormat($row['date']); ? The $row['date'] is coming out of the mysql database. Here's the sqlDateFormat function: function sqlDateFormat($value) { $date = $value; $date = strtotime($date); $date = date('m-d-y', $date); return $date; } I'd appreciate any suggestions as to why this isn't working. Thanks. Dave. -- 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
RES: [PHP] Invalid chars in XML
Hi I am working with xml, in portuguese, and i have many problems with special characters. I find this code to work with this problem... When create xml ExpandEntities : function ExpandEntities( $sText ) { $trans = array('' = 'amp;', ' = 'apos;', '' = 'quot;', '' = 'lt;', '' = 'gt;' ); return strtr( $sText, $trans ); } When read xml CompEntities function CompEntities( $sText ) { $trans = array('amp;' = '', 'apos;' = ', 'quot;' = '', 'lt;' = '', 'gt;' = '' ); return strtr( $sText, $trans ); } Alejandro M.S. -Mensagem original- De: robert mena [mailto:robert.m...@gmail.com] Enviada em: segunda-feira, 20 de setembro de 2010 17:08 Para: php-general@lists.php.net Assunto: [PHP] Invalid chars in XML 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? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Valid Xml not validate with xsd
Hi: I am working with a xml document that is validate with a schema. Within php the xml does not validate, but if i use a external validator the same xml validates with no problems. My Php is now 5.2.14, but i test with 5.3.1 and the same problem. I create a small program as example: libxml_use_internal_errors(true); $xDocXml = 'test-file.xml'; // xml $xmldoc = new DOMDocument(); $bErro = $xmldoc-load( $xDocXml ); // loads xml if ( $bErro ) { $return = $xmldoc-schemaValidate( 'nfe_v2.00.xsd' ); if ( !$return ) { $aErros = libxml_get_errors(); $sErro = ''; foreach ( $aErros as $oErro ) { switch ( $oErro-level ) { case LIBXML_ERR_WARNING: $sErrosErro .= ' Atenção ' . $oErro-code . : \n; break; case LIBXML_ERR_ERROR: $sErro .= ' Erro ' . $oErro-code . : \n; break; case LIBXML_ERR_FATAL: $sErro .= ' Erro Fatal ' . $oErro-code . : \n; break; } $sErro .= '' . \n; $sErro .= $oErro-message; $sErro .= ' Line: ' . $oErro-line . \n; $sErro .= ' Column: ' . $oErro-column . \n; $sErro .= ' Level: ' . $oErro-level . \n; } echo 'pre'; echo $sErro; echo '/pre'; } else echo 'VALID'; } Result a this moment: Erro 1839: Element '{http://www.portalfiscal.inf.br/nfe}IE': [facet 'pattern'] The value '' is not accepted by the pattern 'ISENTO|[0-9]{0,14}'. Line: 59 Column: 0 Level: 2 Erro 1824: Element '{http://www.portalfiscal.inf.br/nfe}IE': '' is not a valid value of the atomic type '{http://www.portalfiscal.inf.br/nfe}TIeDest'. Line: 59 Column: 0 Level: 2 This is the rule that fails : xs:simpleType name=TIeDest xs:annotation xs:documentationTipo Inscrição Estadual do Destinatário/xs:documentation /xs:annotation xs:restriction base=xs:string xs:whiteSpace value=preserve/ xs:pattern value=ISENTO|[0-9]{0,14}/ /xs:restriction /xs:simpleType In the xml file the line 59 has : IE/IE The pattern for this tag is : xs:pattern value=ISENTO|[0-9]{0,14}/ When i change this xs:pattern value=ISENTO|[0-9]{0,14}/ to xs:pattern value=[0-9]{0,14}|ISENTO/ work ok, buts each document that has IEISENTO/IE fails validation. I attached a small rar file with the test case. How to change the pattern to meets the requirements: or value ISENTO ou number [0-9]{0,14} or empty ? Thanks in advance Alejandro M.S. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php