Re: [PHP] Urgent help - Token Generation code!

2011-05-28 Thread Shreyas Agasthya

Let me try and get back.

Thanks, Jasper!



On 28-May-2011, at 4:29 AM, Jasper Mulder lord_fa...@hotmail.com  
wrote:






From: shreya...@gmail.com
To: lord_fa...@hotmail.com
Subject: Re: [PHP] Urgent help - Token Generation code!
Date: Sat, 28 May 2011 04:15:59 +0530

Jasper,

Tried echoing $sToken but wouldn't work.

Regards,
Shreyas

On 28-May-2011, at 4:11 AM, Jasper Mulder
wrote:





Date: Sat, 28 May 2011 03:56:26 +0530
From: shreya...@gmail.com
To: php-general@lists.php.net
Subject: [PHP] Urgent help - Token Generation code!

I am re-visiting the world of PHP after a really big hiatus and I
am finding
things veryslippery. Can someone please help me with the below code
and let
me know how I can print the token that is getting generated?

I am using EasyPHP and I am trying to echo the $token but it
wouldn't print
anything. I am trying it as : http://localhost/token/URLToken.php.
May I
know where all I am going wrong here in my approach?




$sUrl = /tstd_c_b1@s54782;
$sParam = primaryToken;
$nTime = time();
$nEventDuration = 86400;
$nWindow = $nTime + $nEventDuration;
$sSalt = akamai123!;
$sExtract = ; // optional



As a second try, what happens if you add right here the line

$sGen = urlauth_gen_url($sUrl, $sParam, $nWindow, $sSalt, $sExtract,  
$nTime);


Because it seems as though you just declare three functions in the  
code

without calling them...



function urlauth_gen_url($sUrl, $sParam, $nWindow,
$sSalt, $sExtract, $nTime) {



$sToken = urlauth_gen_token($sUrl, $nWindow, $sSalt,
$sExtract, $nTime);
echo $token;


There are two cases:
1. You made a typo and meant 'echo $sToken;' on the above line  
instead

2. You omitted the part where $token is defined and used


[More code that seemed fine]

--
Regards,
Shreyas Agasthya




Best regards,
Jasper Mulder



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Urgent help - Token Generation code!

2011-05-27 Thread Shreyas Agasthya
I am re-visiting the world of PHP after a really big hiatus and I am finding
things veryslippery. Can someone please help me with the below code and let
me know how I can print the token that is getting generated?

I am using EasyPHP and I am trying to echo the $token but it wouldn't print
anything. I am trying it as : http://localhost/token/URLToken.php. May I
know where all I am going wrong here in my approach?

?php

  $sUrl = /tstd_c_b1@s54782;
   $sParam = primaryToken;
   $nTime = time();
   $nEventDuration = 86400;
   $nWindow = $nTime + $nEventDuration;
   $sSalt = akamai123!;
   $sExtract = ; // optional


function urlauth_gen_url($sUrl, $sParam, $nWindow,
 $sSalt, $sExtract, $nTime) {



$sToken = urlauth_gen_token($sUrl, $nWindow, $sSalt,
$sExtract, $nTime);
 echo $token;
 if ($sToken == null) {
return ;
}

if (($sParam == ) || (!is_string($sParam))) {
$sParam = __gda__;
}

if ((strlen($sParam)  5) || (strlen($sParam)  12)) {
return;
}

if (($nWindow  0) || (!is_integer($nWindow))) {
return;
}

if (($nTime = 0) || (!is_integer($nTime))) {
$nTime = time();
}

$nExpires = $nWindow + $nTime;

if (strpos($sUrl, ?) === false) {
$res = $sUrl . ? . $sParam . = . $nExpires . _ . $sToken;
} else {
$res = $sUrl .  . $sParam . = . $nExpires . _ . $sToken;
}

return $res;
}

/**
 * Returns the hash portion of the token. This function should not be
 *   called directly.
 */
function urlauth_gen_token($sUrl, $nWindow, $sSalt,
   $sExtract, $nTime) {


if (($sUrl == ) || (!is_string($sUrl))) {
return;
}

if (($nWindow  0) || (!is_integer($nWindow))) {
return;
}

if (($sSalt == ) || (!is_string($sSalt))) {
return;
}

if (!is_string($sExtract)) {
$sExtract = ;
}

if (($nTime = 0) || (!is_integer($nTime))) {
$nTime = time();
}

$nExpires = $nWindow + $nTime;
$sExpByte1 = chr($nExpires  0xff);
$sExpByte2 = chr(($nExpires  8)  0xff);
$sExpByte3 = chr(($nExpires  16)  0xff);
$sExpByte4 = chr(($nExpires  24)  0xff);

$sData = $sExpByte1 . $sExpByte2 . $sExpByte3 . $sExpByte4
 . $sUrl . $sExtract . $sSalt;

$sHash = _unHex(md5($sData));

$sToken = md5($sSalt . $sHash);
return $sToken;
}

/**
 * Helper function used to translate hex data to binary
 */
function _unHex($str) {
$res = ;
for ($i = 0; $i  strlen($str); $i += 2) {
$res .= chr(hexdec(substr($str, $i, 2)));
}
return $res;
}

?

-- 
Regards,
Shreyas Agasthya


Re: [PHP] JavaScript Injection ???

2011-04-18 Thread Shreyas Agasthya
Is someone up to Cross Site Scripting? ;)

--Shreyas

On Mon, Apr 18, 2011 at 10:39 PM, Joshua Kehn josh.k...@gmail.com wrote:

 On Monday, April 18, 2011 at 1:06 PM, tedd wrote:
 Hi gang:
 
  Quite some time ago I had a demo that showed Javascript injection. It
  was where a user could type in:
 
  script alert(Evil Code);/script
 
  and a JavaScript alert would be shown.
 
  But now my demo no longer works. So, what happened? Was there a php
  update that prohibited that sort of behavior or did hosts start
  setting something to OFF, or what?
 
  If you know, please explain.
 
  Thanks,
 
  tedd
  --
  ---
  http://sperling.com/
 Not that I know of. Are you talking about on-page injection, like comments
 and such? Normally JS injection would be that (bad scripts inserted by the
 user on a comment form or review page) or where you are using eval() and
 they dump bad code into there.

 Regards,

 -Josh___
 Joshua Kehn | josh.k...@gmail.com
 http://joshuakehn.com





-- 
Regards,
Shreyas Agasthya


Re: [PHP] Does requesting $_SERVER variables need to query the server

2011-02-23 Thread Shreyas Agasthya
Marc,

$_SERVER is an array and it should have all the information. I do not know
the answer for the latter part of your query.

Regards,
Shreyas

On Thu, Feb 24, 2011 at 12:30 AM, Marc Guay marc.g...@gmail.com wrote:

 This question will probably reveal my lacking knowledge of the
 fundamentals, but I'm a go for it anyway:

 When you use a $_SERVER variable, is a query made to the server to get
 the information or is it just sitting in a variable all ready to go?
 Reworded, is there any efficiency gained by storing the data in a
 local variable if it's going to be used many times in the script?
 My experience with jQuery has taught me to store $(objects) in local
 variables if they're going to be used repeatedly because the DOM is
 queried every time a jQuery object is generated, so I'm wondering if a
 similar logic applies.

 Example:

 if ($_SERVER['SCRIPT_NAME'] == 'how.php')
 // do stuff
 if ($_SERVER['SCRIPT_NAME'] == 'why.php')
 // do other stuff

 vs.

 $script_name = $_SERVER['SCRIPT_NAME'];

 if ($script_name == 'how.php')
 // do stuff
 if ($script_name  == 'why.php')
 // do other stuff

 Cheerios,
 Marc

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


Re: [PHP] odd list bounces

2011-01-31 Thread Shreyas Agasthya
Ashley,

I just got one with the subject line as : ' ezmlm warning'
*
*

On Mon, Jan 31, 2011 at 4:17 PM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

 Hiya,

 Is anyone else getting odd bounce messages? I just received one from the
 list about a message that was returned as a bounce from my email
 address. The fact that I was able to read an email about an email that
 bounced from me suggests that things are OK my end with regards to
 receiving messages.

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk





-- 
Regards,
Shreyas Agasthya


Re: [PHP] Fw: Spoofing user_agent

2010-11-25 Thread Shreyas Agasthya
A standard HTTP Request headers is : User Agent (without the underscore).

--Shreyas

On Thu, Nov 25, 2010 at 2:36 PM, Ron Piggott ron.pigg...@actsministries.org
 wrote:


 Is this what you are telling me to do:

 header('user_agent: RonBot (http://www.theverseoftheday.info)');

 Ron

 The Verse of the Day
 “Encouragement from God’s Word”
 http://www.TheVerseOfTheDay.info

 From: a...@ashleysheridan.co.uk
 Sent: Thursday, November 25, 2010 3:34 AM
 To: Ron Piggott ; php-general@lists.php.net
 Subject: Re: [PHP] Fw: Spoofing user_agent

 You need to set it in the header request you make. Putting it in the script
 you're using as a spider with ini_set won't do anything because the Target
 site doesn't know anything about it.

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk

 - Reply message -
 From: Ron Piggott ron.pigg...@actsministries.org
 Date: Thu, Nov 25, 2010 08:25
 Subject: [PHP] Fw: Spoofing user_agent
 To: php-general@lists.php.net

 I have wrote a script to generate a sitemap of my web site.  It crawls all
 of the site web pages.  (About 30,000)

 I need help to spoof the user_agent variable so the stats program running
 in the background ( “AWSTATS” ) will treat the crawl as a bot, not browsing
 usage.

 The sitemap generator is a cron job.  I tried the syntax:
 ini_set('user_agent', 'RonBot (http://www.theverseoftheday.info)/'/);

 This didn’t work.  The browsing was attributed to the dedicated IP address.

 How do I get AWSTATS to access this, such as other entries under the
 “Robots/Spiders visitors” heading:
 Unknown robot (identified by 'bot*')

 I don’t mean any ill will by changing this setting.  Thanks for the help.

 Ron

 The Verse of the Day
 “Encouragement from God’s Word”
 http://www.TheVerseOfTheDay.info




-- 
Regards,
Shreyas Agasthya


Re: [PHP] Pros/Cons of using mysqli prepared statments

2010-11-04 Thread Shreyas Agasthya
Tamara,

In one of the earlier threads, it was mentioned mysqli APIs are more secure,
faster, and actually maintained.

Also, if you use some of the mysql_xxx(), you actually get a warning saying
that it will be or it is being deprecated and paves the way for you to
approach the same thing with mysqli_xxx().

The seniors perhaps can give you more facts which they have seen and
experienced.

Regards,
Shreyas

On Thu, Nov 4, 2010 at 1:18 PM, Tamara Temple tam...@tamaratemple.comwrote:

 I'm wondering what the advantages/disadvantage of using prepared statements
 with mysqli are. I'm used to using the mysqli::query and mysqli::fetch_assoc
 functions to deal with retrieving data and bulding my sql statement in php
 code.

 Tamara Temple
-- aka tamouse__
 tam...@tamaratemple.com


 May you never see a stranger's face in the mirror.


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


Re: [PHP] Apache mod_pagespeed

2010-11-03 Thread Shreyas Agasthya
Thiago,

I would like to join this. Let me know how I can help you with this. Please
be explicit with your requests so that we can totally test it  and see if it
could pose any risk to acceleration services provided by CDNs.

Regards,
Shreyas

On Wed, Nov 3, 2010 at 11:51 PM, Thiago H. Pojda thiago.po...@gmail.comwrote:

 Guys,

 Google announced this
 morning
 http://googlewebmastercentral.blogspot.com/2010/11/make-your-websites-run-faster.html
 their
 mod_pagespeed http://code.google.com/speed/page-speed/docs/module.html
 to
 improve Apache's performance. It really looks promising, what do you guys
 think?

 Me and Daniel Brown will be running some tests with it, let us know if
 you'd
 like to join us. :)

 Google mentions 2x faster loading times, but they don't mention CPU cost.

 What do you think it will break?


 Cheers,
 Thiago Henrique Pojda
 +55 41 8856-7925




-- 
Regards,
Shreyas Agasthya


Re: [PHP] Reminder On Mailing List Rules

2010-10-21 Thread Shreyas Agasthya
Let's adhere to the rules.

--Shreyas

On Fri, Oct 22, 2010 at 1:15 AM, Per Jessen p...@computer.org wrote:

 sueandant wrote:

  Hi
 
  I'm not familiatr with the term top-post; could you please explain?

 http://lmgtfy.com/?q=top-post



 --
 Per Jessen, Zürich (3.7°C)


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


Let's adhere to the rules

-- 
Regards,
Shreyas Agasthya


Re: [PHP] Formatting an ECHO statement.

2010-10-19 Thread Shreyas Agasthya
Thanks for that detailed mail, Admin. The i was an example and I wanted to
understand how does one go about the whole formatting. Nonetheless, I am
pretty well informed after this thread.

Thanks once again, everyone.

Regards,
Shreyas

On Tue, Oct 19, 2010 at 10:09 AM, Paul M Foster pa...@quillandmouse.comwrote:

 On Mon, Oct 18, 2010 at 10:46:41PM -0400, Cris S wrote:

  At 15:12 18 10 10, Shreyas Agasthya wrote:
  Thanks all for their input. Some of the learnings  from the thread :
  
  1. i tag is getting deprecated.
 
  Not in HTML5.
 
  2. Use em and strong
 
  Both? Read that shit again, buckwheat. And by that shit I
  do mean the standards, not what Joe Bloe told you.
 
  3. Have CSS used to do the kind of stuff I was trying.
 
  Uhm, yeah. @@
 
   I must inform, this was already in place.
 
  Then why the fuck are we discussing this?
 
  4. Keep an eye on the SE monster.
 
  and on the go fuck yourself monster too.
 
  Holy fuck, I've been lurking for months. I turn away for
  one day and this is the non-PHP crap that happens?

 Please go back to lurking. We'd all appreciate it, and you'll be
 happier.

 Paul

 --
 Paul M. Foster

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


[PHP] Formatting an ECHO statement.

2010-10-18 Thread Shreyas Agasthya
Team,

A bit of silly one but like my book says, there are no dumb questions, I am
asking it here.

If I have :

$other=Whatever;

and I do:

echo 'Other Comments:' .$other. 'br/

works perfectly well and prints the value. What if I want to, now, italicize
the value of $other with the above syntax? How do I achieve it?

I know we can do it this way : echo  I am i$other/i; but I want to
learn how to do it with the above syntax like I mentioned earlier.

Regards,
Shreyas Agasthya


Re: [PHP] Eclipse, Komodo, Netbeans, Zend Studio, PHP Storm, other?

2010-10-13 Thread Shreyas Agasthya
Eclipse Ganymede or Galileo.

The support for plug-ins is what I like.

I have tried NetBeans and found it to be OK.

--Shreyas

On Wed, Oct 13, 2010 at 10:28 PM, Hansen, Mike mike.han...@atmel.comwrote:

 I'm about to do a lot of work on an existing code base and I think I'd like
 to try an IDE. I currently use VIM for most editing.

 What IDE are you using?

 What do you like about the one you are using?

 Which ones have you tried?

 Mike



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


Re: [PHP] Re: Continuance of the struggle (trying to understand)

2010-10-05 Thread Shreyas Agasthya
Col,

Can you let us know what exactly you see when you say
http://localhost:/phptest.php
?


Regards,
Shreyas

On Tue, Oct 5, 2010 at 4:20 PM, Col Day colind...@aol.com wrote:


 Col Day colind...@aol.com wrote in message
 news:23.81.45586.2820b...@pb1.pair.com...

  Hi all,

 After my escapades with the real basics and realizing my laptop wasn't
 logged on as Administrator, I now am trying to work out why this script
 works sometimes but not others.

   html
   head
   titlePHP Test/title
   /head
   body
   pThis is an HTML line
   ?php
  echo pThis is a PHP line/p;
  phpinfo();
   ?
   /body
   /html

 If I save this as phptest.php and open IE pointing it to
 localhost/phptest.php it works fine. Get both lines of text followed by the
 pages of gumpf about php.

 However if I paste this into a



 That was weird!

 I was saying, If I paste this into a webpage I only get the HTML line as
 before.

 Anyone have any ideas?

 PHP is obviously working as is apache. Just don't understand why they don't
 show up in web pages.

 Cheers again all!

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


Re: [PHP] Re: SEO Experts?

2010-09-26 Thread Shreyas Agasthya
Avoid 302's as mush as possible.

--Shreyas

On Sun, Sep 26, 2010 at 8:55 PM, Al n...@ridersite.org wrote:



 On 9/26/2010 8:09 AM, David Mehler wrote:

 Hello,
 Do we have any SEO experts on this list? I'm not one, learning only,
 reading a book and a few articles/tutorials from webmasters, and I'm
 wanting to optimize an existing site to get the best search rank
 possible. Some techniques, dos and don'ts would be appreciated.
 Thanks.
 Dave.



 Google Webmasters is a very good resource.


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


Re: [PHP] Web application architecture (subdomain vs. sub directory)

2010-08-25 Thread Shreyas Agasthya
I am not sure who the end-users are for your website but if you are
concerned about scalability, I would definitely go for a sub-domain
approach. Assuming you approach a CDN like Akamai and you want to offload
the traffic to come from the cloud, it's lot easier for you to integrate
with them and to maintain.

The subdirectory approach, whereas, is very cumbersome and  takes more work
at your end to paraphrase the whole set-up should the needs change going
forward.

Regards,
Shreyas

On Thu, Aug 26, 2010 at 12:42 AM, Steven Staples sstap...@mnsi.net wrote:

 I started out not using a framework... then I started at a company who used
 a zend like framework, worked there for a bit, then moved on, and started
 using cake...

 I found that they were great for what they are... but really simplified
 things too much, so I created my own framework, incorporating the classes
 that I use all the time (smarty/fpdf/jquery/tinymce), and with that, I
 learned a LOT about how things really worked.

 I would suggest looking at the core of the frameworks to see how things are
 put together, and how they really work... but maybe make one that is more
 custom to your application?

 As for subdomain vs subdirectory, if your using SSL, then you would need a
 wildcard SSL which is usually more money.  Eitherway you choose, you will
 have to program around it.  The app that I created uses subdomains, because
 we were using CA SSL Certs, and the clients preferred to have their own
 IP's... long story, not my call, I just program it :P


 Steven Staples


  -Original Message-
  From: Peter Lind [mailto:peter.e.l...@gmail.com]
  Sent: August 25, 2010 3:01 PM
  To: a...@ashleysheridan.co.uk
  Cc: Tim Martens; php-general@lists.php.net
  Subject: Re: [PHP] Web application architecture (subdomain vs. sub
  directory)
 
  On 25 August 2010 20:54, Ashley Sheridan a...@ashleysheridan.co.uk
 wrote:
   On Wed, 2010-08-25 at 13:45 -0500, Tim Martens wrote:
  
   If you're new to PHP, I would recommend not using a framework for the
   experience you will gain with the language, as a framework will tend to
   hide away certain caveats and peculiarities of PHP which could lead to
   issues further down the line. Most people I know who are great PHP
   programmers have tended to start without frameworks at first.
  
   Having said that, if you're looking for a rapid deployment with a
   shorter learning curve, then a framework might be better in this
   situation.
  
 
  You could also argue that using a framework is more likely to promote
  good habits, as there's a bigger chance you'll be forced down good
  paths.
 
  Regards
  Peter
 
  --
  hype
  WWW: http://plphp.dk / http://plind.dk
  LinkedIn: http://www.linkedin.com/in/plind
  BeWelcome/Couchsurfing: Fake51
  Twitter: http://twitter.com/kafe15
  /hype
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
  No virus found in this incoming message.
  Checked by AVG - www.avg.com
  Version: 9.0.851 / Virus Database: 271.1.1/3089 - Release Date: 08/25/10
  02:34:00


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


Re: [PHP] Regular expressions, filter option1 OR option2

2010-08-18 Thread Shreyas Agasthya
Camilo,

What exactly are you trying to achieve? Meaning:

if (true)
   do this;
if (false)
   do that;

However, here's a link that I used long back to help me with some RegEx :
http://www.gskinner.com/RegExr/

Regards,
Shreyas

On Wed, Aug 18, 2010 at 11:31 PM, Camilo Sperberg csperb...@unreal4u.comwrote:

 Hello list :)

 Just a short question which I know it should be easy, but I'm no expert yet
 in regular expressions.
 I've got a nice little XML string, which is something like this but can be
 changed:

 ?xml version=1.0 encoding=utf-8?
 boolean xmlns=http://tempuri.org/;false/boolean

 The boolean value can be true or false, so what I want to do, is filter it.
 I've done it this way, but I know it can be improved (just because I love
 clean coding and also because I want to master regular expressions xD):

  $result = preg_match('/true/',$curl_response);
  if ($result == 0) $result = preg_match('/false/',$curl_response);

 I've also tried something like:
 $result = preg_replace('/^(true)|^(false)/','',$curl_response); // if not
 true OR not false = replace with empty

 and also '/^true|^false/' which doesn't seem to work.

 Any ideas to filter this kind of string in just one expression?

 Thanks in advance :)

 --
 Mailed by:
 UnReAl4U - unreal4u
 ICQ #: 54472056
 www1: http://www.chw.net/
 www2: http://unreal4u.com/




-- 
Regards,
Shreyas Agasthya


Re: [PHP] Encoding for W3C Validation

2010-08-03 Thread Shreyas Agasthya
Rick,

Probably Sebastian's fix might work but *htmlspecialchars*  can help you,
too.

Regards,
Shreyas

On Wed, Aug 4, 2010 at 12:17 AM, Sebastian Ewert seb2...@yahoo.de wrote:

 Rick Dwyer wrote:
  Hello List.
 
  In the Alt section of the IMG tag below, the variable $myitem has a value
 of Who's There.
 
  echo div class='myclass'a href='#' class='color_thumb' img
 src='/itemimages/$mypic' alt='$myitem' width='60' 
 
  When running through W3C validator, the line errors out because of the 
 '  in Who's.
  I tried:
  $myitem=(htmlentities($myitem));
 
  But this has no affect on Who's.
 
  What's the best way to code this portion so the apostrophe is handled
 correctly?
 
 
  TIA,
 
  --Rick
 
 
 
 
 Use it


 echo 'div class=myclassa href=# class=color_thumb img
 src=/itemimages/'.$mypic.' alt='.$myitem.' width=60 ...'

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


Re: [PHP] opening link in new window

2010-07-23 Thread Shreyas Agasthya
I am not sure how PHP can help here. I am sure there must be a way out.

With JavaScript, it s certainly possible. You can try window.open() to make
this happen. It can accept a lot of parameters and a google search should
give you a lot of answers.

--Shreyas

On Fri, Jul 23, 2010 at 10:58 AM, David Mehler dave.meh...@gmail.comwrote:

 Hello,
 I've got a page with an external link. I'd like to open it in a new
 window, but i'm using the xhtml 1.0 strict dtd so this isn't possible.
 I was wondering if php could pull this off? Failing that, and not
 really wanting to go there, would javascript work for this?
 Thanks.
 Dave.

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


Re: [PHP] MySQL Query Puzzle

2010-07-20 Thread Shreyas Agasthya
I am very keen to see a closure to this thread so that I can add to my
snippets.
Let's all know what worked best out of many solutions that have been
proposed.

--Shreyas

On Tue, Jul 20, 2010 at 10:07 AM, Jim Lucas li...@cmsws.com wrote:

 Peter wrote:

 Hi All,

 I have a  table which contain's some duplicate rows. I just want to delete
 the duplicate records alone
 not original records.

 Assume my table as look as below

 column1 column2
 1
a
 1
a
 2
b
 3
c
 3
c



 i want the above table need  to be as below, After executing the mysql
 query.

 column1
column2
 1
a
 2
b
 3
c




 Thanks in advance..

 Regards
 Peter


 Use the SQL command alter with the ignore flag.

 ALTER IGNORE TABLE `your_table` ADD UNIQUE ( `column1` , `column2` )

 I tested this on my test DB and it worked fine.  It erased all the
 duplicates and left one instance of the multiple entry values.

 This will add a permanent unique restraint to the table.  So, you will
 never have dupps again.

 Jim Lucas

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


Re: [PHP] functions and global variables

2010-07-19 Thread Shreyas Agasthya
My two cents on this one.

Modify the $name within the function and print it.

Modify the$name outside the function (means the non-global-declared $name)
and print it. You will know the difference.

--Shreyas

On Mon, Jul 19, 2010 at 7:41 AM, Paul M Foster pa...@quillandmouse.comwrote:

 On Sun, Jul 18, 2010 at 06:37:30PM -0400, David Mehler wrote:

  Hello,
  I've got a file with a variable declared in it. For purposes of this
 post:
 
  $name = $_POST['name'];
 
  Now a little later in the same file I have a custom function call that
  outputs some information. In that information is an echo statement
  outputting $name:
 
  echo $name;
 
  I'm wondering do I have to have $name declared as a global variable
  within that function? For example:
 
  function customFunction() {
  global $name
  }
 
  I've tried it both ways and both ways it works, with and without the
  global statement. I was under the impression that to be useful in a
  function variables outside were not accessible.
  Thanks.
  Dave.

 Variables declared outside a function are visible outside the function.
 Variables declared inside a function are visible only within that
 function. To use a global variable inside a function, you must declare
 it global, as:

 global $globalvar;

 Paul

 --
 Paul M. Foster

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


Re: [PHP] MySQL Query Puzzle

2010-07-19 Thread Shreyas Agasthya
How about this :

CREATE TEMPORARY TABLE bad_temp1 (id INT,name VARCHAR(20));
INSERT INTO bad_temp1 (id,name) SELECT DISTINCT id,name FROM SAMPLE;

Regards,
Shreyas

On Mon, Jul 19, 2010 at 7:31 PM, Richard Quadling rquadl...@gmail.comwrote:

 On 19 July 2010 05:44, Peter pet...@egrabber.com wrote:
  Hi All,
 
  I have a  table which contain's some duplicate rows. I just want to
 delete
  the duplicate records alone
  not original records.
 
  Assume my table as look as below
 
  column1 column2
  1
 a
  1
 a
  2
 b
  3
 c
  3
 c
 
 
 
  i want the above table need  to be as below, After executing the mysql
  query.
 
  column1
 column2
  1
 a
  2
 b
  3
 c
 
 
 
 
  Thanks in advance..
 
  Regards
  Peter
 

 If your table had a db generated sequential unique identifier (an
 identity / autoinc), then something along these lines may be what you
 are looking for ...

 -- Delete everything except the UniqueIDs we want to keep.
 DELETE FROM
Table
 WHERE
UniqueID NOT IN
(
-- Just get the UniqueIDs we want to keep.
SELECT
UniqueID
FROM
(
-- Get the earlist UniqueID for each Col1, Col2,
 pairing.
SELECT
Col1,
Col2,
MIN(UniqueID) AS UniqueID
FROM
Table
GROUP BY
Col1,
Col2
)
)

 UNTESTED

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


Re: [PHP] Recent Influx of Unrelated Discussions

2010-07-19 Thread Shreyas Agasthya
I completely agree with Dan's voice. I hear the tone.  I am sure most of us
here would spend a lot of time here to help each other out. Why not spend
time on genuine PHP issues?

Outside the scope of the discussion :

Also, once they implement and get things working, I would like to request
all the members to let us know the code or even the pseudo-code to let us
know how they made it work. We can collect those snippets and also ask
not repeated questions.

Regards,
Shreyas

On Sat, Jul 17, 2010 at 7:43 AM, Jason Pruim li...@pruimphotography.comwrote:


 On Jul 16, 2010, at 10:47 AM, Paul M Foster wrote:

  On Fri, Jul 16, 2010 at 11:59:49AM +0200, Arno Kuhl wrote:

  And Daniel, your own
 gentle prods to keep things on track I think sets some of the
 professional
 tone of the list.


 This is very true. I've administered various lists for almost ten years,
 and I know for a fact that the list administrator plays a tremendous
 role in the tone of a list.



 So... By replying to this thread... Are we helping the problem or making it
 worse by adding to the off topic posts? :P

 Happy Friday yall! :)


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


Re: [PHP] I need me a Good Book for PHP

2010-07-19 Thread Shreyas Agasthya
Joce,

6 mouth? I assume it's months. :)
You can choose Head First with PHP and MySQL. Very good and I am currently
learning form it; I am no veteran with the language but it's AWESOME.

Also, good to know (for the PHP-veterans) will be :

1. Why are you learning PHP?
2. How do you plan to put your learning to usage?
3. Any specific things that you want to achieve from PHP?

Regards,
Shreyas

On Mon, Jul 19, 2010 at 9:24 PM, Joce Jovanov jovanovj...@gmail.com wrote:

 Hello,

 I work only 6 mouth with PHP, and now star to like more and more. Do you
 someone know samo good books (tutorials) for PHP and MySQL.
  Thanks

 Best Regard
 Jovanov Jordan




-- 
Regards,
Shreyas Agasthya


Re: [PHP] MySQL Query Puzzle

2010-07-19 Thread Shreyas Agasthya
Just to add more perspective :

You will have a table with DISTINCT values.

Drop the initial table (better take a back-up); copy from the temporary
table which will have only DISTINCT values.

Regards,
Shreyas

On Mon, Jul 19, 2010 at 7:58 PM, Shreyas Agasthya shreya...@gmail.comwrote:

 How about this :

 CREATE TEMPORARY TABLE bad_temp1 (id INT,name VARCHAR(20));
 INSERT INTO bad_temp1 (id,name) SELECT DISTINCT id,name FROM SAMPLE;

 Regards,
 Shreyas

 On Mon, Jul 19, 2010 at 7:31 PM, Richard Quadling rquadl...@gmail.comwrote:

 On 19 July 2010 05:44, Peter pet...@egrabber.com wrote:
  Hi All,
 
  I have a  table which contain's some duplicate rows. I just want to
 delete
  the duplicate records alone
  not original records.
 
  Assume my table as look as below
 
  column1 column2
  1
 a
  1
 a
  2
 b
  3
 c
  3
 c
 
 
 
  i want the above table need  to be as below, After executing the mysql
  query.
 
  column1
 column2
  1
 a
  2
 b
  3
 c
 
 
 
 
  Thanks in advance..
 
  Regards
  Peter
 

 If your table had a db generated sequential unique identifier (an
 identity / autoinc), then something along these lines may be what you
 are looking for ...

 -- Delete everything except the UniqueIDs we want to keep.
 DELETE FROM
Table
 WHERE
UniqueID NOT IN
(
-- Just get the UniqueIDs we want to keep.
SELECT
UniqueID
FROM
(
-- Get the earlist UniqueID for each Col1, Col2,
 pairing.
SELECT
Col1,
Col2,
MIN(UniqueID) AS UniqueID
FROM
Table
GROUP BY
Col1,
Col2
)
)

 UNTESTED

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




 --
 Regards,
 Shreyas Agasthya




-- 
Regards,
Shreyas Agasthya


Re: [PHP] Serial Numbers

2010-07-12 Thread Shreyas Agasthya
Perhaps using a static variable might help? I am just guessing.

--Shreyas

On Tue, Jul 13, 2010 at 12:22 AM, Gary gp...@paulgdesigns.com wrote:

 I'm sure it is possible, but I am unsure how to do this.  I have created a
 Sale coupon that I was going to put up on a site that I manage, for
 visitors
 to print out and bring to the store. The coupon is currently a .png,
 however
 I was planning on converting to a pdf.  I would like to put on the coupon a
 serial number that increases by 1 everytime the page is viewed. I dont
 really care if someone refreshes the page and skews the numbers.

 Is this possible and could someone give me some help?

 Thanks

 Gary



 __ Information from ESET Smart Security, version of virus signature
 database 5273 (20100712) __

 The message was checked by ESET Smart Security.

 http://www.eset.com





 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


Re: [PHP] form validation and error display

2010-07-05 Thread Shreyas Agasthya
Ash - Thanks for correcting me [should I say us ;) ]. So, if my understandng
is right, we should use # instead of the superglobal variable.

David - Sorry to have written that. I was not aware of the implications of
the grand old way of doing it. :)

Regards,
Shreyas

On Mon, Jul 5, 2010 at 4:24 AM, Ashley Sheridan 
a...@ashleysheridan.co.ukwrote:

 On Sun, 2010-07-04 at 18:23 -0400, David Mehler wrote:

  Hello everyone,
  Thanks for your suggestions.
  For my variable in the value area of the text input field I enter
 
  value=?php echo $name; ?
 
  Prior to this I assign the variable $name to:
 
  $name = stripslashes($_POST['name']);
 
  I hope this is correct.
  Sticky forms sounds exactly what i'm looking for. I've changed my
  action attribute to
 
  ?php echo $_SERVER['PHP_SELF']; ?
 
  The first thing I do once the page is loaded is check whether or not
  submit is set, if it is not I display the form, which is in a function
  call. If submit is set I want to begtin validation, so i'm deciding to
  merge my two files in to one, I like this better. My question is say
  for example the name text field is not filled out but all the other
  required fields are how do I get the form to redisplay itself? I was
  thinking a location redirect, but this doesn't sound right.
  Thanks.
  Dave.
 
 
  On 7/4/10, Paul M Foster pa...@quillandmouse.com wrote:
   On Sun, Jul 04, 2010 at 01:57:01PM -0400, David Mehler wrote:
  
   Hello,
   I've got a form with several required fields of different types. I
   want to have the php script process it only when all the required
   fields are present, and to redisplay the form with filled in values on
   failure so the user won't have to fill out the whole thing again.
   One of my required fields is a text input field called name. If it's
   not filled out the form displayed will show this:
  
   input type=text name=name id=name size=50 value=?php
   echo($name); ? / br /
  
   Note, I've got $_POST* variable processing before this so am assigning
   that processing to short variables.
   If that field is filled out, but another required one is not that form
   field will fill in the value entered for the name field.
   This is working for my text input fields, but not for either select
   boxes or textareas. Here's the textarea also a required field:
  
   textarea name=description id=description cols=50 rows=10
   value=?php echo($description); ?/textarea
  
   Textarea fields don't work this way. To display the prior value, you
   have to do this:
  
   textarea name=description?php echo $description; ?/textarea
  
  
   What this does, if a user fills out this field, but misses another, it
   should echo the value of what was originally submitted. It is not
   doing this. Same for my select boxes, here's one:
  
   select name=type id=type value=?php echo($type); ?
   option value=0 selected=selected-- select type --/option
   option value=meeting - Meeting - /option
   option value=event - Event - /option
   /select
  
   The value attribute of a select field won't do this for you. You have
   to actually set up each option with an either/or choice, like this:
  
   option value=0 ?php if ($type == 'meeting') echo
 'selected=selected';
   ? - Meeting - /option
  
   Since doing this is pretty tedious, I use a function here instead:
  
   function set_selected($fieldname, $value)
   {
   if ($_POST[$fieldname] == $value)
   echo 'selected=selected';
   }
  
   And then
  
   option value=meeting ?php set_selected('type', 'meeting');
   ?Meeting/option
  
   HTH,
  
   Paul
  
   --
   Paul M. Foster
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 


 $_SERVER['PHP_SELF'] is not to be trusted, and shouldn't be used as the
 action of a form like this.
 http://www.mc2design.com/blog/php_self-safe-alternatives explains it all
 better than I can here, so it's worth a read, but it does list safe
 alternatives.

 One thing I do when creating sticky select lists is this:

 $colours = array('red', 'green', 'blue', 'yellow', 'pink');

 echo 'select name=colour';
 for($i=0; $icount($colours); $i++)
 {
$selected = (isset($_POST['colour'])  $_POST['colour'] ==
 $i)?'selected=selected':'';
echo option value=\$i\ $selected{$colours[$i]}/option;
 }
 echo '/select';

 Basically, this uses PHP to not only output the list from an array
 (which itself can be populated from a database maybe) and select the
 right option if it exists in the $_POST array and matches the current
 option in the loop that's being output.

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk





-- 
Regards,
Shreyas Agasthya


Re: [PHP] form validation and error display

2010-07-04 Thread Shreyas Agasthya
David,

If I understand your problem/issue here, you are talking about something
called 'sticky forms'.
This means -
(i) the form references itself.
(ii) that the form knows what the previous data was when it encounters any
validation issues.

You achieve (i) and (ii) by re-submitting the form with the usage of a
superglobal variable called $_SERVER['PHP_SELF'].

form method='POST' action =php echo $_SERVER['PHP_SELF'] ? 

Regards,
Shreyas


On Sun, Jul 4, 2010 at 11:27 PM, David Mehler dave.meh...@gmail.com wrote:

 Hello,
 I've got a form with several required fields of different types. I
 want to have the php script process it only when all the required
 fields are present, and to redisplay the form with filled in values on
 failure so the user won't have to fill out the whole thing again.
 One of my required fields is a text input field called name. If it's
 not filled out the form displayed will show this:

 input type=text name=name id=name size=50 value=?php
 echo($name); ? / br /

 Note, I've got $_POST* variable processing before this so am assigning
 that processing to short variables.
 If that field is filled out, but another required one is not that form
 field will fill in the value entered for the name field.
 This is working for my text input fields, but not for either select
 boxes or textareas. Here's the textarea also a required field:

 textarea name=description id=description cols=50 rows=10
 value=?php echo($description); ?/textarea

 What this does, if a user fills out this field, but misses another, it
 should echo the value of what was originally submitted. It is not
 doing this. Same for my select boxes, here's one:

 select name=type id=type value=?php echo($type); ?
 option value=0 selected=selected-- select type --/option
 option value=meeting - Meeting - /option
 option value=event - Event - /option
 /select

 I'd also like for any not entered required fields to have an error box
 around them, I've got a css class to handle this, but am not sure how
 to tie it in to the fields since any one of the required fields could
 not be filled in.
 I'd appreciate any help.
 Thanks.
 Dave.

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


Re: [PHP] Integers

2010-07-01 Thread Shreyas Agasthya
It would also mean that 7 (8 digits which includes 0) is the highest numeric
representation that you can have or go up to in an octal representation.

So to take your example and represent an octal number :

00100010 (subscript 2) = 1057(subscript 8)

--Shreyas

On Thu, Jul 1, 2010 at 7:42 AM, Stephen stephe...@rogers.com wrote:

 On 10-06-30 10:02 PM, David McGlone wrote:

 Hi again

 I'm trying to learn about octal numbers and I don't understand this:

 Binary: 00100010
 breakdown: (001)= 1 (000)= 0 (101)=5 (111)=7

 I know it's similar to unix permissions, but I'm not understanding where
 for
 example: 111 = 7


 In base 10, which you use every day, we go
 0
 1
 2
 3
 4
 5
 6
 7
 8
 9
 10

 The number 10 is the number of distinct digits we use.

 In binary we only us two, 0 and 1, so 10 is 2 decimal

 So we go

 0 = 0 decimal
 1 = 1  important
 10 = 2  important
 11 = 3
 100 = 4  important
 101 = 5
 110 = 6
 111 = 7

 So binary 111 is 4 + 2 + 1 = 7

 Stephen


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


[PHP] mail() + localhost

2010-07-01 Thread Shreyas Agasthya
PHP'ers,

I am sure this would have been asked a zillion times but I take this as my
turn to get some help. I hate to ask such rhetorical questions but quite
couldn't understand how to tweak this.

All I am trying to do is send a mail from my localhost to my Gmail ID. I
read stuff about how the SMTP port should be accessible; should be open et
al. My set-up is very simple:

1. Using Easy PHP.
2. Windows XP

Also, when the comment says that you need to 'configure' your php.ini, which
.ini should I modify? The reason being, I see that file in two locations,
apparently.
(i) C:\Program Files\EasyPHP 3.0\apache
(ii) C:\Program Files\EasyPHP 3.0\conf_files


*My php.ini (will remove the semi-colon)*
*
*
; For Win32 only.
;SMTP = localhost
;smtp_port = 25

; For Win32 only.
;sendmail_from = m...@example.com

*My  code: *
*
*
*
?php
*

$from= shreya...@gmail.com;
$to =shreya...@gmail.com;
$subject = PHP Testing;
$message = Test Me;
mail ($to,$subject,$message,'From:'.$from);
?
*
*
*
Regards,
*Shreyas Agasthya


Re: [PHP] mail() + localhost

2010-07-01 Thread Shreyas Agasthya
Erm... understood.

I modified the changes to look like this in the php.ini file (the right
one based on the output of phpinfo()).

3)
*smtp = smtp.gmail.com*
*smtp_port = 587*
*
*
*I get : Failed to connect to mailserver at localhost port 587, verify
your SMTP and smtp_port setting in php.ini*
*
*
Regards,
Shreyas

On Thu, Jul 1, 2010 at 7:03 PM, Daniel Brown danbr...@php.net wrote:

 On Thu, Jul 1, 2010 at 09:09, Shreyas Agasthya shreya...@gmail.com
 wrote:
 
  All I am trying to do is send a mail from my localhost to my Gmail ID. I
  read stuff about how the SMTP port should be accessible; should be open
 et
  al. My set-up is very simple:
 
  1. Using Easy PHP.
  2. Windows XP

 3.) An SMTP server, I hope...?

  Also, when the comment says that you need to 'configure' your php.ini,
 which
  .ini should I modify? The reason being, I see that file in two locations,
  apparently.
  (i) C:\Program Files\EasyPHP 3.0\apache
  (ii) C:\Program Files\EasyPHP 3.0\conf_files

 In a browser, check the output of phpinfo() - specifically, the
 value for Loaded Configuration File - and modify that, as the other
 may be for the PHP CLI, another installed component using a local
 override, or may not even be used at all.

  *My php.ini (will remove the semi-colon)*
  *
  *
  ; For Win32 only.
  ;SMTP = localhost
  ;smtp_port = 25

 Uncomment the two lines above.

  ; For Win32 only.
  ;sendmail_from = m...@example.com

 You don't *need* to uncomment and set the `sendmail_from` option,
 as long as you set an explicit `From` header in your code.  More on
 that after your snippet.

  *My  code: *
  *
  *
  *
  ?php
  *
 
  $from= shreya...@gmail.com;
  $to =shreya...@gmail.com;
  $subject = PHP Testing;
  $message = Test Me;
  mail ($to,$subject,$message,'From:'.$from);
  ?

 Your code should be modified just a bit for better conformance and
 portability, but I understand that you're just using it as a test.
 After following the suggestions above (and remembering to restart
 Apache, of course), try this:

 ?php

  $from = sherya...@gmail.com;

  // Gmail allows (\+[a-z0-9\.\-_]+) appended to your username to
 filter emails in your Gmail box.
  $to = shreyasbr+phpt...@gmail.com shreyasbr%2bphpt...@gmail.com;

  // This will append (at the moment, my local time) 1 Jul 2010, 09:27:23
  $subject = PHP Testing .date(j M Y, H:i:s);

  $message = Test Me.;

  // Create your headers, remembering to terminate each line with CRLF
 (\r\n) to comply with RFC [2]821.
  $headers  = From: .$from.\r\n;
  $headers .= X-Mailer: PHP/.phpversion().\r\n;

  // Send it, or inform us of an error.  No need to use a -f flag here.
  if (!mail($to,$subject,$body,$headers)) {
echo Ah, crap.  Something's SNAFU'd here.;
exit(-1);
  }
 ?

 --
 /Daniel P. Brown
 UNADVERTISED DEDICATED SERVER SPECIALS
 SAME-DAY SETUP
 Just ask me what we're offering today!
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/




-- 
Regards,
Shreyas Agasthya


Re: [PHP] mail() + localhost

2010-07-01 Thread Shreyas Agasthya
Spoke too fast.

Fixed that (SMTP has to be uppercase)

Now it is : *SMTP server response: 530 5.7.0 Must issue a STARTTLS command
first. c15sm7128213rvi.11*

On Thu, Jul 1, 2010 at 7:25 PM, Shreyas Agasthya shreya...@gmail.comwrote:

 Erm... understood.

 I modified the changes to look like this in the php.ini file (the right
 one based on the output of phpinfo()).

 3)
 *smtp = smtp.gmail.com*
 *smtp_port = 587*
 *
 *
 *I get : Failed to connect to mailserver at localhost port 587, verify
 your SMTP and smtp_port setting in php.ini*
 *
 *
 Regards,
 Shreyas

 On Thu, Jul 1, 2010 at 7:03 PM, Daniel Brown danbr...@php.net wrote:

 On Thu, Jul 1, 2010 at 09:09, Shreyas Agasthya shreya...@gmail.com
 wrote:
 
  All I am trying to do is send a mail from my localhost to my Gmail ID. I
  read stuff about how the SMTP port should be accessible; should be open
 et
  al. My set-up is very simple:
 
  1. Using Easy PHP.
  2. Windows XP

 3.) An SMTP server, I hope...?

  Also, when the comment says that you need to 'configure' your php.ini,
 which
  .ini should I modify? The reason being, I see that file in two
 locations,
  apparently.
  (i) C:\Program Files\EasyPHP 3.0\apache
  (ii) C:\Program Files\EasyPHP 3.0\conf_files

 In a browser, check the output of phpinfo() - specifically, the
 value for Loaded Configuration File - and modify that, as the other
 may be for the PHP CLI, another installed component using a local
 override, or may not even be used at all.

  *My php.ini (will remove the semi-colon)*
  *
  *
  ; For Win32 only.
  ;SMTP = localhost
  ;smtp_port = 25

 Uncomment the two lines above.

  ; For Win32 only.
  ;sendmail_from = m...@example.com

 You don't *need* to uncomment and set the `sendmail_from` option,
 as long as you set an explicit `From` header in your code.  More on
 that after your snippet.

  *My  code: *
  *
  *
  *
  ?php
  *
 
  $from= shreya...@gmail.com;
  $to =shreya...@gmail.com;
  $subject = PHP Testing;
  $message = Test Me;
  mail ($to,$subject,$message,'From:'.$from);
  ?

 Your code should be modified just a bit for better conformance and
 portability, but I understand that you're just using it as a test.
 After following the suggestions above (and remembering to restart
 Apache, of course), try this:

 ?php

  $from = sherya...@gmail.com;

  // Gmail allows (\+[a-z0-9\.\-_]+) appended to your username to
 filter emails in your Gmail box.
  $to = shreyasbr+phpt...@gmail.com shreyasbr%2bphpt...@gmail.com;

  // This will append (at the moment, my local time) 1 Jul 2010, 09:27:23
  $subject = PHP Testing .date(j M Y, H:i:s);

  $message = Test Me.;

  // Create your headers, remembering to terminate each line with CRLF
 (\r\n) to comply with RFC [2]821.
  $headers  = From: .$from.\r\n;
  $headers .= X-Mailer: PHP/.phpversion().\r\n;

  // Send it, or inform us of an error.  No need to use a -f flag here.
  if (!mail($to,$subject,$body,$headers)) {
echo Ah, crap.  Something's SNAFU'd here.;
exit(-1);
  }
 ?

 --
 /Daniel P. Brown
 UNADVERTISED DEDICATED SERVER SPECIALS
 SAME-DAY SETUP
 Just ask me what we're offering today!
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/




 --
 Regards,
 Shreyas Agasthya




-- 
Regards,
Shreyas Agasthya


Re: [PHP] mail() + localhost

2010-07-01 Thread Shreyas Agasthya
Not sure where I am top-posting. I posted to my own mail so that one gets to
know the latest. Nevertheless, I wouldn't go against the guidelines as I
completely understand the havoc that it can create.

The port is 587 as per Google; SMTP that I am using
is Google's (anything wrong here?). If there is a rudimentary mistake that I
am doing, please guide me.

Regards,
Shreyas

On Thu, Jul 1, 2010 at 7:46 PM, Daniel Brown danbr...@php.net wrote:

 On Thu, Jul 1, 2010 at 10:02, Shreyas Agasthya shreya...@gmail.com
 wrote:
  Spoke too fast.
 
  Fixed that (SMTP has to be uppercase)
 
  Now it is : *SMTP server response: 530 5.7.0 Must issue a STARTTLS
 command
  first. c15sm7128213rvi.11*

(Quick note: per the list guidelines, please don't top-post in threads.)

That error message is because you're trying to connect to an SMTPS
 (secure, SSL-encrypted SMTP) server using plain text, which won't
 work.  If you have a plain SMTP server running, try that to get one
 thing resolved at a time.  Change the port to 25 in your php.ini (and,
 again, restart Apache) if plain SMTP is available on the default port.

 --
 /Daniel P. Brown
 UNADVERTISED DEDICATED SERVER SPECIALS
 SAME-DAY SETUP
 Just ask me what we're offering today!
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/




-- 
Regards,
Shreyas Agasthya


Re: [PHP] mail() + localhost

2010-07-01 Thread Shreyas Agasthya
Trying again; most likely I cannot do this without SSL.

--Shreyas

On Thu, Jul 1, 2010 at 8:42 PM, Shreyas Agasthya shreya...@gmail.comwrote:

 Not sure where I am top-posting. I posted to my own mail so that one gets
 to know the latest. Nevertheless, I wouldn't go against the guidelines as I
 completely understand the havoc that it can create.

 The port is 587 as per Google; SMTP that I am using
 is Google's (anything wrong here?). If there is a rudimentary mistake that I
 am doing, please guide me.

 Regards,
 Shreyas

 On Thu, Jul 1, 2010 at 7:46 PM, Daniel Brown danbr...@php.net wrote:

 On Thu, Jul 1, 2010 at 10:02, Shreyas Agasthya shreya...@gmail.com
 wrote:
  Spoke too fast.
 
  Fixed that (SMTP has to be uppercase)
 
  Now it is : *SMTP server response: 530 5.7.0 Must issue a STARTTLS
 command
  first. c15sm7128213rvi.11*

(Quick note: per the list guidelines, please don't top-post in
 threads.)

That error message is because you're trying to connect to an SMTPS
 (secure, SSL-encrypted SMTP) server using plain text, which won't
 work.  If you have a plain SMTP server running, try that to get one
 thing resolved at a time.  Change the port to 25 in your php.ini (and,
 again, restart Apache) if plain SMTP is available on the default port.

 --
 /Daniel P. Brown
 UNADVERTISED DEDICATED SERVER SPECIALS
 SAME-DAY SETUP
 Just ask me what we're offering today!
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/




 --
 Regards,
 Shreyas Agasthya




-- 
Regards,
Shreyas Agasthya


Re: [PHP] form validation code

2010-06-30 Thread Shreyas Agasthya
http://www.php.net/manual/en/types.comparisons.php

http://www.php.net/manual/en/types.comparisons.phpThe first table actually
gives a very good understanding.

--Shreyas

On Wed, Jun 30, 2010 at 7:05 PM, Richard Quadling rquadl...@gmail.comwrote:

 On 30 June 2010 14:23, Daniel P. Brown daniel.br...@parasane.net wrote:
 (Hint: isset != empty)

 More importantly ...

 isset != !empty

 $a = Null;
 $b = '';
 // $c = undefined;
 $d = 'Hello';

 isset($a) = False vs True  = empty($a)
 isset($b) = True  vs True  = empty($b)
 isset($c) = False vs True  = empty($c)
 isset($d) = True  vs False = empty($d)



 --
 -
 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




-- 
Regards,
Shreyas Agasthya


[PHP] Info : Regular Expressions Website.

2010-06-29 Thread Shreyas Agasthya
Team,

I came across this website which can be very helpful to all of us when we
are struggling to get the Regex right. I just started using it and seems
very helpful.

http://www.gskinner.com/RegExr/

Regards,
Shreyas Agasthya


Re: [PHP] Array form processing

2010-06-29 Thread Shreyas Agasthya
The painDesc array is what that should be iterated.

--Shreyas

On Wed, Jun 30, 2010 at 2:27 AM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

 On Tue, 2010-06-29 at 16:54 -0400, Ron Piggott wrote:

  I am trying to process a form where the user uses checkboxes:
 
  input type=checkbox name=painDesc[] value=1 /Sharp
  input type=checkbox name=painDesc[] value=2 /Stabbing
  input type=checkbox name=painDesc[] value=3 /Jabbing
 
  When I do:
 
  foreach($_REQUEST as $key = $val) {
   $$key = $val;
 echo $key . :  . $val . br;
  }
 
  The output is:
 
  painDesc: Array
 
  I need to know the values of the array (IE to know what the user is
  checking), not that there is an array.  I hope to save these values to
 the
  database.
 
  Thank you.
 
  Ron
 
 


 You need to iterate that array, as that holds the values of everything
 sent by the browser

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk





-- 
Regards,
Shreyas Agasthya


Re: [PHP] Attachment to email from form.

2010-06-28 Thread Shreyas Agasthya
I have got one, too.



On Mon, Jun 28, 2010 at 7:34 PM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

 On Mon, 2010-06-28 at 09:58 -0400, Andrew Ballard wrote:

  On Mon, Jun 28, 2010 at 8:53 AM, Richard Quadling rquadl...@gmail.com
 wrote:
   On 28 June 2010 13:44, Brandon Rampersad brandon.add...@gmail.com
 wrote:
   f**k no
  
   Enlightened criticism aside, why not? Or rather (as I'm willing to
 adapt) how?
 
  Probably because you ignored his latest request to chat. Just guessing,
 really.
 
  Andrew
 


 No, he often emails the list with random insults. He's emailed me
 personally a couple of times too in response to a list email. Normally
 I'd keep this off list, but as it's been going on for so long, and
 others have noticed it too, figured his off-list behaviour should be
 mentioned as well.

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk





-- 
Regards,
Shreyas Agasthya


Re: [PHP] Warning messages on web page.

2010-06-23 Thread Shreyas Agasthya
Mike,

Little weird. I executed the same lines of code against my sample database
and did not got any warning. You might want to send the code for projects
and news to do any comparison?
*[I will silently wait for the PHP demi-gods (the Ashleys, the Pauls et al)
at hover their vigilant eyes on your lines .:) ]*

Regards,
Shreyas

On Wed, Jun 23, 2010 at 2:48 PM, Mike Davies m...@integrawebdesign.co.ukwrote:


 The only earlier reference to $thumbsarray is in the first lines of the
 file :

 ?php
 mysql_select_db($database_general, $general);
 $query_details = SELECT * FROM news WHERE news_id = '$_GET[id]';
 $details = mysql_query($query_details, $general) or die(mysql_error());
 $row_details = mysql_fetch_assoc($details);
 $totalRows_details = mysql_num_rows($details);

 mysql_select_db($database_general, $general);
 $query_thumbs = SELECT * FROM news_thumbs;
 $thumbs = mysql_query($query_thumbs, $general) or die(mysql_error());
 $totalRows_thumbs = mysql_num_rows($thumbs);
 $i = 1;
 while ($row_thumbs = mysql_fetch_assoc($thumbs)){
 $thumbsarray[$i] = $row_thumbs;
 $i++;
 }

 //print_r($thumbsarray);
 ?

 This is exactly the same as the code which is working for the 'projects'
 pages.

 Mike

 --
 Mike Davies
 Integra Web Design, Rhynie, By Huntly, AB54 4LS
 01464 861535www.integrawebdesign.co.uk


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


Re: [PHP] Warning messages on web page.

2010-06-22 Thread Shreyas Agasthya
Mike,

A couple of things that I could understand reading carefully at the error.

1. reset takes an array as the input and perhaps your $thumbsarray is *not *an
array? Reset will set the internal pointer to the start of the array.

2. Warning # 2 is very closely related to #1 since you can iterate on an
array and not on a variable.

3. Just FYI - You can control the behavior should or not these
warnings/notices/errors in your php.ini file. Do a quick google and you
should be happy to see the result.

Regards,
Shreyas

On Tue, Jun 22, 2010 at 7:47 PM, Mike Davies m...@integrawebdesign.co.ukwrote:

 Hello,

 This is my first post to this list and I am a novice at php coding. I
 can generally follow the code but not good at writing from scratch.


 I have recently been trying to add to a website which was originally
 developed by someone else and is written in php and mysql. I am trying
 to add a 'news' section to the site. This would be similar to an
 existing 'projects' section so, rather than write it completely from
 scratch I copied the php and the database tables from the 'project'
 section and renamed 'project' to 'news'.


 This is working well except for one thing – I get the following error
 messages when looking at the detailed news item. This code does not
 produce this warning in the project section which is using the same php
 code


 Warning: reset() [function.reset]: Passed variable is not an array or
 object in /home/b23aadf/public_html/news/details.php on line 72

 Warning: Variable passed to each() is not an array or object
 in /home/b23aadf/public_html/news/details.php on line 73


 The relevant lines are :


 72 reset($thumbsarray);

 73 while (list($key, $value) = each($thumbsarray)) {

 The site is at www.aadf.co.uk and select 'News'.

 Is anyone able to help resolve this? If you let me know what further
 information you require I can provide it.


 Mike Davies

 --
 Mike Davies
 Integra Web Design, Rhynie, By Huntly, AB54 4LS
 01464 861535www.integrawebdesign.co.uk


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


Re: [PHP] Stripping Characters

2010-06-22 Thread Shreyas Agasthya
Perhaps, ereg_replace(your regex, replacement_string, String
$variable).

Regards,
Shreyas

On Tue, Jun 22, 2010 at 9:10 PM, Rick Dwyer rpdw...@earthlink.net wrote:

 Hello List.

 I need to remove characters from a string and replace them with and
 underscore.

 So instead of having something like:

 $moditem = str_replace(--,_,$mystring);
 $moditem = str_replace(?,_,$mystring);
 $moditem = str_replace(!,_,$mystring);
 etc.

 For every possible character I can think of, is there a way to simply omit
 any character that is not an alpha character and not a number value from 0
 to 9?


  --Rick



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Regards,
Shreyas Agasthya


Re: [PHP] Stripping Characters

2010-06-22 Thread Shreyas Agasthya
Then, when does one use ereg_replace as against preg_replace? I read from
one the forums that preg_* is faster and ereg_* is if not faster but
simpler.

Is that it?

Regards,
Shreyas



On Tue, Jun 22, 2010 at 9:58 PM, Richard Quadling rquadl...@gmail.comwrote:

 A word character is any letter or digit or the underscore
 character, that is, any character which can be part of a Perl word.
 The definition of letters and digits is controlled by PCRE's character
 tables, and may vary if locale-specific matching is taking place. For
 example, in the fr (French) locale, some character codes greater
 than 128 are used for accented letters, and these are matched by \w.

 The above becomes ...

 _A _word_ character is any letter or digit or the underscore
 character_ that is_ any character which can be part of a Perl _word__
 The definition of letters and digits is controlled by PCRE_s character
 tables_ and may vary if locale_specific matching is taking place_ For
 example_ in the _fr_ _French_ locale_ some character codes greater
 than 128 are used for accented letters_ and these are matched by _w__

 --
 -
 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




-- 
Regards,
Shreyas Agasthya


Re: [PHP] Website content question

2010-06-21 Thread Shreyas Agasthya
Ernie,

I am sure you know none of us could have accessed the link that you have
given there. Can you let us know what code you have written so that one of
us can guide you?

As a broad pitch, your php code has to be either in ?php ? or ? ?

I would wait for your code and other to probe a little more.

Regards,
Shreyas

On Mon, Jun 21, 2010 at 5:11 PM, Ernie Kemp ernie.k...@sympatico.ca wrote:

   This is not a direct PHP question but I will be using PHP in the
 website.



 I go to the php list because the wordpress forum does not respond to my
 questions and I know some of you have a lot of expertise in other areas than
 PHP.



 I wish to a my own pages to a theme.

 I created pages on my PC and added the code at the top of the page for
 wordpress to use the page for a template page.

 I than FTP’d the file over to web hosting server template location.

 Through  wordpress “administrator” I added my file called homepage.php.



 I FTP’d my CSS, images, js and flash folders over to the template location.

 Went to load the website
 http://localhost/Michael-8701/site_flash/wordpress/wp-content/homepage.phpand 
 all I got was the html code displayed.



 I tried moving the folder around but same results.

 Read some docs on this but it’s not clear to me why this will not work.



 Please help this is new to me and I need to get over this wall.

 Thanks,

 /Ernie
















-- 
Regards,
Shreyas Agasthya


Re: [PHP] Date Conversion Problem

2010-06-17 Thread Shreyas Agasthya
David,

I think it would help people like me (newbie) to know the exact statements.
Though I could envisage what you would have done with my current learning,
it would be good if I double check the statements that went there to fix
it.

Regards,
Shreyas

On Thu, Jun 17, 2010 at 7:07 PM, David Stoltz dsto...@shh.org wrote:

 Thanks all - I've fixed the problem.

 I fixed it by updating the php statement to write the date in a true SQL
 date-ready format. Then I updated the invalid rows.

 Thanks all!


 -Original Message-
 From: Richard Quadling [mailto:rquadl...@gmail.com]
 Sent: Thursday, June 17, 2010 8:47 AM
 To: David Stoltz
 Cc: a...@ashleysheridan.co.uk; php-general@lists.php.net
 Subject: Re: [PHP] Date Conversion Problem

 On 17 June 2010 13:40, David Stoltz dsto...@shh.org wrote:
  I would agree with you, but I have no control on inherited web apps.
 
 
 
  I now need to concentrate on trying to fix this.
 
 
 
  From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
  Sent: Thursday, June 17, 2010 8:38 AM
  To: David Stoltz
  Cc: php-general@lists.php.net
  Subject: Re: [PHP] Date Conversion Problem
 
 
 
  On Thu, 2010-06-17 at 08:35 -0400, David Stoltz wrote:
 
 
  PHP newbie here...
 
 
 
  I have some PHP code writing the date/time into a MS SQL 2000 database
  like this:
 
 
 
  date('l jS \of F Y h:i:s A')
 
 
 
  So the text it writes into the DB is like: Thursday 15th of April 2010
  10:13:42 AM
 
 
 
  The database field is defined as varchar, not datetime...so it's a
  string essentially...
 
 
 
  How in the world do I do a date conversion on this? I've tried things
  like:
 
 
 
  select * from table where convert(datetime,fieldname) = '6/10/2010'
 
  (where fieldname is the string in question)
 
 
 
  Which results in Syntax error converting datetime from character
  string.
 
 
 
  So I guess I have two questions:
 
 
 
  1)  Can I write a SQL query that will convert this properly into a
  datetime?
 
  2)  If not, I guess I'll need to change the code to write the date
  differently into the system, how should this statement be changed to
  allow for proper conversion? date('l jS \of F Y h:i:s A')
 
 
 
  Thanks for any help!
 
 
 
  It's best to store the date as a date rather than a string, as it avoids
 the sorts of problems you're seeing now.
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 
 
 
 

 The fix is most likely to be ...

 1 - Convert the string date using PHP's strtotime() function to
 populate a new column on the DB.
 2 - Find the code that inserts/updates the date string and add the new
 column to the insert/update statement.

 That will preserve the current app and allow you to have the new
 column for new work.

 Just remember, if _YOU_ update the new column, you must also update
 the original date string also.

 --
 -
 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




-- 
Regards,
Shreyas Agasthya


Re: [PHP] Multiple Login in a single PC should not be possible

2010-06-15 Thread Shreyas Agasthya
Karl,

Which app are you talking about?

Regards,
Shreyas

On Tue, Jun 15, 2010 at 8:21 AM, Karl DeSaulniers k...@designdrumm.comwrote:

 Hey,
 I just found this app that I think will do your single user login. It is a
 MySQL monitoring app called MySQL Query Analyzer. It has the functionality I
 think you were looking for. Might be worth a look-see.

 :))

 Hth,
 Karl




-- 
Regards,
Shreyas Agasthya