Re: [PHP] Help using PHP 5.3.3 mail() with Apache James
On 23-10-2012 23:54, Steven Pogue wrote: Dan, I assume you meant to add a system() call into it...if so, here is what was presented. -rwxrwxrwx. 1 root root 3878 Sep 6 14:45 /opt/james-2.3.2/bin/sendmail.py -rwxrwxrwx. 1 root root 3878 Sep 6 14:45 /opt/james-2.3.2/bin/sendmail.py Steve Hey Steve, first of all: don't top-post. Secondly: no, he didn't. Dan used the backtick operator (`) which is the same as calling system on its parameter. ie: `ls -l` is equal to writing shell_exec('ls -l') ( http://www.php.net/manual/en/language.operators.execution.php ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help using PHP 5.3.3 mail() with Apache James
On Thu, Oct 25, 2012 at 5:32 AM, Maciek Sokolewicz maciek.sokolew...@gmail.com wrote: On 23-10-2012 23:54, Steven Pogue wrote: Dan, I assume you meant to add a system() call into it...if so, here is what was presented. -rwxrwxrwx. 1 root root 3878 Sep 6 14:45 /opt/james-2.3.2/bin/sendmail.py -rwxrwxrwx. 1 root root 3878 Sep 6 14:45 /opt/james-2.3.2/bin/sendmail.py Steve Hey Steve, first of all: don't top-post. Secondly: no, he didn't. Dan used the backtick operator (`) which is the same as calling system on its parameter. ie: `ls -l` is equal to writing shell_exec('ls -l') ( http://www.php.net/manual/en/language.operators.execution.php ) I have lost the backtick operator so many times, I've stopped using it, using shell_exec instead. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help using PHP 5.3.3 mail() with Apache James
On Tue, Oct 23, 2012 at 5:00 PM, Steven Pogue spo...@us.ibm.com wrote: Has anyone been successful at using the above on a RHEL 6.2 environment? I am able to use Postfix using the php.ini SENDMAIL_PATH but when I bring down PostFix, start Apache James and switch the sendmail_path value to point to the Apache James 2.3.2 provided wrapper (/opt/james-2.3.2/bin/sendmail.py) the return code on mail() indicates it failed and no record of the wrapper being invoked. Calling the wrapper directly from the command-line works as expected so the problem is somewhere between PHP and the sendmail_path invocation. What is the output of the following code? ?php echo 'pre'.PHP_EOL; echo trim(`ls -al /opt/james-2.3.2/bin/sendmail.py`).PHP_EOL; echo '/pre'.PHP_EOL; ? -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help using PHP 5.3.3 mail() with Apache James
Dan, I assume you meant to add a system() call into it...if so, here is what was presented. -rwxrwxrwx. 1 root root 3878 Sep 6 14:45 /opt/james-2.3.2/bin/sendmail.py -rwxrwxrwx. 1 root root 3878 Sep 6 14:45 /opt/james-2.3.2/bin/sendmail.py Steve From: Daniel Brown danbr...@php.net To: Steven Pogue/Raleigh/IBM@IBMUS Cc: php-general@lists.php.net Date: 10/23/2012 05:24 PM Subject: Re: [PHP] Help using PHP 5.3.3 mail() with Apache James Sent by: paras...@gmail.com On Tue, Oct 23, 2012 at 5:00 PM, Steven Pogue spo...@us.ibm.com wrote: Has anyone been successful at using the above on a RHEL 6.2 environment? I am able to use Postfix using the php.ini SENDMAIL_PATH but when I bring down PostFix, start Apache James and switch the sendmail_path value to point to the Apache James 2.3.2 provided wrapper (/opt/james-2.3.2/bin/sendmail.py) the return code on mail() indicates it failed and no record of the wrapper being invoked. Calling the wrapper directly from the command-line works as expected so the problem is somewhere between PHP and the sendmail_path invocation. What is the output of the following code? ?php echo 'pre'.PHP_EOL; echo trim(`ls -al /opt/james-2.3.2/bin/sendmail.py`).PHP_EOL; echo '/pre'.PHP_EOL; ? -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/
Re: [PHP] Help with MSSQL and Stored Procs
On Wed, Aug 29, 2012 at 3:14 PM, Phillip Baker phil...@freewolf.net wrote: I am trying to access a MSSQL DB on another system. I am having trouble executed a stored proc and debugging the problem./ I have included the code below. I can connect to the DB just fine. I also can run regular queries on the DB and get a result set. We can also run the stored proc manually with the data in $xmlstring and that runs fine. However the mssql_execute is failing. I am getting the Execute failed die message however I am not getting anything for mssql_get_last_message So I have no idea what is happening. And ideas for solutions or at least to get more debugging information would be awesome. I know SQLSRV is a more recent option however we do not have it installed on the server and will likely not get that to happen so I need to get this debugged. $link = mssql_connect($myServer, $myUser, $myPass) or die(Couldn't connect to SQL Server on $myServer); mssql_select_db($myDB, $link) or die(Couldn't select database $myDB); if(!$link){ die('Error connecting to MSSQL database at '.$myServer); } else { $version = mssql_query('SELECT @@VERSION'); $row = mssql_fetch_array($version); mssql_free_result($version); echo $row[0].'br /br /'; } $storedproc = Sp_DialerValidLead; $param = ValidLeadText; $stmt = mssql_init('Sp_DialerValidLead', $link) or die(Unable to initialize); mssql_bind($stmt, @.$param, $xmlstring, SQLVARCHAR) or die(Unable to bind @ValidLeadText:$storedprocbr.mssql_get_last_message()); $result = mssql_execute($stmt) or die (Execute failed. Message:.mssql_get_last_message()); var_dump($result); Blessed Be Phillip I had to go to an old server that we are phasing out to find something that had php_mssql installed on it, but once I got everything set up it everything worked fine for me. I tested it with everything correct as well as with a variety of forced errors (procedure doesn't exist, user does not have permission to execute, parameter name different than passed by PHP, etc.) and they all displayed error messages using the code you posted above. The server is running PHP 5.2.12, and this one can only connect to our SQL Server 2000 instance, so I can't test it against SQL 2008. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with query
Jack jacklistm...@gmail.com wrote: Hello All, I have this string defined for my query and it shows the different types of categories fine, but when I change a.categoryid = c.categoryid to a.categoryid = 1 which is only one of the categories It shows me the same record twice. $query = select a.startdate, a.articleid, c.name, a.title, a.intro, a.datecreated from articles as a, categories as c where (a.startdate = -1 or a.startdate = {$now}) and (a.enddate = -1 or a.enddate = {$now}) and a.categoryid = c.categoryid order by a.startdate DESC; while ( $row = mysql_fetch_array($res) ) { $tpldata['articles'][] = array( 'title' = $row['title'], 'intro' = makeLinks($row['intro']), 'id'= $row['articleid'], 'categoryname' = $row['name'], 'created' = date('n/j/Y', $row['datecreated']) ); //echo $row['datecreated']; } Any Ideas??? Thanks! How many entries in total are in your categories table? You're joining the table but not putting any kind of constraint on the joined tables, so its doing a join on all the rows. You can either add an extra clause on the join, leave the original join and limit with a where clause, or use a group by on that field. Thanks, Ash http://ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with query
On 06/07/2012 09:37 AM, Jack wrote: $query = select a.startdate, a.articleid, c.name, a.title, a.intro, a.datecreated from articles as a, categories as c where (a.startdate = -1 or a.startdate= {$now}) and (a.enddate = -1 or a.enddate= {$now}) and a.categoryid = c.categoryid order by a.startdate DESC; $query = SELECT a.startdate, a.articleid, c.name, a.title, a.intro, a.datecreated FROMarticles as a, categories as c WHERE ( a.startdate = -1 OR a.startdate = {$now} ) AND ( a.enddate = -1 OR a.enddate = {$now} ) -- This line must stay, it is limiting the combination of the data from -- both tables AND a.categoryid = c.categoryid -- You need to add this line to make it work, but keep the previous line AND a.categoryid = 1 ORDER BY a.startdate DESC ; -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ http://www.bendsource.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] help with query
Thanks Jim, worked like a charm. -Original Message- From: Jim Lucas [mailto:li...@cmsws.com] Sent: Thursday, June 07, 2012 4:08 PM To: Jack Cc: PHP Subject: Re: [PHP] help with query On 06/07/2012 09:37 AM, Jack wrote: $query = select a.startdate, a.articleid, c.name, a.title, a.intro, a.datecreated from articles as a, categories as c where (a.startdate = -1 or a.startdate= {$now}) and (a.enddate = -1 or a.enddate= {$now}) and a.categoryid = c.categoryid order by a.startdate DESC; $query = SELECT a.startdate, a.articleid, c.name, a.title, a.intro, a.datecreated FROMarticles as a, categories as c WHERE ( a.startdate = -1 OR a.startdate = {$now} ) AND ( a.enddate = -1 OR a.enddate = {$now} ) -- This line must stay, it is limiting the combination of the data from -- both tables AND a.categoryid = c.categoryid -- You need to add this line to make it work, but keep the previous line AND a.categoryid = 1 ORDER BY a.startdate DESC ; -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ http://www.bendsource.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with preg_match
On 2012-06-03 22:37, Robert Williams wrote: On Jun 3, 2012, at 17:28, Chris Purvesch...@northfolk.ca wrote: I know that the text ends 'end', but I don't know what the Something, something is. I am using preg_match as follows: preg_match('/[^]*end/',$curl_response,$matches); I want to match 'end' and everything before it that is not ''. You need to match something at the beginning. Try this: preg_match('/([^]*end)/', $curl_response, $matches); Assuming a match, you can then look to $matches[1] for your content. That did it. In my case, I know that the first letter is capitalized, so I used: preg_match('/[A-Z][^]*end/', $curl_response, $matches); Thanks for your help. -- Chris Purves The eyes are the groin of the head. Dwight Schrute -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with preg_match
On Jun 3, 2012, at 17:28, Chris Purves ch...@northfolk.ca wrote: I know that the text ends 'end', but I don't know what the Something, something is. I am using preg_match as follows: preg_match('/[^]*end/',$curl_response,$matches); I want to match 'end' and everything before it that is not ''. You need to match something at the beginning. Try this: preg_match('/([^]*end)/', $curl_response, $matches); Assuming a match, you can then look to $matches[1] for your content. -- Bob Williams Notice: This communication, including attachments, may contain information that is confidential. It constitutes non-public information intended to be conveyed only to the designated recipient(s). If the reader or recipient of this communication is not the intended recipient, an employee or agent of the intended recipient who is responsible for delivering it to the intended recipient, or 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. If you have received this email in error, please notify us immediately by e-mail or telephone and delete the e-mail and the attachments (if any). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] help with preg_match
-Original Message- From: Chris Purves [mailto:ch...@northfolk.ca] Sent: Sunday, June 03, 2012 8:26 PM To: php-general General Subject: [PHP] help with preg_match Hello, I am trying to use preg_match to match something from an html file. Within the html file is some text that looks like: spanSomething, something end/span I know that the text ends 'end', but I don't know what the Something, something is. I am using preg_match as follows: preg_match('/[^]*end/',$curl_response,$matches); I want to match 'end' and everything before it that is not ''. The problem appears to be with the ''. I have tried escaping (\), but it didn't make a difference. The php script hangs when it tries to run this function. -- Chris Purves There's a time to think, and a time to act. And this, gentlemen, is no time to think. - Sheriff Bud B. Boomer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- You could try this preg_match_all('/(span[^]**)(.*)(/span[^]*)/is',$curl_response,$matc hes); print_r($matches); Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help! Having trouble getting one XML field from this feed reliably
I wonder why you use cURL as SimpleXML itself can load URLs: $vastdata = new SimpleXMLElement('http://afe.specificclick.net/?l=32259t=xrnd=123456',0,true); See http://de.php.net/manual/en/simplexmlelement.construct.php Am 09.02.2012 04:44, schrieb Rob Gould: Can anyone tell me what I'm doing wrong here? I'm trying to get the VASTAdTagURI field from the XML data at this url: http://afe.specificclick.net/?l=32259t=xrnd=123456 Here's my code. (below). It works maybe 30% of the time, but most of the time it just returns nothing from that field. Yet when I go to the above url in Firefox, I always see the data. This is very strange. // Lets get the ad! $curl_handle=curl_init(); curl_setopt($curl_handle,CURLOPT_URL,'http://afe.specificclick.net/?l=32259t=xrnd=123456'); curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2); curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1); $buffer = curl_exec($curl_handle); curl_close($curl_handle); $vastdata = new SimpleXMLElement($buffer); $vasturi = $vastdata-Ad-Wrapper-VASTAdTagURI; echo If the script works, vasturi = . $vasturi; echo brbrbr; print_r($vastdata); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help! Having trouble getting one XML field from this feed reliably
On Thu, Feb 9, 2012 at 9:10 AM, Yared Hufkens y4...@yahoo.de wrote: I wonder why you use cURL as SimpleXML itself can load URLs: $vastdata = new SimpleXMLElement('http://afe.specificclick.net/?l=32259t=xrnd=123456 ',0,true); See http://de.php.net/manual/en/simplexmlelement.construct.php It is pretty convenient that SimpleXMLElement allows you to grab URL's, but curl allows me to manually set a timeout limit (along with many other things, although they're not necessarily needed in Rob's example), so I tend to use curl in this type situation, too. Adam -- Nephtali: A simple, flexible, fast, and security-focused PHP framework http://nephtaliproject.com
Re: [PHP] Help! Having trouble getting one XML field from this feed reliably
On Wed, Feb 8, 2012 at 10:44 PM, Rob Gould gould...@mac.com wrote: Can anyone tell me what I'm doing wrong here? I'm trying to get the VASTAdTagURI field from the XML data at this url: http://afe.specificclick.net/?l=32259t=xrnd=123456 Here's my code. (below). It works maybe 30% of the time, but most of the time it just returns nothing from that field. Yet when I go to the above url in Firefox, I always see the data. This is very strange. // Lets get the ad! $curl_handle=curl_init(); curl_setopt($curl_handle,CURLOPT_URL,' http://afe.specificclick.net/?l=32259t=xrnd=123456'); curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2); curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1); $buffer = curl_exec($curl_handle); curl_close($curl_handle); $vastdata = new SimpleXMLElement($buffer); $vasturi = $vastdata-Ad-Wrapper-VASTAdTagURI; echo If the script works, vasturi = . $vasturi; echo brbrbr; print_r($vastdata); I'd try adding some error checks to see what issues curl may be having: $str = curl_exec($ch); $error_no = curl_errno($ch); curl_close ($ch); if ($error_no != 0) throw new Exception('There was an error retrieving the string contents of the url \''.$url.'\'. CURL error number:'.$error_no); I wonder if you transaction is timing out, which you can set as below: curl_setopt($ch, CURLOPT_TIMEOUT, $transaction_timeout = 2); Adam -- Nephtali: A simple, flexible, fast, and security-focused PHP framework http://nephtaliproject.com
Re: [PHP] Help with redeclare error
On Thu, 2011-10-27 at 17:40 -0700, UltraMega Admin wrote: On 10/27/2011 5:33 PM, Daniel Brown wrote: On Thu, Oct 27, 2011 at 20:06, Jason Pruimli...@pruimphotography.com wrote: Most likely you have in included in 2 files... Look into it from that angle... It only needs to be included in 1 file to work throughout all the files. Prune is spot-on. That error generally happens when you include a file that has already been included, which contains function definitions. Look at the code in the files the error mentions, on the lines it specifies, and - most likely - you'll see an include. Changing them to include_once instead will resolve the issue, as PHP will just skip the order if it's already been done within the execution of the code. A function with that name already exists in PHP as of 5.3.0. You'll have to rename it or something. http://us2.php.net/manual/en/function.date-diff.php Or wrap it inside a function_exists() call assuming that both your function and the internal one do the same thing. -- Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] Help with redeclare error
A function with that name already exists in PHP as of 5.3.0. You'll have to rename it or something. http://us2.php.net/manual/en/function.date-diff.php That looks like what happened that new function was added and we had written one with the same name from the stone age... Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with redeclare error
Jason Pruim li...@pruimphotography.com On Oct 27, 2011, at 7:55 PM, Jack wrote: Hello All, I have some code that just broke with a PHP upgrade, the error says: PHP Fatal error: Cannot redeclare date_diff() the line of the error is the close bracket of the function which is below. Any ideas what's going on, I'm stuck? Most likely you have in included in 2 files... Look into it from that angle... It only needs to be included in 1 file to work throughout all the files. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with redeclare error
On Thu, Oct 27, 2011 at 20:06, Jason Pruim li...@pruimphotography.com wrote: Most likely you have in included in 2 files... Look into it from that angle... It only needs to be included in 1 file to work throughout all the files. Prune is spot-on. That error generally happens when you include a file that has already been included, which contains function definitions. Look at the code in the files the error mentions, on the lines it specifies, and - most likely - you'll see an include. Changing them to include_once instead will resolve the issue, as PHP will just skip the order if it's already been done within the execution of the code. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with redeclare error
On 10/27/2011 5:33 PM, Daniel Brown wrote: On Thu, Oct 27, 2011 at 20:06, Jason Pruimli...@pruimphotography.com wrote: Most likely you have in included in 2 files... Look into it from that angle... It only needs to be included in 1 file to work throughout all the files. Prune is spot-on. That error generally happens when you include a file that has already been included, which contains function definitions. Look at the code in the files the error mentions, on the lines it specifies, and - most likely - you'll see an include. Changing them to include_once instead will resolve the issue, as PHP will just skip the order if it's already been done within the execution of the code. A function with that name already exists in PHP as of 5.3.0. You'll have to rename it or something. http://us2.php.net/manual/en/function.date-diff.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help on number matching function
On Sep 16, 2011, at 6:02, Dare Williams darrenwi...@yahoo.com wrote: I have a 5 Digits set of number and need to match it with another set of five digits and return how many number are match and the figures that are match. Check out array_intersect(). http://us.php.net/manual/en/function.array-intersect.php -- Bob Williams Notice: This communication, including attachments, may contain information that is confidential. It constitutes non-public information intended to be conveyed only to the designated recipient(s). If the reader or recipient of this communication is not the intended recipient, an employee or agent of the intended recipient who is responsible for delivering it to the intended recipient, or 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. If you have received this email in error, please notify us immediately by e-mail or telephone and delete the e-mail and the attachments (if any). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help on number matching function
At 08:36 AM 9/16/2011, Dare Williams wrote: Dear PHP Group, I need a Function of any category in either PHP or MySQL RDBMS customize Function, Class, Methods or anything that could help me compare a particular set of number and return their matching result. e.g If I have a 5 Digits set of number and need to match it with another set of five digits and return how many number are match and the figures that are match. 1.(62,39,47,25,14) - (14,39,62,25,47) - match 5 (all) 2.(55,11,27,62,39) - (66,39,12,13,27) - match 2 (27,39) 3.(20,04,56,17,16) - (16,01,17,04,79) - match 3 (16,17,04) Any Help will be appreciated. Thank you. Turn your sets of number into an array and then use the function array_intersect, http://php.net/array_intersect Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help on number matching function
Hello Dare, DW I need a Function of any category in either PHP or MySQL RDBMS DW customize Function, Class, Methods or anything that could help me DW compare a particular set of number and return their matching DW result. consider using array_intersect(). -- With best regards from Ukraine, Andre Skype: Francophile My blog: http://oire.org/menelion (mostly in Russian) Twitter: http://twitter.com/m_elensule Facebook: http://facebook.com/menelion -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help on number matching function
If one or both of your data sets are in MySQL already, there may be no need to do the comparison in PHP. Just use IN() or INNER JOIN. Or is there some particular reason why neither of these will work in your case? Cheers, Mattias On 09/16/2011 05:36 AM, Dare Williams wrote: Dear PHP Group, I need a Function of any category in either PHP or MySQL RDBMS customize Function, Class, Methods or anything that could help me compare a particular set of number and return their matching result. e.g If I have a 5 Digits set of number and need to match it with another set of five digits and return how many number are match and the figures that are match. 1.(62,39,47,25,14) - (14,39,62,25,47) - match 5 (all) 2.(55,11,27,62,39) - (66,39,12,13,27) - match 2 (27,39) 3.(20,04,56,17,16) - (16,01,17,04,79) - match 3 (16,17,04) Any Help will be appreciated. Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with an array if its possible!
On Wed, Jun 22, 2011 at 18:43, Adam Preece a...@blueyonder.co.uk wrote: Hi Gang! i have 2 assoc arrays from 2 querys, first one is page categorys it consists of: id name second is pages name cat_id now, i am using smarty, so i pass arrays into the view. this i would like to pass to the view and display within a html select element. select id=name option value=CAT_IDCAT NAME option disabled=disabledPAGE NAME ASSOCIATED TO THE CAT NAME/option /option /select and i cannot think of how i can structure an array to pass in to achieve this and/or is it even possible :-/. i hope this makes sense. i'm truly stuck! If I'm understanding you correctly, this should get you started: ?php $arr = array( 'inventory_100' = 'apples', 'inventory_101' = 'oranges', 'inventory_102' = 'pears', 'inventory_103' = 'bananas', ); echo 'select id=inventory_items'.PHP_EOL; foreach ($arr as $k = $v) { echo ' option value='.$k.''.$v.'/option'.PHP_EOL; } echo '/select'.PHP_EOL; ? You can copy and paste that code (though I just typed it in here, it should work) and it should illustrate the point. -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with an array if its possible!
On 6/22/2011 3:43 PM, Adam Preece wrote: Hi Gang! i have 2 assoc arrays from 2 querys, first one is page categorys it consists of: id name second is pages name cat_id now, i am using smarty, so i pass arrays into the view. this i would like to pass to the view and display within a html select element. select id=name option value=CAT_IDCAT NAME option disabled=disabledPAGE NAME ASSOCIATED TO THE CAT NAME/option /option /select and i cannot think of how i can structure an array to pass in to achieve this and/or is it even possible :-/. i hope this makes sense. i'm truly stuck! kind regards Adam Preece I see that you have a nested option ... tag. Maybe you are looking for the optgroup tag. select optgroup label=Swedish Cars option value=volvoVolvo/option option value=saabSaab/option /optgroup optgroup label=German Cars option value=mercedesMercedes/option option value=audiAudi/option /optgroup /select ?php $categories[] = array('id' = 1, 'name' = 'cars'); $categories[] = array('id' = 2, 'name' = 'trucks'); $categories[] = array('id' = 3, 'name' = 'motorcycles'); $pages[] = array('id' = 1, 'name' = 'Neon', 'cat_id' = 1); $pages[] = array('id' = 2, 'name' = 'Saturn', 'cat_id' = 1); $pages[] = array('id' = 3, 'name' = 'F150', 'cat_id' = 2); $pages[] = array('id' = 4, 'name' = 'Ram 2500', 'cat_id' = 2); $pages[] = array('id' = 5, 'name' = 'Suzuki', 'cat_id' = 2); $pages[] = array('id' = 6, 'name' = 'Honda', 'cat_id' = 3); echo select id=\page_id\\n; foreach ($categories AS $cat) { $c_cat_name = htmlspecialchars($cat['name']); echo \toptgroup label=\{$c_cat_name}\\n; foreach ($pages AS $page) { if ( $page['cat_id'] == $cat['id'] ) { $c_page_id = htmlspecialchars((int)$page['id']); $c_page_name = htmlspecialchars($page['name']); echo \t\toption value=\{$c_page_id}\{$c_page_name}/option\n; } } # Reset pages so you can loop through it again reset($pages); echo \t/optgroup\n; } echo /select\n; ? All the above is untested, but should get you very close to what I think you are trying to accomplish. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help needed with php.ini
I remember that there's 2 php.ini in Fedora, one is for SAPI like apache or other CGIServer, and another is for CLI. Can you confirm that you edited a right config file? On Mon, Jun 6, 2011 at 4:55 AM, Camilo Sperberg unrea...@gmail.com wrote: On 05-06-2011, at 10:31, Adam Tong adam.to...@gmail.com wrote: Hi, I can't set correctly the error display and reporting properties. I don't know what i'm doing wrong. Here is the section that i modified in php.ini: - display_errors = On ; Default Value: On ; Development Value: On ; Production Value: Off display_startup_errors = On ; Default Value: Off ; Development Value: On ; Production Value: Off error_reporting = E_ALL | E_STRICT ; Default Value: E_ALL ~E_NOTICE ; Development Value: E_ALL | E_STRICT ; Production Value: E_ALL ~E_DEPRECATED And here is the output of phpinfo(): - display_errorsOffOff display_startup_errorsOffOff doc_rootno valueno value docref_extno valueno value docref_rootno valueno value enable_dlOffOff error_append_stringno valueno value error_logno valueno value error_prepend_stringno valueno value error_reporting22527 22527 - I'm using a default installation (using yum) of php on Fedora14. This is my development environment, and want to see all the errors on standard output. Thank you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Have you modified the example values instead of the ones mid-way php.ini? If so, scroll down to check. The latest settings should override the previous one. Have you restarted apache with service httpd restart or /etc/init.d/httpd restart? (or apachectl restart) In your php script or htaccess file, do you override those values? Sent from my iPhone 5 Beta [Confidential use only] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Powered By Francis™. Welcome to my website: http://www.francistm.com Rewrite to francis...@gmail.com please.
Re: [PHP] Help needed with php.ini
And here is the output of phpinfo(): - In the same phpinfo() output, what is the path/location of the php.ini file you are using? Loaded Configuration File D:\PHP\INI\php-cgi-fcgi.ini for example. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help needed with php.ini
On 05-06-2011, at 10:31, Adam Tong adam.to...@gmail.com wrote: Hi, I can't set correctly the error display and reporting properties. I don't know what i'm doing wrong. Here is the section that i modified in php.ini: - display_errors = On ; Default Value: On ; Development Value: On ; Production Value: Off display_startup_errors = On ; Default Value: Off ; Development Value: On ; Production Value: Off error_reporting = E_ALL | E_STRICT ; Default Value: E_ALL ~E_NOTICE ; Development Value: E_ALL | E_STRICT ; Production Value: E_ALL ~E_DEPRECATED And here is the output of phpinfo(): - display_errorsOffOff display_startup_errorsOffOff doc_rootno valueno value docref_extno valueno value docref_rootno valueno value enable_dlOffOff error_append_stringno valueno value error_logno valueno value error_prepend_stringno valueno value error_reporting2252722527 - I'm using a default installation (using yum) of php on Fedora14. This is my development environment, and want to see all the errors on standard output. Thank you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Have you modified the example values instead of the ones mid-way php.ini? If so, scroll down to check. The latest settings should override the previous one. Have you restarted apache with service httpd restart or /etc/init.d/httpd restart? (or apachectl restart) In your php script or htaccess file, do you override those values? Sent from my iPhone 5 Beta [Confidential use only] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with _get error
Jack wrote: Hello All, I'm having a problem with this line of code which worked fine for years: $l_url2 = ..$_GET[SERVER_NAME]; Here is the error: [Wed Mar 23 13:33:49 2011] [error] [client 16.139.201.61] PHP Notice: Use of undefined constant SERVER_NAME - assumed 'SERVER_NAME' in /home//modules/jack.php on line 322 Thanks! J You need to learn the differences in error reporting levels. My guess is you changed hosts recently. ;-) Donovan -- D Brooke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with a safe mode snag
On Mon, Mar 14, 2011 at 21:12, Jack jacklistm...@gmail.com wrote: Hello All, Im writing a script that creates a temp file which it then encrypts and sends out in an email. This works 100% on servers that don't have safe mode, but this server with safe mode doesn't understand it's all the same user. Error: Mon Mar 14 21:10:11 2011] [error] [client 14.18.8.43] PHP Warning: fopen() [a href='function.fopen'function.fopen/a]: SAFE MODE Restriction in effect. The script whose uid is 50069 is not allowed to access /tmp/A1_mYM5q5 owned by uid 48 in Any suggestions? 1.) Write to a local directory (though, if it's UID 48, that's probably httpd, apache, or nobody anyway, so it still may not work). 2.) Write to a database. 3.) Don't write anything at all, and work entirely from memory. 4.) Move to a different web host (unless this is a script you're distributing, whereby that may not be a viable option). -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help translating PHP5 code to PHP4.
On 7 March 2011 17:29, Marc Guay marc.g...@gmail.com wrote: Hi Richard, It's not a SOAP service, and I've actually decided to have ask the client to upgrade their server software before continuing. But for the sake of study: Depending upon your requirement, you could use simplexml_load_string() to convert an XML string into a native PHP object rather than manually parsing the text of the XML string. I looked up simplexml_load_string() and the manual seems to say that it's only available in PHP5. Can you clarify? Marc Ah. I see that you are trying to port TO V4 ... (Yes, simplexml is PHP5+ only). PHP4 is end of life and though I have my ZCE which was gained based upon PHP4, I've not really used it for the last many years (looking back it is probably 5 years or so). Depending upon their hosting, I would recommend one of the following options. 1 - Upgrade to PHP 5.3.5 2 - Dual install PHP 5.3.5 3 - Create a new vhost with PHP 5.3.5 I'm guessing upgrading straight away is a no-no. Running PHP4 and PHP5 SxS is very simple (I used to run PHP4 ISAPI, PHP5 CGI and PHP6-dev CGI - on the same Sambar Server - on Windows too!). The ease I had in running multiple versions of PHP on Windows would suggest it should be pretty easy to do for non-windows. Richard. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help translating PHP5 code to PHP4.
The ease I had in running multiple versions of PHP on Windows would suggest it should be pretty easy to do for non-windows. Funny and true. Thanks for the tips Richard, I've suggested that they upgrade their hosting package. Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help translating PHP5 code to PHP4.
On 3/7/2011 8:16 AM, Marc Guay wrote: Hi folks, I've stumbled into a project involving a server running PHP4 without cURL. The script fetches data from an XML webservice and deals with it. Is http://ca2.php.net/xml_parser_create the place to start? Any tips (besides updating PHP)? Here's an example of the PHP5 code: $url = http://www.domain.com/webservice.php?var=foo;; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $val = curl_exec($ch); curl_close($ch); libxml_use_internal_errors(true); $xml = simplexml_load_string($val); $errors = libxml_get_errors(); if (!($errors)){ $myvariable = $xml-attributes()-value; } else{ // deal with errors } Here is an example that is in the PHP manual http://us.php.net/manual/en/function.xml-parser-create.php#38739 The only modification that you will probably have to make is to set the following in your php.ini file. allow_url_include = On and/or allow_url_fopen = On This would allow fopen to open the external URL and grab the data returned. Jim Lucas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help translating PHP5 code to PHP4.
Just take another web host. 2011/3/7 Marc Guay marc.g...@gmail.com Hi folks, I've stumbled into a project involving a server running PHP4 without cURL. The script fetches data from an XML webservice and deals with it. Is http://ca2.php.net/xml_parser_create the place to start? Any tips (besides updating PHP)? Here's an example of the PHP5 code: $url = http://www.domain.com/webservice.php?var=foo;; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $val = curl_exec($ch); curl_close($ch); libxml_use_internal_errors(true); $xml = simplexml_load_string($val); $errors = libxml_get_errors(); if (!($errors)){ $myvariable = $xml-attributes()-value; } else{ // deal with errors } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- sexyprout
Re: [PHP] Help translating PHP5 code to PHP4.
On 7 March 2011 16:16, Marc Guay marc.g...@gmail.com wrote: Hi folks, I've stumbled into a project involving a server running PHP4 without cURL. The script fetches data from an XML webservice and deals with it. Is http://ca2.php.net/xml_parser_create the place to start? Any tips (besides updating PHP)? Here's an example of the PHP5 code: $url = http://www.domain.com/webservice.php?var=foo;; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $val = curl_exec($ch); curl_close($ch); libxml_use_internal_errors(true); $xml = simplexml_load_string($val); $errors = libxml_get_errors(); if (!($errors)){ $myvariable = $xml-attributes()-value; } else{ // deal with errors } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Is it a SOAP service? If so, PHP supports SOAP natively using SOAPClient (and you can create your own SOAPServers too). Depending upon your requirement, you could use simplexml_load_string() to convert an XML string into a native PHP object rather than manually parsing the text of the XML string. Can you give any more details? Richard. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help translating PHP5 code to PHP4.
Hi Richard, It's not a SOAP service, and I've actually decided to have ask the client to upgrade their server software before continuing. But for the sake of study: Depending upon your requirement, you could use simplexml_load_string() to convert an XML string into a native PHP object rather than manually parsing the text of the XML string. I looked up simplexml_load_string() and the manual seems to say that it's only available in PHP5. Can you clarify? Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help! Made a boo-boo encrypting credit cards
My merchant provider levies monthly fines based on how many of their security restrictions you fail to follow. I follow as many as are reasonably practical, but I think it's virtually impossible to follow them all, such as absurdly expensive (and probably unnecessary) hardware. IMHO, some of the restrictions are based less on reality and more on their security consulting firm's ability to frighten them. Their consulting firm's disclosed commissions on the fines creates an inherent conflict of interest. Goofily, my provider's fine structure does not differentiate between transactions that are merely processed on my server with no storage, and transactions originating from a card number stored on my server. So I have to constantly weigh the monthly fines vs. the cost of the upgrades vs. the amount of money that my various services bring in. There is no perfect solution. Nevertheless, I'm very open to any suggestions people have for transactions requiring that I keep the card number (in this case, recurring monthly charges where the customers choose not to use PayPal etc. and where too many customers would flake or get frustrated if forced to re-enter their card info every month for an annoyingly small transaction). Sorry this is getting a little off-topic for PHP. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help! Made a boo-boo encrypting credit cards
That's a great suggestion. I will try this and report back. It's also been suggested to me that I should have base64_encoded the encryptions before storing them in MySQL, so I'll try this option at the same time. On Mar 1, 2011, at 2:04 PM, Ashley Sheridan wrote: Onto the problem of the data you already have. Do you have a test-case that causes the problem? Try running a bunch of fictitious numbers against your code and store the results in your DB. For a decent test, you'll want to test it against a lot of numbers, store each one in plain format in the DB (use the same character encoding as you already have to see if that's part of the issue) alongside the encrypted version, then retrieve the encrypted value and test it against the original. It may take only a few dozen numbers to show the problem, it may take a thousand, but just let it run until it finds a problem. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help! Made a boo-boo encrypting credit cards
From: Brian Dunning My merchant provider levies monthly fines based on how many of their security restrictions you fail to follow. I follow as many as are reasonably practical, but I think it's virtually impossible to follow them all, such as absurdly expensive (and probably unnecessary) hardware. IMHO, some of the restrictions are based less on reality and more on their security consulting firm's ability to frighten them. Their consulting firm's disclosed commissions on the fines creates an inherent conflict of interest. Goofily, my provider's fine structure does not differentiate between transactions that are merely processed on my server with no storage, and transactions originating from a card number stored on my server. So I have to constantly weigh the monthly fines vs. the cost of the upgrades vs. the amount of money that my various services bring in. There is no perfect solution. Nevertheless, I'm very open to any suggestions people have for transactions requiring that I keep the card number (in this case, recurring monthly charges where the customers choose not to use PayPal etc. and where too many customers would flake or get frustrated if forced to re-enter their card info every month for an annoyingly small transaction). Sorry this is getting a little off-topic for PHP. Seems to me we have had similar discussions in the past, and not necessarily on Friday. First of all, you probably want to talk to your lawyer about the potential conflict of interest. That may need to be forwarded to a regulatory office or Attorney General for investigation. Second, do their rules conform to the OWASP recommendations and standard PCI guidelines? If they are deviating from those, or adding ridiculous requirements simply to squeeze a few extra pesos out of you, you might also want to ask your lawyer about them. Next, do they have a storage vault for credit card numbers that you can access. There shouldn't be any need for you to store them. We put numbers in our processor's vault and they give us a hash index to access them in the future. We use that for recurring charges and as a convenience so customers don't have to enter them every time they make a payment. And finally, even if they do follow the PCI regulations, you have to remember that the primary purpose of those regulations is to deflect liability from them to you when there is a problem. All they need to do is document one instance where you don't follow the rules and they are off the hook for damages. Guess where that puts you. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help needed with mysql import
You shouldn't have a default value in an auto increment field. You can set AUTO_INCREMENT to 0 and start with 1, but as auto increment is a unique field and its automagically incremented, you should not set a default value on it... -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. Thijs Lensselink d...@lenss.nl wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 03/02/2011 07:56 AM, Ashim Kapoor wrote: Dear all, I am trying to make a website with php and I found the following code in a book and I am trying to import it. The following are the beginning of the file i am trying to import with the command mysql -u root -pmypassword certainty dump I get the following error : ERROR 1067 (42000) at line 9: Invalid default value for 'id' but when I see line 9 i see the value '0' for id which seems ok to me, I also tried removing the quotes but same error. Can someone guide me ? Thank you, Ashim # MySQL dump 7.1 # # Host: [host deleted] Database: certainty #_ # Server version 3.22.32 # # Table structure for table 'high_scores' # CREATE TABLE high_scores ( id int(11) DEFAULT '0' NOT NULL auto_increment, name varchar(30), answer_count int(11), credit double(16,4), PRIMARY KEY (id) ); It's not really a PHP question. But here goes. Your first field id is an auto_increment field this means the counter goes up by every insert. Normally this will start at 1 not 0. So either change the 0 to a higher number or remove the auto_increment part before you import change the 0 after and alter the table to put back auto_increment -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJNbfOvAAoJEMffsHAOnubXC7UP/1k5qA4TDxDnUKrYZLV/rl9s bLRPTQ21riFMIzt0ne14No4+MTwjNtfVAdSnjpCWEZP+Y2MEixaiz8gIcOt9GIOD f9QPJZFEIcVADs3lqeS88eqdgRBNiYy3x2PHyslR3jtuaeFrRvxOLBTgBISq6Ih4 Dd5nRCbo6WObQ5e26HhbDeMJDAnOw4iQMjpoxc6UD9syxkJrORYw6XFvEmJA/QNF RDTNIO7P62ROamGor8urmPdfIemFLyqjD5YAQ64O6aWVHp0ehjO4l1xPWCeI84sV 2g8C3yqi06UjYOE8NHrf64VYcQtvLFkJbzGT6mmPwEP0gBdqX6o2YDwnudv7+APN F5zoVBv/7wygFaP+P0zgJ+EWVML35VfJFuq5VCH3CUk1hROS4X/JtsNXdVkAbaFA BpEhQ4jN0x/34HrI1cWjEUwaUuU6m9XoMIuO+1tQRLFatEW9I5z1c3hrJsPUNImX qSxEGLAZyA7tex++4YFn8DZXWz4mdllI7yejRe0nl1vl4Nn1+t2se/vF0TfZAGdB HgDeUWTdY/N2KeT4z9gPjGEDlRp8Wqo13Sv1yVhzWDdAJQdWaH8+Kk0GCI0jBrgT Pthmjr0e4bKCW19SJtL7/mTRU12qX/kbjMG5JqIh1ixn72qgqcvkTjgvEeQ1Y0DM xBBFUUedwoKevRJI05/2 =mdri -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help needed with mysql import
On 3/2/2011 4:25 AM, Alex wrote: You shouldn't have a default value in an auto increment field. You can set AUTO_INCREMENT to 0 and start with 1, but as auto increment is a unique field and its automagically incremented, you should not set a default value on it... This is fine and dandy until you want to do a restore of your data. With a restore, you will probably want to retain your auto-increment IDs since they are probably used else where in your DB. Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help needed with mysql import
On 3/2/2011 9:48 AM, Ashley Sheridan wrote: Jim Lucas li...@cmsws.com wrote: On 3/2/2011 4:25 AM, Alex wrote: You shouldn't have a default value in an auto increment field. You can set AUTO_INCREMENT to 0 and start with 1, but as auto increment is a unique field and its automagically incremented, you should not set a default value on it... This is fine and dandy until you want to do a restore of your data. With a restore, you will probably want to retain your auto-increment IDs since they are probably used else where in your DB. Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Restoring data wouldn't need default values though, would it. You can just perform a regular insert statement and update the next id value to be used if necessary. Also, I'm not 100% sure on this one, but I thought that some versions of Mysql had problems with a 0 in an auto_inc field? Thanks Ash Ash, Sorry, I didn't mean to imply that the AUTO_INCREMENT set to 0 is fine. Doing an export of the table structure for one of my smaller tables (that is empty), I see that the AUTO_INCREMENT value is set to 1 by default. CREATE TABLE IF NOT EXISTS `ajax_products` ( `id` int(11) NOT NULL auto_increment, `name` varchar(64) NOT NULL default '', `version` tinytext NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; It doesn't show a default value, but rather a default starting point for the AUTO_INCREMENT OP: Show us an export of your db table structure. Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help! Made a boo-boo encrypting credit cards
I just wanted to ping this, as it's becoming a serious problem. I hope someone can help. On Feb 11, 2011, at 2:42 PM, Brian Dunning wrote: Hey all - I'm using mcrypt to store credit cards into MySQL. About 90% of them decrypt fine, but about 10% decrypt as nonsense (b1�\�JEÚU�A��� is a good example). Maybe there is a character that appears in about 10% of my encryptions that's not being encoded properly??? // Encryption is set up at the top of the script: $crypto = mcrypt_module_open('rijndael-256', '', 'ofb', ''); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($crypto), MCRYPT_DEV_RANDOM); $ks = mcrypt_enc_get_key_size($crypto); $key = substr(md5('my_funky_term'), 0, $ks); // When the card number is collected by the form, it's encrypted: $cc_number = addslashes($_POST['cc_number']); mcrypt_generic_init($crypto, $key, $iv); $cc_encrypt = mcrypt_generic($crypto, $cc_number); mcrypt_generic_deinit($crypto); // This is written to the database: $query = update accounts set cc_encrypt='$cc_encrypt', encrypt_iv='$iv', other_fields='$other_stuff' where id='$account_id' limit 1; $result = mysql_query($query) or die(mysql_error()); Both the cc_encrypt and encrypt_iv fields are tinytext, latin1_swedish_ci, MyISAM, MySQL 5.0.91 In another script, when I retrieve, I first set it up at the top of the script exactly like step #1 above, then retrieve it like this: mcrypt_generic_init($crypto, $key, $row['encrypt_iv']); $cc_number = trim(mdecrypt_generic($crypto, $row['cc_encrypt'])); mcrypt_generic_deinit($crypto); Most of them are good, a few of them are bad. Can anyone see anything I'm doing wrong or a case I'm not covering? Thanks much. -- 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] Help! Made a boo-boo encrypting credit cards
On Tue, Mar 1, 2011 at 12:34 PM, Brian Dunning br...@briandunning.com wrote: I just wanted to ping this, as it's becoming a serious problem. I hope someone can help. On Feb 11, 2011, at 2:42 PM, Brian Dunning wrote: Hey all - I'm using mcrypt to store credit cards into MySQL. About 90% of them decrypt fine, but about 10% decrypt as nonsense (b1�\�JEÚU�A��� is a good example). Maybe there is a character that appears in about 10% of my encryptions that's not being encoded properly??? // Encryption is set up at the top of the script: $crypto = mcrypt_module_open('rijndael-256', '', 'ofb', ''); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($crypto), MCRYPT_DEV_RANDOM); $ks = mcrypt_enc_get_key_size($crypto); $key = substr(md5('my_funky_term'), 0, $ks); // When the card number is collected by the form, it's encrypted: $cc_number = addslashes($_POST['cc_number']); mcrypt_generic_init($crypto, $key, $iv); $cc_encrypt = mcrypt_generic($crypto, $cc_number); mcrypt_generic_deinit($crypto); // This is written to the database: $query = update accounts set cc_encrypt='$cc_encrypt', encrypt_iv='$iv', other_fields='$other_stuff' where id='$account_id' limit 1; $result = mysql_query($query) or die(mysql_error()); Both the cc_encrypt and encrypt_iv fields are tinytext, latin1_swedish_ci, MyISAM, MySQL 5.0.91 In another script, when I retrieve, I first set it up at the top of the script exactly like step #1 above, then retrieve it like this: mcrypt_generic_init($crypto, $key, $row['encrypt_iv']); $cc_number = trim(mdecrypt_generic($crypto, $row['cc_encrypt'])); mcrypt_generic_deinit($crypto); Most of them are good, a few of them are bad. Can anyone see anything I'm doing wrong or a case I'm not covering? Thanks much. -- 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 Could it be that the addslashes is creating a \0 (null) value? That might screw up the decryption routine. -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help! Made a boo-boo encrypting credit cards
On Fri, Feb 11, 2011 at 4:42 PM, Brian Dunning br...@briandunning.com wrote: Hey all - I'm using mcrypt to store credit cards into MySQL. About 90% of them decrypt fine, but about 10% decrypt as nonsense (b1�\�JEÚU�A��� is a good example). Maybe there is a character that appears in about 10% of my encryptions that's not being encoded properly??? // Encryption is set up at the top of the script: $crypto = mcrypt_module_open('rijndael-256', '', 'ofb', ''); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($crypto), MCRYPT_DEV_RANDOM); $ks = mcrypt_enc_get_key_size($crypto); $key = substr(md5('my_funky_term'), 0, $ks); // When the card number is collected by the form, it's encrypted: $cc_number = addslashes($_POST['cc_number']); mcrypt_generic_init($crypto, $key, $iv); $cc_encrypt = mcrypt_generic($crypto, $cc_number); mcrypt_generic_deinit($crypto); // This is written to the database: $query = update accounts set cc_encrypt='$cc_encrypt', encrypt_iv='$iv', other_fields='$other_stuff' where id='$account_id' limit 1; $result = mysql_query($query) or die(mysql_error()); Both the cc_encrypt and encrypt_iv fields are tinytext, latin1_swedish_ci, MyISAM, MySQL 5.0.91 In another script, when I retrieve, I first set it up at the top of the script exactly like step #1 above, then retrieve it like this: mcrypt_generic_init($crypto, $key, $row['encrypt_iv']); $cc_number = trim(mdecrypt_generic($crypto, $row['cc_encrypt'])); mcrypt_generic_deinit($crypto); Most of them are good, a few of them are bad. Can anyone see anything I'm doing wrong or a case I'm not covering? Thanks much. Just a WAG, but when I first was working with mcrypt, it would append spaces to the encrypted value. I would have to TRIM() everything for processing or decryption. BTW, we also elected *not* to store card numbers, only the last 4 digits. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help needed with mysql import
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 03/02/2011 07:56 AM, Ashim Kapoor wrote: Dear all, I am trying to make a website with php and I found the following code in a book and I am trying to import it. The following are the beginning of the file i am trying to import with the command mysql -u root -pmypassword certainty dump I get the following error : ERROR 1067 (42000) at line 9: Invalid default value for 'id' but when I see line 9 i see the value '0' for id which seems ok to me, I also tried removing the quotes but same error. Can someone guide me ? Thank you, Ashim # MySQL dump 7.1 # # Host: [host deleted] Database: certainty # # Server version 3.22.32 # # Table structure for table 'high_scores' # CREATE TABLE high_scores ( id int(11) DEFAULT '0' NOT NULL auto_increment, name varchar(30), answer_count int(11), credit double(16,4), PRIMARY KEY (id) ); It's not really a PHP question. But here goes. Your first field id is an auto_increment field this means the counter goes up by every insert. Normally this will start at 1 not 0. So either change the 0 to a higher number or remove the auto_increment part before you import change the 0 after and alter the table to put back auto_increment -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJNbfOvAAoJEMffsHAOnubXC7UP/1k5qA4TDxDnUKrYZLV/rl9s bLRPTQ21riFMIzt0ne14No4+MTwjNtfVAdSnjpCWEZP+Y2MEixaiz8gIcOt9GIOD f9QPJZFEIcVADs3lqeS88eqdgRBNiYy3x2PHyslR3jtuaeFrRvxOLBTgBISq6Ih4 Dd5nRCbo6WObQ5e26HhbDeMJDAnOw4iQMjpoxc6UD9syxkJrORYw6XFvEmJA/QNF RDTNIO7P62ROamGor8urmPdfIemFLyqjD5YAQ64O6aWVHp0ehjO4l1xPWCeI84sV 2g8C3yqi06UjYOE8NHrf64VYcQtvLFkJbzGT6mmPwEP0gBdqX6o2YDwnudv7+APN F5zoVBv/7wygFaP+P0zgJ+EWVML35VfJFuq5VCH3CUk1hROS4X/JtsNXdVkAbaFA BpEhQ4jN0x/34HrI1cWjEUwaUuU6m9XoMIuO+1tQRLFatEW9I5z1c3hrJsPUNImX qSxEGLAZyA7tex++4YFn8DZXWz4mdllI7yejRe0nl1vl4Nn1+t2se/vF0TfZAGdB HgDeUWTdY/N2KeT4z9gPjGEDlRp8Wqo13Sv1yVhzWDdAJQdWaH8+Kk0GCI0jBrgT Pthmjr0e4bKCW19SJtL7/mTRU12qX/kbjMG5JqIh1ixn72qgqcvkTjgvEeQ1Y0DM xBBFUUedwoKevRJI05/2 =mdri -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help! Made a boo-boo encrypting credit cards
On Feb 13, 2011, at 12:44 AM, Richard Quadling wrote: You are using addslashes($_POST['cc_number']). Considering a credit card number is purely numeric, the addslashes would seem to be redundant as you don't need to escape numbers. I do that routinely to all input fields as one additional layer of protection against injection attacks. And you can run a Luhn10 check against the card number to make sure it is valid before storing it. I do that as well. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help! Made a boo-boo encrypting credit cards
On 11 February 2011 22:42, Brian Dunning br...@briandunning.com wrote: Hey all - I'm using mcrypt to store credit cards into MySQL. About 90% of them decrypt fine, but about 10% decrypt as nonsense (b1�\�JEÚU�A��� is a good example). Maybe there is a character that appears in about 10% of my encryptions that's not being encoded properly??? Unrelated to the code, but considering the frequency of credit card theft from big sites, is it really safe to store CC details, even if they are encrypted? Considering the site's code CAN decrypt it, it wouldn't be that difficult to use your code to get the card details. Sure, having the details is a benefit to the client in terms of saving them the hassle of entering the card details for each purchase/usage, but how secure is it overall? Related to the code, do you validate the card details first? You are using addslashes($_POST['cc_number']). Considering a credit card number is purely numeric, the addslashes would seem to be redundant as you don't need to escape numbers. And you can run a Luhn10 check against the card number to make sure it is valid before storing it. Richard. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help: Validate Domain Name by Regular Express
On Sun, 2011-01-09 at 11:44 +0800, WalkinRaven wrote: Right, RFC 1034 allow valid endless . parts, till the sum length is over 255. On 01/09/2011 01:21 AM, TR Shaw wrote: On Jan 8, 2011, at 12:09 PM, Ashley Sheridan wrote: On Sat, 2011-01-08 at 16:55 +0800, WalkinRaven wrote: PHP 5.3 PCRE Regular Express to match domain names format according to RFC 1034 - DOMAIN NAMES - CONCEPTS AND FACILITIES /^ ( [a-z] | [a-z] (?:[a-z]|[0-9]) | [a-z] (?:[a-z]|[0-9]|\-){1,61} (?:[a-z]|[0-9]) ) # One label (?:\.(?1))*+# More labels \.? # Root domain name $/iDx This rule matches onlylabel andlabel. but notlabel.label... I don't know what wrong with it. Thank you. I think trying to do all of this in one regex will prove more trouble than it's worth. Maybe breaking it down into something like this: ?php $domain = www.ashleysheridan.co.uk; $valid = false; $tlds = array('aero', 'asia', 'biz', 'cat', 'com', 'coop', 'edu', 'gov', 'info', 'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'pro', 'tel', 'travel', 'xxx', 'ac', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg', 'er', 'es', 'et', 'eu', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mk', 'ml', 'mm', 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'za', 'zm', 'zw', ); if(strlen($domain= 253)) { $labels = explode('.', $domain); if(in_array($labels[count($labels)-1], $tlds)) { for($i=0; $icount($labels) -1; $i++) { if(strlen($labels[$i])= 63 (!preg_match('/^[a-z0-9][a-z0-9 \-]*?[a-z0-9]$/', $labels[$i]) || preg_match('/^[0-9]+$/', $labels[$i]) )) { $valid = false; break; // no point continuing if one label is wrong } else { $valid = true; } } } } var_dump($valid); This matches the last label with a TLD, and each label thereafter against the standard a-z0-9 and hyphen rule as indicated in the preferred characters allowed in a label (LDH rule), with the start and end character in a label isn't a hyphen (oddly enough it doesn't mention starting with a digit!) Also, each label is checked to ensure it doesn't run over 63 characters, and the whole thing isn't over 253 characters. Lastly, each label is checked to ensure it doesn't completely consist of digits. I've tested it only with my domain so far, but it should work fairly well. As I said before, I couldn't think of a way to do it all with one regex. It could probably be done, but would you really want to create a huge and difficult to read/understand expression just because it's possible? Ash I doubt its possible since the ccTLD's have valid 3 and more dotted domain names. You should see .us And .uk doesn't follow the ccTLS rules for .tk for example. Now, if the purpose is to write a regex for a host name then that's a different story. Tom Which is what my code does too, while also checking for label length. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Help: Validate Domain Name by Regular Express
On Sat, 2011-01-08 at 16:55 +0800, WalkinRaven wrote: PHP 5.3 PCRE Regular Express to match domain names format according to RFC 1034 - DOMAIN NAMES - CONCEPTS AND FACILITIES /^ ( [a-z] | [a-z] (?:[a-z]|[0-9]) | [a-z] (?:[a-z]|[0-9]|\-){1,61} (?:[a-z]|[0-9]) ) # One label (?:\.(?1))*+# More labels \.? # Root domain name $/iDx This rule matches only label and label. but not label.label... I don't know what wrong with it. Thank you. I think trying to do all of this in one regex will prove more trouble than it's worth. Maybe breaking it down into something like this: ?php $domain = www.ashleysheridan.co.uk; $valid = false; $tlds = array('aero', 'asia', 'biz', 'cat', 'com', 'coop', 'edu', 'gov', 'info', 'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'pro', 'tel', 'travel', 'xxx', 'ac', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg', 'er', 'es', 'et', 'eu', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mk', 'ml', 'mm', 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'za', 'zm', 'zw', ); if(strlen($domain = 253)) { $labels = explode('.', $domain); if(in_array($labels[count($labels)-1], $tlds)) { for($i=0; $icount($labels) -1; $i++) { if(strlen($labels[$i]) = 63 (!preg_match('/^[a-z0-9][a-z0-9 \-]*?[a-z0-9]$/', $labels[$i]) || preg_match('/^[0-9]+$/', $labels[$i]) )) { $valid = false; break; // no point continuing if one label is wrong } else { $valid = true; } } } } var_dump($valid); This matches the last label with a TLD, and each label thereafter against the standard a-z0-9 and hyphen rule as indicated in the preferred characters allowed in a label (LDH rule), with the start and end character in a label isn't a hyphen (oddly enough it doesn't mention starting with a digit!) Also, each label is checked to ensure it doesn't run over 63 characters, and the whole thing isn't over 253 characters. Lastly, each label is checked to ensure it doesn't completely consist of digits. I've tested it only with my domain so far, but it should work fairly well. As I said before, I couldn't think of a way to do it all with one regex. It could probably be done, but would you really want to create a huge and difficult to read/understand expression just because it's possible? Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Help: Validate Domain Name by Regular Express
On Jan 8, 2011, at 12:09 PM, Ashley Sheridan wrote: On Sat, 2011-01-08 at 16:55 +0800, WalkinRaven wrote: PHP 5.3 PCRE Regular Express to match domain names format according to RFC 1034 - DOMAIN NAMES - CONCEPTS AND FACILITIES /^ ( [a-z] | [a-z] (?:[a-z]|[0-9]) | [a-z] (?:[a-z]|[0-9]|\-){1,61} (?:[a-z]|[0-9]) ) # One label (?:\.(?1))*+# More labels \.? # Root domain name $/iDx This rule matches only label and label. but not label.label... I don't know what wrong with it. Thank you. I think trying to do all of this in one regex will prove more trouble than it's worth. Maybe breaking it down into something like this: ?php $domain = www.ashleysheridan.co.uk; $valid = false; $tlds = array('aero', 'asia', 'biz', 'cat', 'com', 'coop', 'edu', 'gov', 'info', 'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'pro', 'tel', 'travel', 'xxx', 'ac', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg', 'er', 'es', 'et', 'eu', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mk', 'ml', 'mm', 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'za', 'zm', 'zw', ); if(strlen($domain = 253)) { $labels = explode('.', $domain); if(in_array($labels[count($labels)-1], $tlds)) { for($i=0; $icount($labels) -1; $i++) { if(strlen($labels[$i]) = 63 (!preg_match('/^[a-z0-9][a-z0-9 \-]*?[a-z0-9]$/', $labels[$i]) || preg_match('/^[0-9]+$/', $labels[$i]) )) { $valid = false; break; // no point continuing if one label is wrong } else { $valid = true; } } } } var_dump($valid); This matches the last label with a TLD, and each label thereafter against the standard a-z0-9 and hyphen rule as indicated in the preferred characters allowed in a label (LDH rule), with the start and end character in a label isn't a hyphen (oddly enough it doesn't mention starting with a digit!) Also, each label is checked to ensure it doesn't run over 63 characters, and the whole thing isn't over 253 characters. Lastly, each label is checked to ensure it doesn't completely consist of digits. I've tested it only with my domain so far, but it should work fairly well. As I said before, I couldn't think of a way to do it all with one regex. It could probably be done, but would you really want to create a huge and difficult to read/understand expression just because it's possible? Ash I doubt its possible since the ccTLD's have valid 3 and more dotted domain names. You should see .us And .uk doesn't follow the ccTLS rules for .tk for example. Now, if the purpose is to write a regex for a host name then that's a different story. Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help: Validate Domain Name by Regular Express
On 01/09/2011 01:09 AM, Ashley Sheridan wrote: On Sat, 2011-01-08 at 16:55 +0800, WalkinRaven wrote: PHP 5.3 PCRE Regular Express to match domain names format according to RFC 1034 - DOMAIN NAMES - CONCEPTS AND FACILITIES /^ ( [a-z] | [a-z] (?:[a-z]|[0-9]) | [a-z] (?:[a-z]|[0-9]|\-){1,61} (?:[a-z]|[0-9]) ) # One label (?:\.(?1))*+# More labels \.? # Root domain name $/iDx This rule matches onlylabel andlabel. but notlabel.label... I don't know what wrong with it. Thank you. I think trying to do all of this in one regex will prove more trouble than it's worth. Maybe breaking it down into something like this: ?php $domain = www.ashleysheridan.co.uk; $valid = false; $tlds = array('aero', 'asia', 'biz', 'cat', 'com', 'coop', 'edu', 'gov', 'info', 'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'pro', 'tel', 'travel', 'xxx', 'ac', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg', 'er', 'es', 'et', 'eu', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mk', 'ml', 'mm', 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'za', 'zm', 'zw', ); if(strlen($domain= 253)) { $labels = explode('.', $domain); if(in_array($labels[count($labels)-1], $tlds)) { for($i=0; $icount($labels) -1; $i++) { if(strlen($labels[$i])= 63 (!preg_match('/^[a-z0-9][a-z0-9 \-]*?[a-z0-9]$/', $labels[$i]) || preg_match('/^[0-9]+$/', $labels[$i]) )) { $valid = false; break; // no point continuing if one label is wrong } else { $valid = true; } } } } var_dump($valid); This matches the last label with a TLD, and each label thereafter against the standard a-z0-9 and hyphen rule as indicated in the preferred characters allowed in a label (LDH rule), with the start and end character in a label isn't a hyphen (oddly enough it doesn't mention starting with a digit!) Also, each label is checked to ensure it doesn't run over 63 characters, and the whole thing isn't over 253 characters. Lastly, each label is checked to ensure it doesn't completely consist of digits. I've tested it only with my domain so far, but it should work fairly well. As I said before, I couldn't think of a way to do it all with one regex. It could probably be done, but would you really want to create a huge and difficult to read/understand expression just because it's possible? Thanks, Ash http://www.ashleysheridan.co.uk Thank you for replying, Ash. I know it may better to pre-deal it with explode()-like, and then we will get a less complex regular express. But I just want to know what the problem in my Regular express. And the code you've offered, I don't like the idea of a limited set of suffix, for when it may be updated some times. I just want to do format validation, not content validation. And the regular express itself, yes it is complex, but I've checked it times very carefully -- letter by letter -- I just don't understand what's wrong with it. Or there is some bug in PCRE engine? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with variable variables not being set for a multi-dimensional array
On Tue, Nov 9, 2010 at 6:55 PM, Daevid Vincent dae...@daevid.com wrote: I've used variable variables before but for some reason I can't figure this snippet out. Why doesn't $ini_file get set (or appended to). AFAIK variable variables can only reference actual variables--not array subscripts or other non-variable syntax elements such as - or ::. eval() can do this because it parses the code as PHP. Variable variables take the *variable name* contained in the variable and look it up in the current scope. This is a variable name: ini_array This is not: ini_array['agis_core']['adapter'] I think you can use references here to do what you need. Warning: I only tested the basics of this in the interpreter without running this exact code. public function explode_ini() { $ini_array = array(); foreach($this-ini_array as $heading = $key_vals) { foreach ($key_vals as $k = $v) { $path = $ini_array[$heading]; $subsection = explode('.', $k); foreach ($subsection as $ss) $path = $path[$ss]; $path = $v; unset($path); } } $this-ini_array = $ini_array; } David
Re: [PHP] Help with sending credentials?
On 14 October 2010 21:45, Brian Dunning br...@briandunning.com wrote: Gents - I'm trying to work with a major vendor's web service, but all my efforts are met with a 401 authentication error response. I can log in manually to this URL using these credentials through a browser, so I know the credentials are good. Unfortunately the support guys at the vendor don't see any problem with my code and have not been able to help. $url = https://servername.com/script;; $ctx = stream_context_create(array('https' = array( 'timeout' = 10, 'header' = sprintf(Authorization: Basic %s\r\n, base64_encode(myUsername:myPassword)) ))); $result = file_get_contents($url, 0, $ctx); $http_response = explode(' ', $http_response_header[0]); $response_code = $http_response[1]; === This is evaluating to '401' Thanks. Are they using Basic authentication? Does ... https://myUsername:mypassw...@http://servername.com/script work? Is this a SOAP based web service? Are they expecting the SOAPHeader to contain the authentication? -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help with sending credentials?
-Original Message- From: Richard Quadling [mailto:rquadl...@gmail.com] Sent: Friday, October 15, 2010 1:47 AM To: Brian Dunning Cc: PHP-General List Subject: Re: [PHP] Help with sending credentials? On 14 October 2010 21:45, Brian Dunning br...@briandunning.com wrote: Gents - I'm trying to work with a major vendor's web service, but all my efforts are met with a 401 authentication error response. I can log in manually to this URL using these credentials through a browser, so I know the credentials are good. Unfortunately the support guys at the vendor don't see any problem with my code and have not been able to help. $url = https://servername.com/script;; $ctx = stream_context_create(array('https' = array( 'timeout' = 10, 'header' = sprintf(Authorization: Basic %s\r\n, base64_encode(myUsername:myPassword)) ))); $result = file_get_contents($url, 0, $ctx); $http_response = explode(' ', $http_response_header[0]); $response_code = $http_response[1]; === This is evaluating to '401' Thanks. Are they using Basic authentication? Does ... https://myUsername:mypassw...@http://servername.com/script Shouldn't that be https://myUsername:mypassw...@servername.com/script ? work? Is this a SOAP based web service? Are they expecting the SOAPHeader to contain the authentication? -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY Regards, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with sending credentials?
On 15 October 2010 10:51, Tommy Pham tommy...@gmail.com wrote: -Original Message- From: Richard Quadling [mailto:rquadl...@gmail.com] Sent: Friday, October 15, 2010 1:47 AM To: Brian Dunning Cc: PHP-General List Subject: Re: [PHP] Help with sending credentials? On 14 October 2010 21:45, Brian Dunning br...@briandunning.com wrote: Gents - I'm trying to work with a major vendor's web service, but all my efforts are met with a 401 authentication error response. I can log in manually to this URL using these credentials through a browser, so I know the credentials are good. Unfortunately the support guys at the vendor don't see any problem with my code and have not been able to help. $url = https://servername.com/script;; $ctx = stream_context_create(array('https' = array( 'timeout' = 10, 'header' = sprintf(Authorization: Basic %s\r\n, base64_encode(myUsername:myPassword)) ))); $result = file_get_contents($url, 0, $ctx); $http_response = explode(' ', $http_response_header[0]); $response_code = $http_response[1]; === This is evaluating to '401' Thanks. Are they using Basic authentication? Does ... https://myUsername:mypassw...@http://servername.com/script Shouldn't that be https://myUsername:mypassw...@servername.com/script ? work? Is this a SOAP based web service? Are they expecting the SOAPHeader to contain the authentication? -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY Regards, Tommy Yeah. CNP error. Thanks. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with sending credentials?
On Thu, Oct 14, 2010 at 4:45 PM, Brian Dunning br...@briandunning.comwrote: Gents - I'm trying to work with a major vendor's web service, but all my efforts are met with a 401 authentication error response. I can log in manually to this URL using these credentials through a browser, so I know the credentials are good. Unfortunately the support guys at the vendor don't see any problem with my code and have not been able to help. $url = https://servername.com/script;; $ctx = stream_context_create(array('https' = array( 'timeout' = 10, 'header' = sprintf(Authorization: Basic %s\r\n, base64_encode(myUsername:myPassword)) ))); $result = file_get_contents($url, 0, $ctx); $http_response = explode(' ', $http_response_header[0]); $response_code = $http_response[1]; === This is evaluating to '401' Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Could the method (POST vs GET) or the content type be causing the issue (hard to guess beyond this without knowing the service?) See this simple twitter function for examples of what I'm wondering about: http://fabien.potencier.org/article/20/tweeting-from-php Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
RE: [PHP] Help with template file and email
Hello Joey, No problem, I'm glad you got it working now. Any other question. Use php-list. Regards, Carlos Sura. From: j.hendrick...@comcast.net To: carlos_s...@hotmail.com Subject: Re: [PHP] Help with template file and email Date: Sat, 24 Jul 2010 08:29:03 -0500 Hi Carlos, I wanted to thank you for all your help!! In the function I had to use a foreach() to get the email. Then put the $_GET['email'] in when I called the function. Finally got it! Thank you for your help!! Joey. - Original Message - From: Carlos Sura To: j.hendrick...@comcast.net Cc: php-general@lists.php.net Sent: Tuesday, July 13, 2010 10:48 AM Subject: RE: [PHP] Help with template file and email Let me get this right... $mymail // If you put an email adress it works, right. You are calling variable $mymail... But, what does contain that var? You are calling $mymail, there has to be a database, or something of those 10 mails you said. -If i'm getting you the point right- If not, my mistake. Or you might use something like this: ?php // mail list $to = 'yourma...@example.com' . ', '; $to .= 'yourma...@example.com'; If my answer is wrong for you. Plrease reffer to: http://docs.php.net/manual/en/function.mail.php -as Richard said.- From: rquadl...@gmail.com Date: Tue, 13 Jul 2010 15:02:14 +0100 To: j.hendrick...@comcast.net CC: php-general@lists.php.net Subject: Re: [PHP] Help with template file and email On 13 July 2010 14:56, Joey Hendricks j.hendrick...@comcast.net wrote: Hello, I have been working on a birtday invite program. The form takes 10 names and 10 email addresses. I think the problem is the $to variable in my function. I get this warning-Warning: mail() [function.mail]: SMTP server response: 550 5.5.0 f domain name required in. Could someone help me with this my email is j.hendrick...@comcast.net Thank you so very much! ?php mail(' j.hendrick...@comcast.net', 'Test email', 'This is a test email'); ? and I get the following entry in my PHP's mail.log ... mail() on [-:2]: To: j.hendrick...@comcast.net -- Headers: Pretty simple stuff. http://docs.php.net/manual/en/function.mail.php Regards, Richard. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Get a new e-mail account with Hotmail - Free. Sign-up now. _ http://clk.atdmt.com/UKM/go/19780/direct/01/ Do you have a story that started on Hotmail? Tell us now
Re: [PHP] help using phpadmin
thanks carlos, but where would i enter that command? and i tried editing the php.ini file but that didn't accomplish anything. isaac On Mon, Jul 19, 2010 at 1:29 AM, Carlos Sura carlos_s...@hotmail.com wrote: Hello Isaac Lee. Are you running on Linux or Windows? You might try: mysql SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(’yourpassword’); Then restart your service -if needed- If not... Try to edit config.inc.php file. Regards, Carlos Sura -Original Message- From: Isaac Lee [mailto:rhinecant...@gmail.com] Sent: domingo, 18 de julio de 2010 10:34 p.m. Cc: php-general@lists.php.net Subject: [PHP] help using phpadmin this is the second time that i have made an account and set the password. then when i try to reaccess phpadmin, it shows this message: Error MySQL said: #1045 - Access denied for user 'root'@'localhost' (using password: NO) What am supposed to do so that my regain access to phpadmin? edit the php.ini file? isaac -- 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] help using phpadmin
im using windows. On Mon, Jul 19, 2010 at 12:23 PM, Isaac Lee rhinecant...@gmail.com wrote: thanks carlos, but where would i enter that command? and i tried editing the php.ini file but that didn't accomplish anything. isaac On Mon, Jul 19, 2010 at 1:29 AM, Carlos Sura carlos_s...@hotmail.com wrote: Hello Isaac Lee. Are you running on Linux or Windows? You might try: mysql SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(’yourpassword’); Then restart your service -if needed- If not... Try to edit config.inc.php file. Regards, Carlos Sura -Original Message- From: Isaac Lee [mailto:rhinecant...@gmail.com] Sent: domingo, 18 de julio de 2010 10:34 p.m. Cc: php-general@lists.php.net Subject: [PHP] help using phpadmin this is the second time that i have made an account and set the password. then when i try to reaccess phpadmin, it shows this message: Error MySQL said: #1045 - Access denied for user 'root'@'localhost' (using password: NO) What am supposed to do so that my regain access to phpadmin? edit the php.ini file? isaac -- 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] help using phpadmin
Hello Isaac Lee, I don't remember well, but I think this is the way to do it in Windows. You can try this: Start -- Run cmd // Write it and press enter key. It will show you a MS-DOS window, Write there: mysql now: mysql cd c:\location\mysql\bin Then you might try: mysqladmin -u root password new_password Now type: mysql -u root -p Write your new password now :) If none of this work... Please show me your ini* file. If you can't show me your ini* file please reffer to: http://search.mysql.com/search?q=Resetting_permissions.htmllr=lang_en Regards, Carlos Sura. Date: Mon, 19 Jul 2010 12:24:26 -0400 From: rhinecant...@gmail.com To: carlos_s...@hotmail.com CC: php-general@lists.php.net Subject: Re: [PHP] help using phpadmin im using windows. On Mon, Jul 19, 2010 at 12:23 PM, Isaac Lee rhinecant...@gmail.com wrote: thanks carlos, but where would i enter that command? and i tried editing the php.ini file but that didn't accomplish anything. isaac On Mon, Jul 19, 2010 at 1:29 AM, Carlos Sura carlos_s...@hotmail.com wrote: Hello Isaac Lee. Are you running on Linux or Windows? You might try: mysql SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(’yourpassword’); Then restart your service -if needed- If not... Try to edit config.inc.php file. Regards, Carlos Sura -Original Message- From: Isaac Lee [mailto:rhinecant...@gmail.com] Sent: domingo, 18 de julio de 2010 10:34 p.m. Cc: php-general@lists.php.net Subject: [PHP] help using phpadmin this is the second time that i have made an account and set the password. then when i try to reaccess phpadmin, it shows this message: Error MySQL said: #1045 - Access denied for user 'root'@'localhost' (using password: NO) What am supposed to do so that my regain access to phpadmin? edit the php.ini file? isaac -- 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 _ We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now http://clk.atdmt.com/UKM/go/195013117/direct/01/
RE: [PHP] help using phpadmin
Hello Isaac Lee. Are you running on Linux or Windows? You might try: mysql SET PASSWORD FOR root@'localhost = PASSWORD(yourpassword); Then restart your service -if needed- If not... Try to edit config.inc.php file. Regards, Carlos Sura -Original Message- From: Isaac Lee [mailto:rhinecant...@gmail.com] Sent: domingo, 18 de julio de 2010 10:34 p.m. Cc: php-general@lists.php.net Subject: [PHP] help using phpadmin this is the second time that i have made an account and set the password. then when i try to reaccess phpadmin, it shows this message: Error MySQL said: #1045 - Access denied for user 'root'@'localhost' (using password: NO) What am supposed to do so that my regain access to phpadmin? edit the php.ini file? isaac -- 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] help with sql statement
On 12 July 2010 18:34, Tommy Pham tommy...@gmail.com wrote: SELECT srs.Name FROM SMS_R_System srs WHERE srs.SystemOUName IN (example.com/COMPUTERS/MAIN CAMPUS/ABC, example.com/COMPUTERS/MAIN CAMPUS/XYZ) As this is a single table query, there is no need for the table alias. SELECT Name FROM SMS_R_System WHERE LEFT(SystemOUName, 34) = 'example.com/COMPUTERS/MAIN CAMPUS/' AND RIGHT(SystemOUName, 3) IN ('ABC', 'XYZ') But this will probably take a measurable amount of time longer to execute - 2 comparisons and 2 string processes. Maybe not for a single run, but after several hundred. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with template file and email
On 13 July 2010 14:56, Joey Hendricks j.hendrick...@comcast.net wrote: Hello, I have been working on a birtday invite program. The form takes 10 names and 10 email addresses. I think the problem is the $to variable in my function. I get this warning-Warning: mail() [function.mail]: SMTP server response: 550 5.5.0 f domain name required in. Could someone help me with this my email is j.hendrick...@comcast.net Thank you so very much! ?php mail(' j.hendrick...@comcast.net', 'Test email', 'This is a test email'); ? and I get the following entry in my PHP's mail.log ... mail() on [-:2]: To: j.hendrick...@comcast.net -- Headers: Pretty simple stuff. http://docs.php.net/manual/en/function.mail.php Regards, Richard. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help with template file and email
Let me get this right... $mymail // If you put an email adress it works, right. You are calling variable $mymail... But, what does contain that var? You are calling $mymail, there has to be a database, or something of those 10 mails you said. -If i'm getting you the point right- If not, my mistake. Or you might use something like this: ?php // mail list $to = 'yourma...@example.com' . ', '; $to .= 'yourma...@example.com'; If my answer is wrong for you. Plrease reffer to: http://docs.php.net/manual/en/function.mail.php -as Richard said.- From: rquadl...@gmail.com Date: Tue, 13 Jul 2010 15:02:14 +0100 To: j.hendrick...@comcast.net CC: php-general@lists.php.net Subject: Re: [PHP] Help with template file and email On 13 July 2010 14:56, Joey Hendricks j.hendrick...@comcast.net wrote: Hello, I have been working on a birtday invite program. The form takes 10 names and 10 email addresses. I think the problem is the $to variable in my function. I get this warning-Warning: mail() [function.mail]: SMTP server response: 550 5.5.0 f domain name required in. Could someone help me with this my email is j.hendrick...@comcast.net Thank you so very much! ?php mail(' j.hendrick...@comcast.net', 'Test email', 'This is a test email'); ? and I get the following entry in my PHP's mail.log ... mail() on [-:2]: To: j.hendrick...@comcast.net -- Headers: Pretty simple stuff. http://docs.php.net/manual/en/function.mail.php Regards, Richard. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ http://clk.atdmt.com/UKM/go/19780/direct/01/ Do you have a story that started on Hotmail? Tell us now
Re: [PHP] help with sql statement
On Mon, 2010-07-12 at 10:24 -0500, Adam wrote: I was google searching, and the only SQL mailing list I found is currently giving a 503 error, so I hope you don't mind me asking my SQL question here, since there are a lot of SQL gurus here. I am having a syntax problem: Instead of doing a query like this:: select SMS_R_SYSTEM.Name from SMS_R_System where (SMS_R_System.SystemOUName = example.com/COMPUTERS/MAIN CAMPUS/ABC) or (SMS_R_System.SystemOUName = example.com/COMPUTERS/MAIN CAMPUS/XYZ) I'd like to shorten it in the where clause to: select SMS_R_SYSTEM.Name from SMS_R_System where (SMS_R_System.SystemOUName = example.com/COMPUTERS/MAIN CAMPUS/ABC, example.com/COMPUTERS/MAIN CAMPUS/XYZ) But I'm getting a syntax error. Any idea why my SQL syntax isn't valid? The short answer is your syntax isn't valid, which means that what you've written isn't valid SQL :p What I think you're looking for instead is something like this: SELECT SMS_R_SYSTEM.Name FROM SMS_R_System WHERE SMS_R_System.SystemOUName IN (example.com/COMPUTERS/MAIN CAMPUS/ABC, example.com/COMPUTERS/MAIN CAMPUS/XYZ) which lets MySQL compare the field against an array of different values within the brackets. Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] help with sql statement
-Original Message- From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: Monday, July 12, 2010 8:26 AM To: Adam Cc: PHP General Subject: Re: [PHP] help with sql statement On Mon, 2010-07-12 at 10:24 -0500, Adam wrote: I was google searching, and the only SQL mailing list I found is currently giving a 503 error, so I hope you don't mind me asking my SQL question here, since there are a lot of SQL gurus here. I am having a syntax problem: Instead of doing a query like this:: select SMS_R_SYSTEM.Name from SMS_R_System where (SMS_R_System.SystemOUName = example.com/COMPUTERS/MAIN CAMPUS/ABC) or (SMS_R_System.SystemOUName = example.com/COMPUTERS/MAIN CAMPUS/XYZ) I'd like to shorten it in the where clause to: select SMS_R_SYSTEM.Name from SMS_R_System where (SMS_R_System.SystemOUName = example.com/COMPUTERS/MAIN CAMPUS/ABC, example.com/COMPUTERS/MAIN CAMPUS/XYZ) But I'm getting a syntax error. Any idea why my SQL syntax isn't valid? The short answer is your syntax isn't valid, which means that what you've written isn't valid SQL :p What I think you're looking for instead is something like this: SELECT SMS_R_SYSTEM.Name FROM SMS_R_System WHERE SMS_R_System.SystemOUName IN (example.com/COMPUTERS/MAIN CAMPUS/ABC, example.com/COMPUTERS/MAIN CAMPUS/XYZ) Even shorter ;) SELECT srs.Name FROM SMS_R_System srs WHERE srs.SystemOUName IN (example.com/COMPUTERS/MAIN CAMPUS/ABC, example.com/COMPUTERS/MAIN CAMPUS/XYZ) which lets MySQL compare the field against an array of different values within the brackets. Given his syntax, I'd guess that his RDBMS is MS SQL and he's trying to get some info from the DB that's populated by MS' SMS. Regards, Tommy Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help, FPDI is changing the size of my PDFs
Solved it. Here's the solution: $pdf = new fpdi(); $pdf-setSourceFile('D:\\DocShare\\'.$filename); $tplidx = $pdf-ImportPage(1); $s = $pdf-getTemplatesize($tplidx); $pdf-AddPage($s['h'] $s['w'] ? 'P' : 'L', array($s['w'], $s['h'])); // This gets it the right dimensions $pdf-useTemplate($tplidx, 0, 0, 0, 0, true); $pdf-Output('newpdf.pdf', 'D'); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with exec.
On 3 March 2010 13:01, Paul Halliday paul.halli...@gmail.com wrote: I need to pipe some data to an external application. I have this: while ($row = mysql_fetch_array($theData[0])) { $src_ip[] = $row[0]; $dst_ip[] = $row[1]; $sig_desc[] = $row[2]; $rec ++; if ( $rec == $recCount ) { break; } } for ($i = 0; $i sizeof($src_ip); $i++) { $tmpResult[] = $sig_desc[$i],$src_ip[$i],$dst_ip[$i]\n; } The external program is called like: cat results.csv | theprogram outputfilename Is there a way mimic this w/o outputting $tmpResult to a file first? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I believe you can use popen() to open theprogram and pipe to it the content and read back the results. All without writing to any files. -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with exec.
On Wed, 2010-03-03 at 13:04 +, Richard Quadling wrote: On 3 March 2010 13:01, Paul Halliday paul.halli...@gmail.com wrote: I need to pipe some data to an external application. I have this: while ($row = mysql_fetch_array($theData[0])) { $src_ip[] = $row[0]; $dst_ip[] = $row[1]; $sig_desc[] = $row[2]; $rec ++; if ( $rec == $recCount ) { break; } } for ($i = 0; $i sizeof($src_ip); $i++) { $tmpResult[] = $sig_desc[$i],$src_ip[$i],$dst_ip[$i]\n; } The external program is called like: cat results.csv | theprogram outputfilename Is there a way mimic this w/o outputting $tmpResult to a file first? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I believe you can use popen() to open theprogram and pipe to it the content and read back the results. All without writing to any files. popen() either reads from a pipe or writes to a pipe, if I remember well, not both. Teus. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with exec.
I work by example :) I can't find enough of an example to get me going with this. I have this: $glow = popen('afterglow.pl -c color.properties -s -e 3 -p 1 -l 2000 | neato -Tpng -o /usr/local/www/test.png','r'); how do I feed my array to that? Thanks. On Wed, Mar 3, 2010 at 9:04 AM, Richard Quadling rquadl...@googlemail.com wrote: On 3 March 2010 13:01, Paul Halliday paul.halli...@gmail.com wrote: I need to pipe some data to an external application. I have this: while ($row = mysql_fetch_array($theData[0])) { $src_ip[] = $row[0]; $dst_ip[] = $row[1]; $sig_desc[] = $row[2]; $rec ++; if ( $rec == $recCount ) { break; } } for ($i = 0; $i sizeof($src_ip); $i++) { $tmpResult[] = $sig_desc[$i],$src_ip[$i],$dst_ip[$i]\n; } The external program is called like: cat results.csv | theprogram outputfilename Is there a way mimic this w/o outputting $tmpResult to a file first? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I believe you can use popen() to open theprogram and pipe to it the content and read back the results. All without writing to any files. -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help preserving sentence structure
On Fri, 2010-02-26 at 14:11 -0600, John Tamm-Buckle wrote: Hi, new to this list... I'm adapting some code that generates text and want to keep the syntax. In the original version the output was iterated from an array in pre tags. That was fine for what it was, but it's now a word press plugin and the pre tags get in the way. How do I keep the sentence structure without using pres? Also, I'm quite new to PHP in general... :) Any help would be much appreciated! Below is an extract of the code with some highlighting for emphasis: function wpm_display_generator() { if (isset($_POST['submit_button'])) { // the form was submitted to this script - generate // and display require_once 'lib/generator.php'; require_once lib/util.php; require_once lib/vocabulary.php; require_once lib/widgets.php; $vocab = Vocabulary::getInstance(); $cats = $vocab-getCategories(); $catName = ''; $sentence = ''; if (isset($_POST['category_choice'])) { $catName = $cats[$_POST['category_choice']]; $gen = new wordGenerator($_POST['category_choice'], $_POST['length_choice']); $lines = $gen-generate(); foreach ($lines as $line) { $sentence .= pre . $line . /pre; } } require 'sentence.php'; } else { require 'generator_form.php'; } } Many thanks, John pre tags don't do anything to mark up a sentence. If you need to convert the hard returns to a br/ tag, then use nl2br() Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Help preserving sentence structure
http://us.php.net/manual/en/function.htmlentities.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help, please, understanding my problem
On Mon, 2010-02-22 at 09:09 -0600, Stan wrote: I have a PHP page that has require_once(genMyOverlay.js.php); . . . echo body; echo script language=\JavaScript\doit(\mydiv\);/scriptbr; echo /body; genMyOverlay.js.php contains: createDiv() (see below) that creates a DIV ID=mydiv and sets it up to overlay a portion of the wbe page and doit()starts it off. invoke the web page once and it works like it should. invoke the web page a second time (and thereafter until a new session) and it gets error: doit is not defined view the source (at the client browser) and it is identical both (all) times can anyone please help me understand what is happening? genMyOverlay.js.php contains script language=PHP echo script language=\JavaScript\; echo function createDiv(); echo {; . . . echo }; echo function doit(ElementID); echo {; echo creatDIV(); . . . echo }; echo /script; /script Going on just that sample, there's no issue. As it works the first time, there isn't a problem with it not getting included. Have you tried it on other browsers to see what happens there? Also, Firefox has a brilliant addon called Firebug, which can show you the contents of included .js files on your page, which will show up any problems you may have. Aside from these points, have you a good reason for including a PHP file that just outputs javascript? Why not just include the .js file as part of the header? Also, your script tags need a type attribute: script language=javascript type=text/javascript And lastly, instead of lots and lots of echo statements in your page, have you looked at heredoc and nowdoc syntax in PHP? echo EOC lots and lots of output lines go here. EOC; Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] help, please, understanding my problem
At 3:15 PM + 2/22/10, Ashley Sheridan wrote: Also, your script tags need a type attribute: script language=javascript type=text/javascript Actually, you only need this: script type=text/javascript The language attribute will throw an error in validation. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help, please, understanding my problem
On Mon, 2010-02-22 at 12:33 -0500, tedd wrote: At 3:15 PM + 2/22/10, Ashley Sheridan wrote: Also, your script tags need a type attribute: script language=javascript type=text/javascript Actually, you only need this: script type=text/javascript The language attribute will throw an error in validation. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com Never thrown an error for me! I guess it depends on what doctype you use? Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] help, please, understanding my problem
At 5:32 PM + 2/22/10, Ashley Sheridan wrote: On Mon, 2010-02-22 at 12:33 -0500, tedd wrote: At 3:15 PM + 2/22/10, Ashley Sheridan wrote: Also, your script tags need a type attribute: script language=javascript type=text/javascript Actually, you only need this: script type=text/javascript The language attribute will throw an error in validation. Cheers, tedd Never thrown an error for me! I guess it depends on what doctype you use? I was trying to be discreet. The language attribute has been depreciated. If you use a transitional DOCTYPE, then it won't throw an error -- but the language attribute is outdated and some consider it poor coding practice to use depreciated attributes. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with regex (search/replace) please
hello, Hi ryan, i am not sure i am getting you on what ya want , is this something like what ya want, the code below which i wrote? function get_value() { var el = document.form_name.elements.length; for(var i =0 ; i= el ; i++) { if(document.form_name.elements[i].type=checkbox) { var id = document.form_name.elements[i].getAttribute(id); var name = document.form_name.elements[i].getAttribute(name); var functions = document.form_name.elements[i].getAttribute(onsomething); var full_field = (you can join all 3 ^^ values to make the full code and pass that to php script via ajax , Other methods are welcome too '); } } } Regards, Gautam Bhatia On Sat, 2010-02-06 at 07:41 -0800, Ryan S wrote: Hey guys, As many of you might know, i totally suck at regex..so would really appreciate some help here. Basically i have a html page with a lot of textboxes,radios,checkboxes etc i need your help in the form of a regex so that when i give it the name and value it gives me the entire code of that checkbox. for example here are 2 checkboxes: input type=checkbox name=something value=1 / input type=checkbox name=something2 value=2 id=something onClick=javascript_code_etc() onSomething=lots of js cod here() / so if i want the second checkbox code i was thinking of something like this: $the_name=something2; $the_value=2; $fetched=getCheckboxFromHTML($the_name,$the_value); and then if successful the variable $fetched would contain input type=checkbox name=something2 value=2 id=something onClick=javascript_code_etc() onSomething=lots of js cod here() / the idea is that i would use the contents of $fetch to add some code before the end just before the greater than symbol, and do a str_replace(). What do you think? Critique of my logic above too is welcome! Thanks! Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with regex (search/replace) please
Why not just pass the value in the onclick? Onclick=doSomething(this); Would give you simple access to all the properties of that element. This.value would pass just the value. Bastien Sent from my iPod On Feb 6, 2010, at 9:43 AM, Ryan S gen...@yahoo.com wrote: Hey guys, As many of you might know, i totally suck at regex..so would really appreciate some help here. Basically i have a html page with a lot of textboxes,radios,checkboxes etc i need your help in the form of a regex so that when i give it the name and value it gives me the entire code of that checkbox. for example here are 2 checkboxes: input type=checkbox name=something value=1 / input type=checkbox name=something2 value=2 id=something onClick=javascript_code_etc() onSomething=lots of js cod here() / so if i want the second checkbox code i was thinking of something like this: $the_name=something2; $the_value=2; $fetched=getCheckboxFromHTML($the_name,$the_value); and then if successful the variable $fetched would contain input type=checkbox name=something2 value=2 id=something onClick=javascript_code_etc() onSomething=lots of js cod here() / the idea is that i would use the contents of $fetch to add some code before the end just before the greater than symbol, and do a str_replace(). What do you think? Critique of my logic above too is welcome! Thanks! Ryan -- 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] Help with regex (search/replace) please
On Sat, 2010-02-06 at 06:43 -0800, Ryan S wrote: Hey guys, As many of you might know, i totally suck at regex..so would really appreciate some help here. Basically i have a html page with a lot of textboxes,radios,checkboxes etc i need your help in the form of a regex so that when i give it the name and value it gives me the entire code of that checkbox. for example here are 2 checkboxes: input type=checkbox name=something value=1 / input type=checkbox name=something2 value=2 id=something onClick=javascript_code_etc() onSomething=lots of js cod here() / so if i want the second checkbox code i was thinking of something like this: $the_name=something2; $the_value=2; $fetched=getCheckboxFromHTML($the_name,$the_value); and then if successful the variable $fetched would contain input type=checkbox name=something2 value=2 id=something onClick=javascript_code_etc() onSomething=lots of js cod here() / the idea is that i would use the contents of $fetch to add some code before the end just before the greater than symbol, and do a str_replace(). What do you think? Critique of my logic above too is welcome! Thanks! Ryan Rather than a regex, you're probably better off using something like DomDocument, where you can iterate over all of the input elements in the document, and check the attributes of each one to check if they match your criteria. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Help with regex (search/replace) please
Hey Ash,Bastien! clip Rather than a regex, you're probably better off using something like DomDocument, where you can iterate over all of the input elements in the document, and check the attributes of each one to check if they match your criteria. /clip @Ash, You're kinda reading my mind... i did do this in domDocument but it didnt work out so well... so now am trying to do this in a diff way. Is it ok if i send you the code via an attachment? it is REA messy code right now though. @Bastien, you're talking client side... i need to do this server side as then i am writing the results to a file which is going to be used as a template in other scripts. Thanks! Ryan
Re: [PHP] Help with regex (search/replace) please
On Sat, 2010-02-06 at 07:53 -0800, Ryan S wrote: Hey Ash,Bastien! clip Rather than a regex, you're probably better off using something like DomDocument, where you can iterate over all of the input elements in the document, and check the attributes of each one to check if they match your criteria. /clip @Ash, You're kinda reading my mind... i did do this in domDocument but it didnt work out so well... so now am trying to do this in a diff way. Is it ok if i send you the code via an attachment? it is REA messy code right now though. @Bastien, you're talking client side... i need to do this server side as then i am writing the results to a file which is going to be used as a template in other scripts. Thanks! Ryan I'm not going to be about for most of the weekend now, so it might be better putting the code in something like pastebin and posting a link to it on here! Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] help with preg_replace pattern
On Tue, Jan 26, 2010 at 10:37 PM, Rob Gould gould...@mac.com wrote: It appears that IE renders it's display: none in all caps while Firefox and other browsers pass it back in lowercase. This throws off my php line of code the is supposed to nuke blank bullets from a string of text: $bl = LI style=DISPLAY: none id=bullet_ug2_col5_8/LI LI style=DISPLAY: none id=bullet_ug2_col4_8/LI LI style=DISPLAY: none id=bullet_ug2_col3_8/LI LI style=DISPLAY: none id=bullet_ug2_col2_8/LI LI style=DISPLAY: none id=bullet_ug2_8/LI LI style=DISPLAY: none id=bullet_ug1_col4_8/LI LI style=DISPLAY: list-item id=bullet_ug1_col3_8Reserved Frontstretch Tower Ticket to the NextEra Energy Resources 250 on Friday Night /LI LI style=DISPLAY: list-item id=bullet_ug1_col2_8Reserved Frontstretch Tower Ticket to the Camping World 300 on Saturday /LI LI style=DISPLAY: list-item id=bullet_2_8Reserved Frontstretch Tower Ticket to the Daytona 500 on Sunday /LI LI style=DISPLAY: none id=bullet_addon_col2_8/LI LI style=DISPLAY: none id=bullet_addon3_8/LI LI style=DISPLAY: none id=bullet_option2_col4_8/LI LI style=DISPLAY: none id=bullet_option2_col3_8/LI LI style=DISPLAY: none id=bullet_option2_col2_8/LI LI style=DISPLAY: none id=bullet_option2_col1_8/LI LI style=DISPLAY: none id=bullet_option3_col4_8/LI LI style=DISPLAY: none id=bullet_option3_col3_8/LI LI style=DISPLAY: none id=bullet_option3_col2_8/LI LI style=DISPLAY: none id=bullet_option3_col1_8/LI LI style=DISPLAY: none id=bullet_option4_col4_8/LI LI style=DISPLAY: none id=bullet_option4_col3_8/LI I want to keep the DISPLAY: list-item lines, and nuke all the others. The below above are sent to PHP in a variable called $bl. I then try to nuke the DISPLAY: none lines with something like: $pattern = '/li[^]*style=display: none[^]*/'; $bl = preg_replace($pattern,'',$bl); $pattern = '/li[^]*style=DISPLAY: none[^]*/'; $bl = preg_replace($pattern,'',$bl); But it appears that the case-sensitivity fix is not just a matter of making the letter capitals. I'm sure someone who knows more than I about preg_replace will see the immediate error of my ways. Any advice is greatly appreciated. Your regex is looking for case-sensitive matches, which given the example below, would preclude all of your list items (they all start with LI, not li.) Try using a case insensitive regex (e.g., $bl = preg_replace($pattern = /li[^]*style=DISPLAY: none[^]*/i','',$bl); (Note the i after the search pattern above.) Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
Re: [PHP] Help needed with calculation
If the download speed is constant (linear) then you can just use. (10245458756 / 6t)/1000 = kb/second or (10245458756 / 6t)/6 = kb/minute The general form would be. (size_of_file / download_speed * time) / convert_to_units Where t (or time) is the amount of seconds that the download has been active. On Sun, Nov 15, 2009 at 15:39, Chris Payne chris_pa...@danmangames.com wrote: Hi everyone, I'm not sure of the correct formula for this, if I have a file - just for example, that is 10245458756 bytes long and the download speed is 60KB a second, what formula would I use to calculate how many seconds/minutes/hours it would take to download the file? Maths really isn't my strong point and formulas go over my head otherwise I wouldn't ask :-( Thanks everyone Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- - Adam Shannon ( http://ashannon.us ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help on pregreplace
On Tue, 2009-08-18 at 16:00 +0200, Merlin Morgenstern wrote: Hi there, I am highlighting keywords with the help of pregreplace. This works great with one limitation. If the word that has to be replaced contains a slash, preg throws an error. So far I could not find a fix. Can someone help? Here is the code: $pattern = /\b($words)\b/is; $replace = 'span style=background:#FF;color:#FC;\\1/span'; return preg_replace($pattern,$replace,$str); Thank you in advance, Merlin Well, a slash has a special meaning inside PHP strings, more so for double quoted strings. Are you correctly escaping the slash as a double slash so that it's not interpreted by the string as an escaped character, as you will need to as the preg_replace will be interpreting it as an escape sequence to match? Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help on pregreplace
Ashley Sheridan wrote: On Tue, 2009-08-18 at 16:00 +0200, Merlin Morgenstern wrote: Hi there, I am highlighting keywords with the help of pregreplace. This works great with one limitation. If the word that has to be replaced contains a slash, preg throws an error. So far I could not find a fix. Can someone help? Here is the code: $pattern = /\b($words)\b/is; $replace = 'span style=background:#FF;color:#FC;\\1/span'; return preg_replace($pattern,$replace,$str); Thank you in advance, Merlin Well, a slash has a special meaning inside PHP strings, more so for double quoted strings. Are you correctly escaping the slash as a double slash so that it's not interpreted by the string as an escaped character, as you will need to as the preg_replace will be interpreting it as an escape sequence to match? Thanks, Ash http://www.ashleysheridan.co.uk HI, replacing the delimiter slash by ~ solved the problem. Thank you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help on pregreplace
On 8/18/09 10:56 AM, Merlin Morgenstern merli...@fastmail.fm wrote: Ashley Sheridan wrote: On Tue, 2009-08-18 at 16:00 +0200, Merlin Morgenstern wrote: Hi there, I am highlighting keywords with the help of pregreplace. This works great with one limitation. If the word that has to be replaced contains a slash, preg throws an error. So far I could not find a fix. Can someone help? Here is the code: $pattern = /\b($words)\b/is; $replace = 'span style=background:#FF;color:#FC;\\1/span'; return preg_replace($pattern,$replace,$str); Thank you in advance, Merlin Well, a slash has a special meaning inside PHP strings, more so for double quoted strings. Are you correctly escaping the slash as a double slash so that it's not interpreted by the string as an escaped character, as you will need to as the preg_replace will be interpreting it as an escape sequence to match? Thanks, Ash http://www.ashleysheridan.co.uk HI, replacing the delimiter slash by ~ solved the problem. Thank you which means that words with ~ in them will fail. as Al pointed out, preg_quote() is a more general solution. it escapes all tricky pcre characters as well as the delimiter. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP - Parse Error
On Tue, Aug 4, 2009 at 13:47, Allen McCabeallenmcc...@gmail.com wrote: [snip=everything] Looks like you're missing a closing bracket here: if(!empty($_POST['EMailAddress'])) { $EMailAddress = $_POST['EMailAddress']; } else { $EMailAddress = ; // --- Right here -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Check out our great hosting and dedicated server deals at http://twitter.com/pilotpig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP - Parse Error
Allen McCabe wrote: *Parse error*: syntax error, unexpected $end in * /home/a9066165/public_html/admin/processccu.php* on line *231* I have learned from a number of similar mistakes that this error message /normally/ means that I have a miss-matched number of brackets on a foreach, while, or if, etc... statement. Usually the line number will represent the last line in your script. In this case, they don't seem to match... Jim I did some major code rewriting about halfway through (lines 114-132), and suddenly I'm getting the above ERROR. I have examined the code line by line, but I'm still relatively new to this, and I don't even know what to look for! Here is the complete code, from beginning ?php tag to closing /html tag: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP - Parse Error
On Tue, 2009-08-04 at 10:56 -0700, Jim Lucas wrote: Allen McCabe wrote: *Parse error*: syntax error, unexpected $end in * /home/a9066165/public_html/admin/processccu.php* on line *231* I have learned from a number of similar mistakes that this error message /normally/ means that I have a miss-matched number of brackets on a foreach, while, or if, etc... statement. Usually the line number will represent the last line in your script. In this case, they don't seem to match... Jim I did some major code rewriting about halfway through (lines 114-132), and suddenly I'm getting the above ERROR. I have examined the code line by line, but I'm still relatively new to this, and I don't even know what to look for! Here is the complete code, from beginning ?php tag to closing /html tag: Thats why I always prefer to have the brackets line up in the code (I forget what the style is called) so that it looks like this: function someFunction { if(condition) { do something } } etc.. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP - Parse Error
Ashley - I am formatting this way, it just didn't translate into gmail : ) Daniel, Martin, and Jim - Thanks very much, my php runs now, however I don't get the result page anymore. My inbox receives the form (missing cells, but that's another issue), but the browser doesn't load processccu.php, it says it cannot display the webpage. note: I did address the mismatch of the DIV and TABLE (including TR's, TD's) tags, so I don't think it's my HTML. On Tue, Aug 4, 2009 at 10:58 AM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-08-04 at 10:56 -0700, Jim Lucas wrote: Allen McCabe wrote: *Parse error*: syntax error, unexpected $end in * /home/a9066165/public_html/admin/processccu.php* on line *231* I have learned from a number of similar mistakes that this error message /normally/ means that I have a miss-matched number of brackets on a foreach, while, or if, etc... statement. Usually the line number will represent the last line in your script. In this case, they don't seem to match... Jim I did some major code rewriting about halfway through (lines 114-132), and suddenly I'm getting the above ERROR. I have examined the code line by line, but I'm still relatively new to this, and I don't even know what to look for! Here is the complete code, from beginning ?php tag to closing /html tag: Thats why I always prefer to have the brackets line up in the code (I forget what the style is called) so that it looks like this: function someFunction { if(condition) { do something } } etc.. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] HELP - Parse Error
Well, I got it to display a thank you page instead of what I had. I'm rolling with the punches. Got to work on why my email table is not building right. Stay tuned! On Tue, Aug 4, 2009 at 11:09 AM, Allen McCabe allenmcc...@gmail.com wrote: Ashley - I am formatting this way, it just didn't translate into gmail : ) Daniel, Martin, and Jim - Thanks very much, my php runs now, however I don't get the result page anymore. My inbox receives the form (missing cells, but that's another issue), but the browser doesn't load processccu.php, it says it cannot display the webpage. note: I did address the mismatch of the DIV and TABLE (including TR's, TD's) tags, so I don't think it's my HTML. On Tue, Aug 4, 2009 at 10:58 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2009-08-04 at 10:56 -0700, Jim Lucas wrote: Allen McCabe wrote: *Parse error*: syntax error, unexpected $end in * /home/a9066165/public_html/admin/processccu.php* on line *231* I have learned from a number of similar mistakes that this error message /normally/ means that I have a miss-matched number of brackets on a foreach, while, or if, etc... statement. Usually the line number will represent the last line in your script. In this case, they don't seem to match... Jim I did some major code rewriting about halfway through (lines 114-132), and suddenly I'm getting the above ERROR. I have examined the code line by line, but I'm still relatively new to this, and I don't even know what to look for! Here is the complete code, from beginning ?php tag to closing /html tag: Thats why I always prefer to have the brackets line up in the code (I forget what the style is called) so that it looks like this: function someFunction { if(condition) { do something } } etc.. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] HELP - Parse Error
Allen McCabe wrote: Ashley - I am formatting this way, it just didn't translate into gmail : ) You might try using indentation with more then one space. Try tabs. Any respectable editor will allow you to set the number of spaces it uses to actually represent the tab. That way I can have mine set to 8 spaces while other can have 3 or 4 spaces. Daniel, Martin, and Jim - Thanks very much, my php runs now, however I don't get the result page anymore. My inbox receives the form (missing cells, but that's another issue), but the browser doesn't load processccu.php, it says it cannot display the webpage. note: I did address the mismatch of the DIV and TABLE (including TR's, TD's) tags, so I don't think it's my HTML. On Tue, Aug 4, 2009 at 10:58 AM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-08-04 at 10:56 -0700, Jim Lucas wrote: Allen McCabe wrote: *Parse error*: syntax error, unexpected $end in * /home/a9066165/public_html/admin/processccu.php* on line *231* I have learned from a number of similar mistakes that this error message /normally/ means that I have a miss-matched number of brackets on a foreach, while, or if, etc... statement. Usually the line number will represent the last line in your script. In this case, they don't seem to match... Jim I did some major code rewriting about halfway through (lines 114-132), and suddenly I'm getting the above ERROR. I have examined the code line by line, but I'm still relatively new to this, and I don't even know what to look for! Here is the complete code, from beginning ?php tag to closing /html tag: Thats why I always prefer to have the brackets line up in the code (I forget what the style is called) so that it looks like this: function someFunction { if(condition) { do something } } etc.. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP - Parse Error
I created a webpage with the code listed, and a screen shot of the email I am currently receiving (with nonsense entered into my inputs) URL: http://lpacmarketing.hostzi.com/admin/help.html Anyone that can provide help will be rewarded in their next life. That's a promise. Thanks! On Tue, Aug 4, 2009 at 10:58 AM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-08-04 at 10:56 -0700, Jim Lucas wrote: Allen McCabe wrote: *Parse error*: syntax error, unexpected $end in * /home/a9066165/public_html/admin/processccu.php* on line *231* I have learned from a number of similar mistakes that this error message /normally/ means that I have a miss-matched number of brackets on a foreach, while, or if, etc... statement. Usually the line number will represent the last line in your script. In this case, they don't seem to match... Jim I did some major code rewriting about halfway through (lines 114-132), and suddenly I'm getting the above ERROR. I have examined the code line by line, but I'm still relatively new to this, and I don't even know what to look for! Here is the complete code, from beginning ?php tag to closing /html tag: Thats why I always prefer to have the brackets line up in the code (I forget what the style is called) so that it looks like this: function someFunction { if(condition) { do something } } etc.. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] HELP - Parse Error
Allen McCabe wrote: I created a webpage with the code listed, and a screen shot of the email I am currently receiving (with nonsense entered into my inputs) URL: http://lpacmarketing.hostzi.com/admin/help.html Anyone that can provide help will be rewarded in their next life. That's a promise. um, your hosting doesn't like that for some reason. Click it and see what you get. Thanks! On Tue, Aug 4, 2009 at 10:58 AM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-08-04 at 10:56 -0700, Jim Lucas wrote: Allen McCabe wrote: *Parse error*: syntax error, unexpected $end in * /home/a9066165/public_html/admin/processccu.php* on line *231* I have learned from a number of similar mistakes that this error message /normally/ means that I have a miss-matched number of brackets on a foreach, while, or if, etc... statement. Usually the line number will represent the last line in your script. In this case, they don't seem to match... Jim I did some major code rewriting about halfway through (lines 114-132), and suddenly I'm getting the above ERROR. I have examined the code line by line, but I'm still relatively new to this, and I don't even know what to look for! Here is the complete code, from beginning ?php tag to closing /html tag: Thats why I always prefer to have the brackets line up in the code (I forget what the style is called) so that it looks like this: function someFunction { if(condition) { do something } } etc.. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with file downloads.
On Sun, 2009-07-19 at 16:47 +0930, tony mount wrote: Hi, My first post. Been writing php from scratch for about 12 months, mainly with what I learnt from the web. Have a problem trying to download multiple files. I'm using the following code: if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); //exit; } from the the php manual under readfile. The files are text files 1Mb in size. Only the first file is downloaded. (The exit; statement is excluded). What should I do? Thanks Tony Is that script in a loop or something, as by itself, it'll only operate on one file. Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP SQL INJECTION
On Saturday 11 July 2009 01:17:28 Zareef Ahmed wrote: Hi, First of all change your FTP password and stop storing your password in your FTP client. This type of attacks are very common with the people who use insecure FTP client. My previous experience with your kind of problem tell me that chances of a FTP attack are really higher in the pattern of your case. Zareef Ahmed On Sat, Jul 11, 2009 at 3:50 AM, Daniel Brown danbr...@php.net wrote: On Fri, Jul 10, 2009 at 18:11, Chris Paynechris_pa...@danmangames.com wrote: Sorry I post at the top because i'm legally blind and it's easier but i'll try to post at the bottom :-) This is the main site on my server: http://www.oxyge.net I just took out the offending code at the end of the index page to get it back up and running. Check the /blog/ as well. Parse error. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Check out our great hosting and dedicated server deals at http://twitter.com/pilotpig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Another way that they hackers get in in the first place is by exploiting a vulnerability in software you have on the server. Have you installed something pre-built, like a forum, blog, etc? Sometimes, these have holes, which can be an open door if left unpatched. -- Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP SQL INJECTION
On Fri, Jul 10, 2009 at 15:48, Chris Paynechris_pa...@danmangames.com wrote: Hi everyone, My server appears to be the victim of a chinese hack-attack and I believe they managed to change pages via SQL Injection, do any of you have any ideas how to lock down my forms so MySQL cannot be used from my forms? First and foremost: http://php.net/mysql_real_escape_string -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Check out our great hosting and dedicated server deals at http://twitter.com/pilotpig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP SQL INJECTION
On Fri, Jul 10, 2009 at 3:50 PM, Daniel Browndanbr...@php.net wrote: On Fri, Jul 10, 2009 at 15:48, Chris Paynechris_pa...@danmangames.com wrote: Hi everyone, My server appears to be the victim of a chinese hack-attack and I believe they managed to change pages via SQL Injection, do any of you have any ideas how to lock down my forms so MySQL cannot be used from my forms? First and foremost: http://php.net/mysql_real_escape_string -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Check out our great hosting and dedicated server deals at http://twitter.com/pilotpig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You, sir, are an email list ninja. Not ten seconds before I hit Send, Gmail tells me you ninja'd my response! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP SQL INJECTION
On Jul 10, 2009, at 1:50 PM, Daniel Brown wrote: On Fri, Jul 10, 2009 at 15:48, Chris Paynechris_pa...@danmangames.com wrote: Hi everyone, My server appears to be the victim of a chinese hack-attack and I believe they managed to change pages via SQL Injection, do any of you have any ideas how to lock down my forms so MySQL cannot be used from my forms? First and foremost: http://php.net/mysql_real_escape_string I am total newbie here, but I can say I would recommend getting a good PHP book or at least reading some articles on preventing XSS attacks (if I said that right) and also SQL injection. for inserting data in to your db, use placeholders. for printing data coming from the db, use htmlentities() for retrieving data from your db via form/user input, use mysql_real_escape_string and strtr() to escape SQL wildcards (%) and the _ char. If I mis-guide the OP, please correct me! Govinda govinda.webdnat...@gmail.com