Re: [PHP] Anyone for cookies and milk? :-)
>From the official doc: http://www.php.net/manual/en/function.setcookie.php All the arguments except the name argument are optional. You may also replace an argument with an empty string ("") in order to skip that argument. Because the expire and secure arguments are integers, they cannot be skipped with an empty string, use a zero (0) instead. setcookie("name2","1",0,"",".bestwebhosters.com"); or setcookie("name2","1",0,"",".bestwebhosters.com",0); ;-) "Curt Zirzow" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED] > Ryan A <[EMAIL PROTECTED]> wrote: > > Hey, > > Am just getting into PHP cookies and have gotten a problem...(surprise > > surprise) > > > > Am trying to set a basic cookie to see exactly how things work before I > > start using it in my apps, heres the code i am using: > > (SetCookieEx.php) > > > setcookie("name1","1","","",".bestwebhosters.com"); > > setcookie("name2","1","","",".bestwebhosters.com"); > > > > echo "done"; > > ?> > > > > This is the output I am getting: > > ** > > Warning: setcookie() expects parameter 3 to be long, string given in > > /bestweb/public_html/testing/SetCookieEx.php on line 2 > > > > Warning: setcookie() expects parameter 3 to be long, string given in > > /bestweb/public_html/testing/SetCookieEx.php on line 3 > > done > te> > > > bool setcookie ( string name [, string value [, int expire [, string > path [, string domain [, int secure]) > > [...] > > All the arguments except the name argument are optional. You may also > replace an argument with an empty string ("") > > > at first look this appears to be a bug. but I have a fealing its only > cause your error_reporting is set to E_ALL thus a warning is shown > because the third paramater should be a interger so change it to: > > setcookie("name2","1",0,"",".bestwebhosters.com"); > > mabey documentation should be changed. > > > > > This is how I am trying to read the cookies: (ReadCookieEx.php) > > > > > if (isset($_COOKIE ['name1'])){ > > echo $_COOKIE ['name1']; > > }else{echo "wrong1";} > > > > if (isset($_COOKIE ['name2'])){ > > echo $_COOKIE ['name2']; > > }else{echo "wrong2";} > > ?> > > > > This is the output i am getting: > > *** > > wrong1wrong2 > > hmm.. > > few things: > 1. is your setcookie returning true or false? > 2. have you examined (or even see the cookie get set) the actual cookie >to see > 3. good reading for intro to cookies for programmers: > http://wp.netscape.com/newsref/std/cookie_spec.html > > > > > > > > > Anybody have any ideas? > > > > Cheers, > > -Ryan > > > > Curt > -- > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Using Extensions
Of course on the official page ;-) http://www.php.net/manual/en/funcref.php Each extension defines functions which can easily be recognised by their prefix: example: xslt_create => xslt extension bzwrite => bzip2 extension "Brenton Dobell" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED] > Hello all, > > recently i started haveing a closer look at the heart of the php engine and > found a whole heap of unused extensions :S, where can i look to learn more > about these and how to use them??/ > > Thanks in advance > > Brenton > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Anyone for cookies and milk? :-)
"Ryan A" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED] > Hey, > Am just getting into PHP cookies and have gotten a problem...(surprise > surprise) > > Am trying to set a basic cookie to see exactly how things work before I > start using it in my apps, heres the code i am using: > (SetCookieEx.php) > setcookie("name1","1","","",".bestwebhosters.com"); > setcookie("name2","1","","",".bestwebhosters.com"); > > echo "done"; > ?> > > This is the output I am getting: > ** > Warning: setcookie() expects parameter 3 to be long, string given in > /bestweb/public_html/testing/SetCookieEx.php on line 2 > > Warning: setcookie() expects parameter 3 to be long, string given in > /bestweb/public_html/testing/SetCookieEx.php on line 3 > done Those errors appear because you out "" in the third parameter of the setcookie function. The parser expects a long (or an integer if you prefer ;-) ) This parameter is used to affect the life of the cookie, put 215000, for a one hour cookie. Thanks for the milk :-) > > This is how I am trying to read the cookies: (ReadCookieEx.php) > > if (isset($_COOKIE ['name1'])){ > echo $_COOKIE ['name1']; > }else{echo "wrong1";} > > if (isset($_COOKIE ['name2'])){ > echo $_COOKIE ['name2']; > }else{echo "wrong2";} > ?> > > This is the output i am getting: > *** > wrong1wrong2 > > > > Anybody have any ideas? > > Cheers, > -Ryan > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: MySQL query problems
But what's your prob ? When you say the second one seems to never be executed ... Does the line: $row = mysql_fetch_array($result2); launches a Php Error ? And pay attention, because you're using mysql_fetch_array and mysql_fetch_row, be sure that you are not treating the result in the same way ;-) "Beauford.2005" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED] > Hi, > > Not sure if the problem here is PHP or MySQL, but here we go. I am > trying to do two queries on a database - one after the other, but the > second one never seems to get executed. The two queries are identical > except for two variables. I have checked my form and they are correct > and are being sent to the PHP script the way they should be. > > The variables are $playerto, $playerfrom, $nameto, $namefrom. The 'TO' > query is the one that doesn't work. > > Here is my code. Any help is appreciated. > > if ($namefrom != $nameto) { > if ($playerfrom != $playerto) { > > include("2004server.inc"); > if($error) { > include("trades-input.php"); > exit; > } > > $query1 = "select manager.idn, manager.total, > roster.idp, position, points from roster join reference > join manager where manager.idn=reference.idn and > reference.idp=roster.idp and manager.idn like '$namefrom' and > roster.idp like '$playerfrom'"; > > $result1 = mysql_query($query1) or $mysqlerror = > mysql_error(); > if ($mysqlerror) { > $error = "$d_base_error$email_error"; > include("trades-input.php"); > exit; > } > > $line = mysql_fetch_row($result1); > > mysql_free_result($result1); > > $query2 = "select manager.idn, manager.total, > roster.idp, position, points from roster join reference > join manager where manager.idn=reference.idn and > reference.idp=roster.idp and manager.idn like '$nameto' and > roster.idp like '$playerto'"; > > $result2 = mysql_query($query2) or $mysqlerror = > mysql_error(); > if ($mysqlerror) { > $error = "$d_base_error$email_error"; > include("trades-inputs.php"); > exit; > } > > $row = mysql_fetch_array($result2); > > mysql_free_result($result2); > } > } > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Regex help needed
First, the prob you got : WARNING comes from the following error: (\s+face=\"Verdana, Arial, Helvetica, sans-serif\"|)> After the | (OR) sign, you must define another case, example: echo eregi_replace ("(\s*)\s*\s*purchasing power parity", '%POWER%', 'sdsdssPurchasing power parity'); Secondly, it's right that the \s expression is not recognised in " purchasing\s+power\s+parity " , a little strange, but you can use two different ways instead of '\s': - [[:space:]] - [ ] The brackets allows you to define a sequence of characters patterns (in the second case above, the space character). It will give: echo eregi_replace ("(\s*)\s*\s*purchasing[[:space:]]+power[[:space:]]+parity", '%POWER%', 'sdsdssPurchasing power parity'); Just a little help, you can find on the page http://www.php.net/manual/en/ref.regex.php that could be useful for you: ^ Start of line $ End of line n? Zero or only one single occurrence of character 'n' n* Zero or more occurrences of character 'n' n+ At least one or more occurrences of character 'n' n{2} Exactly two occurrences of 'n' n{2,} At least 2 or more occurrences of 'n' n{2,4} From 2 to 4 occurrences of 'n' . Any single character () Parenthesis to group expressions (.*) Zero or more occurrences of any single character, ie, anything! (n|a) Either 'n' or 'a' [1-6] Any single digit in the range between 1 and 6 [c-h] Any single lower case letter in the range between c and h [D-M] Any single upper case letter in the range between D and M [^a-z] Any single character EXCEPT any lower case letter between a and z. Pitfall: the ^ symbol only acts as an EXCEPT rule if it is the very first character inside a range, and it denies the entire range including the ^ symbol itself if it appears again later in the range. Also remember that if it is the first character in the entire expression, it means "start of line". In any other place, it is always treated as a regular ^ symbol. In other words, you cannot deny a word with ^undesired_word or a group with ^(undesired_phrase). Read more detailed regex documentation to find out what is necessary to achieve this. [_4^a-zA-Z] Any single character which can be the underscore or the number 4 or the ^ symbol or any letter, lower or upper case ?, +, * and the {} count parameters can be appended not only to a single character, but also to a group() or a range[]. therefore, ^.{2}[a-z]{1,2}_?[0-9]*([1-6]|[a-f])[^1-9]{2}a+$ would mean: ^.{2} = A line beginning with any two characters, [a-z]{1,2} = followed by either 1 or 2 lower case letters, _? = followed by an optional underscore, [0-9]* = followed by zero or more digits, ([1-6]|[a-f]) = followed by either a digit between 1 and 6 OR a lower case letter between a and f, [^1-9]{2} = followed by any two characters except digits between 1 and 9 (0 is possible), a+$ = followed by at least one or more occurrences of 'a' at the end of a line. Sid a écrit: Hello, Well I am doing by first reg ex operations and I am having problems which I just cannot figure out. For example I tried echo eregi_replace ("(\s*)\s*\s*purchasing power parity", '%POWER%', 'sdsdssPurchasing power parity'); and this worked perfectly, but when I chnaged that to echo eregi_replace ("(\s*)\s*\s*purchasing\s+power\s+parity", '%POWER%', 'sdsdssPurchasing power parity'); It does not detect the string. Srange. According to what I know, \s+ will detect a single space also. I tried chnaging the last 2 \s+ to \s* but this did not work also. Any ideas on this one? As I proceed I would like the expression to detect the optional face attribute also, so I tried echo eregi_replace ("(\s*)\s*\s*purchasing power parity", '%POWER%', 'sdsdssPurchasing power parity'); ... and this gave me an error like Warning: eregi_replace(): REG_EMPTY:çempty (sub)expression in D:\sid\dg\test.php on line 2 Any ideas? BTW any place where I can get started on regex? I got a perl book that explains regex, but I have got to learn perl first (I dont know any perl) Thanks in advance. - Sid Sid a écrit: Hello, Well I am doing by first reg ex operations and I am having problems which I just cannot figure out. For example I tried echo eregi_replace ("(\s*)\s*\s*purchasing power parity", '%POWER%', 'sdsdssPurchasing power parity'); and this worked perfectly, but when I chnaged that to echo eregi_replace ("(\s*)\s*\s*purchasing\s+power\s+parity", '%POWER%', 'sdsdssPurchasing power parity'); It does not detect the string. Srange. According to what I know, \s+ will detect a single space also. I tried chnaging the last 2 \s+ to \s* but this did not work also. Any ideas on this one? As I proceed I would like the expression to detect the optional face attribute also, so I tried echo eregi_replace ("(\s*)\s*\s*purchasing power parity", '%POWER%', 'sdsdssPurchasing power parity'); ... and this gave me an error like Warning: eregi_replace(): REG_EMPTY:çempty (sub)expression in D:\sid\dg\test.php on line 2 Any ideas? BTW any place where I can get started
Re: [PHP] Regex and variable usage
Gerard Samuel a écrit: Curt Zirzow wrote: Gerard Samuel <[EMAIL PROTECTED]> wrote: or even preg_match('/^[a-z0-9\-_\.]+\.[a-z0-9]{' . $foo . ', ' . $bar . '}$/', $some_string) I think, you Forgot, a \ before the $ at the end of the expression... that should work. Unfortunately it doesn't for some reason. Don't know why. but you could do this: $pattern = "/^[a-z0-9\-_\.]+\.[a-z0-9]{$foo, $bar}\$/"; preg_match($pattern, $some_string) But this does, so Im good. Thanks for the tips... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php