[PHP] Ereg question
I am using ereg to validate the format of a date entry (mm/dd/yy), but if the year ends in a 0, it is being stripped and as such produces an error. So 1990 would be 199. The dob is being inputted by a form Here is my code: if (!ereg("^([0-9]{2})/([0-9]{2})/([0-9]{4})$", $formsave["dob"], $parts)) { $error["dob"] = "*"; $message["dob"] = "Invalid date format!"; $dob = " \"$parts[3]-$parts[2]-$parts[1]\""; } Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg question
$parts has been removed as I found I didn't need it there, but the problem still exists. This part of code however may be causing the problem, although I thought trim only stripped white space.?. $formsave['dob'] is a session variable. I have also found now that leading 0's are also being stripped. foreach($HTTP_POST_VARS as $varname => $value) $formsave[$varname] = trim($value, 50); If it's not there then the whole script fails. B. - Original Message - From: "John W. Holmes" <[EMAIL PROTECTED]> To: "'Beauford'" <[EMAIL PROTECTED]>; "'PHP General'" <[EMAIL PROTECTED]> Sent: Sunday, March 30, 2003 2:28 PM Subject: RE: [PHP] Ereg question > > I am using ereg to validate the format of a date entry (mm/dd/yy), but > if > > the year ends in a 0, it is being stripped and as such produces an > error. > > So > > 1990 would be 199. The dob is being inputted by a form > > > > Here is my code: > > > > if (!ereg("^([0-9]{2})/([0-9]{2})/([0-9]{4})$", $formsave["dob"], > $parts)) > > { > > $error["dob"] = "*"; $message["dob"] = "Invalid date format!"; > > $dob = " \"$parts[3]-$parts[2]-$parts[1]\""; > > } > > So is $formsave['dob'] being changed before you get to this code, > causing the check to fail? What else are you doing with > $formsave['dob']? Nothing here is going to cause it to drop a zero from > the end. > > Your code doesn't make much sense, though. If the ereg() fails, $parts > is not going to have any value, so why are you referencing $part[1], > $part[2], etc... ? > > ---John W. Holmes... > > PHP Architect - A monthly magazine for PHP Professionals. Get your copy > today. http://www.phparch.com/ > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg question
This is what I get when I echo $formsave["dob"] - 9/09/199. It was inputted as 09/09/1990. B. - Original Message - From: "John W. Holmes" <[EMAIL PROTECTED]> To: "'Beauford'" <[EMAIL PROTECTED]>; "'PHP General'" <[EMAIL PROTECTED]> Sent: Sunday, March 30, 2003 2:28 PM Subject: RE: [PHP] Ereg question > > I am using ereg to validate the format of a date entry (mm/dd/yy), but > if > > the year ends in a 0, it is being stripped and as such produces an > error. > > So > > 1990 would be 199. The dob is being inputted by a form > > > > Here is my code: > > > > if (!ereg("^([0-9]{2})/([0-9]{2})/([0-9]{4})$", $formsave["dob"], > $parts)) > > { > > $error["dob"] = "*"; $message["dob"] = "Invalid date format!"; > > $dob = " \"$parts[3]-$parts[2]-$parts[1]\""; > > } > > So is $formsave['dob'] being changed before you get to this code, > causing the check to fail? What else are you doing with > $formsave['dob']? Nothing here is going to cause it to drop a zero from > the end. > > Your code doesn't make much sense, though. If the ereg() fails, $parts > is not going to have any value, so why are you referencing $part[1], > $part[2], etc... ? > > ---John W. Holmes... > > PHP Architect - A monthly magazine for PHP Professionals. Get your copy > today. http://www.phparch.com/ > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg question
Just some more information. It appears that the session variable $formsave["dob"] is causing the problem. If I echo the input $_POST['dob'] it shows correctly, but when it's put into $formsave["dob"] the leading and ending 0's are being stripped. B. - Original Message - From: "John W. Holmes" <[EMAIL PROTECTED]> To: "'Beauford'" <[EMAIL PROTECTED]>; "'PHP General'" <[EMAIL PROTECTED]> Sent: Sunday, March 30, 2003 2:28 PM Subject: RE: [PHP] Ereg question > > I am using ereg to validate the format of a date entry (mm/dd/yy), but > if > > the year ends in a 0, it is being stripped and as such produces an > error. > > So > > 1990 would be 199. The dob is being inputted by a form > > > > Here is my code: > > > > if (!ereg("^([0-9]{2})/([0-9]{2})/([0-9]{4})$", $formsave["dob"], > $parts)) > > { > > $error["dob"] = "*"; $message["dob"] = "Invalid date format!"; > > $dob = " \"$parts[3]-$parts[2]-$parts[1]\""; > > } > > So is $formsave['dob'] being changed before you get to this code, > causing the check to fail? What else are you doing with > $formsave['dob']? Nothing here is going to cause it to drop a zero from > the end. > > Your code doesn't make much sense, though. If the ereg() fails, $parts > is not going to have any value, so why are you referencing $part[1], > $part[2], etc... ? > > ---John W. Holmes... > > PHP Architect - A monthly magazine for PHP Professionals. Get your copy > today. http://www.phparch.com/ > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg question
I posted the information as I had it. I had no idea what the problem was and posted the information I thought was FULL and ACCURATE - if this isn't good enough - then maybe I'll look for another list where people are a little more forgiving of new users. Remember, you were in my shoes once. B. - Original Message - From: "Jason Wong" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, March 30, 2003 11:20 PM Subject: Re: [PHP] Ereg question > On Monday 31 March 2003 04:15, Beauford wrote: > > Just some more information. It appears that the session variable > > $formsave["dob"] is causing the problem. If I echo the input $_POST['dob'] > > it shows correctly, but when it's put into $formsave["dob"] the leading > > and ending 0's are being stripped. > > Having read the whole thread it seems that you're only disclosing information > when it's been totured out of you :) > > May I suggest that in order to save yourself and other people's time that you > give FULL and ACCURATE information. > > For example, at the start of the thread you're pinning the blame on your ereg, > then you're saying the session variable is the problem. Only after it has > been pointed out to you that what you say you're doing cannot possibly have > the effect that you say you're seeing, do you finally disclose that you're > using trim() on the vital variables. > > Put simply, if you had posted your full and unadulterated code right from the > start then this thread should/would/could have been resolved in about 2 > posts. Saving time and frustration for everyone involved. > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.biz > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > -- > Search the list archives before you post > http://marc.theaimsgroup.com/?l=php-general > -- > /* > Bit off more than my mind could chew, > Shower or suicide, what do I do? > -- Julie Brown, "Will I Make it Through the Eighties?" > */ > > > -- > 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] Ereg question
This likely won't get through, but if it does. Post a real address so these conversations don't go through the list. I mean I'm already a burden to the list as it is. B. - Original Message - From: "Jason Wong" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, March 31, 2003 1:36 AM Subject: Re: [PHP] Ereg question > On Monday 31 March 2003 13:58, Beauford wrote: > > > I posted the information as I had it. I had no idea what the problem was > > and posted the information I thought was FULL and ACCURATE - > > Full and accurate if taken literally are absolute terms and are objective not > subjective. > > > if this isn't > > good enough - then maybe I'll look for another list where people are a > > little more forgiving of new users. Remember, you were in my shoes once. > > Jeez, my suggestion was to make it easier for others to help you. If you > insist you can always continue to post your question in installments (don't > forget a teaser to whet people's appetite for the next episode). And yes, you > can also look for another list if you want. These are all your choices. > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.biz > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > -- > Search the list archives before you post > http://marc.theaimsgroup.com/?l=php-general > -- > /* > Things are not always what they seem. > -- Phaedrus > */ > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] What's wrong with this code??
Hi, I have the following which gets the month and day: $mo = date("m"); $dy = date("d"); Then I have the following IF statements which do something based on the date.. if ($mo == 04 and $dy >= 01 and $dy <= 20) { $wd = "1"; } if ($mo == 04 and $dy >= 21 and $dy <= 27) { $wd = "2"; } if ($mo == 04 and $dy >= 28 or $mo == 5 and $dy <= 04) { $wd = "3"; } if ($mo == 05 and $dy >= 05 and $dy <= 11) { $wd = "4"; } if ($mo == 05 and $dy >= 12 and $dy <= 18) { $wd = "5"; } if ($mo == 05 and $dy >= 19 and $dy <= 25) { $wd = "6"; } if ($mo == 05 and $dy >= 26 or $mo == 06 and $dy <= 01) { $wd = "7"; } Problem lines if ($mo == 06 and $dy > 01 and $dy < 09) { $wd = "8"; } if ($mo == 06 and $dy > 08) { $wd = "9"; } The first 7 IF statements work fine ($wd gets the right value if the condition is met), but if I change my date to 06/02 then no matter what I try, $wd always gets the value of 9 (it should be 8 on this date). It should not get the value 9 until the 9th of June. I have checked and $mo and $dy have the proper values. Am I missing something? TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What's wrong with this code??
I figured that out after I sent the email. The reason I used the 0 in the first place was that I was having all sorts of problems with it - and it seemed to work fine for 01 to 05 so I just continued on with it - not even thinking about it. Your right though, the code is awkward - but I couldn't think of any other way of doing it. Any suggestions? Thanks - Original Message - From: "Ernest E Vogelsinger" <[EMAIL PROTECTED]> To: "Beauford" <[EMAIL PROTECTED]> Cc: "PHP General" <[EMAIL PROTECTED]> Sent: Friday, May 30, 2003 7:39 PM Subject: Re: [PHP] What's wrong with this code?? > At 01:08 30.04.2003, Beauford said: > [snip] > >if ($mo == 06 and $dy > 01 and $dy < 09) { $wd = "8"; } > >if ($mo == 06 and $dy > 08) { $wd = "9"; } > [snip] > > The problem is your notation. If you had written > > if ($mo == 6 and $dy > 1 and $dy < 9) { $wd = "8"; } > if ($mo == 6 and $dy > 8) { $wd = "9"; } > > your logic would still look a bit clumsy but work as you intend. > > Why? Prefixing a number with a zero makes the intepreter believe you're > using octal numbers. Oczal numbers range from 00 to 07, the decimal number > 8 would be 010 in octal notation. Your code, translated in decimal for > better understanding, is seen by the compiler as > > if ($mo == 6 and $dy > 1 and $dy < 2) { $wd = "8"; } > if ($mo == 6 and $dy > 0) { $wd = "9"; } > > (08 => decimal 0, 09 => decimal 1). In this case your last statement will > trigger for _any_ day in June. > > > -- >>O Ernest E. Vogelsinger >(\)ICQ #13394035 > ^ http://www.vogelsinger.at/ > > > > -- > 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] What's wrong with this code??
I find the switch statement does not always give the desired results and it's really not any different than using the if statement - the calculations would still have to be the same - it's just laid out differently. - Original Message - From: "Brian V Bonini" <[EMAIL PROTECTED]> To: "Beauford" <[EMAIL PROTECTED]> Cc: "PHP General" <[EMAIL PROTECTED]> Sent: Friday, May 30, 2003 9:18 PM Subject: Re: [PHP] What's wrong with this code?? > On Fri, 2003-05-30 at 20:02, Beauford wrote: > > Your right though, the code is awkward - but I couldn't think of any other > > way of doing it. > > > > Any suggestions? > > > > switch > > http://us4.php.net/manual/en/control-structures.switch.php > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Headers Problem
I'm getting the following error. My question is, where would I use the ob_start() and ob_end_flush() function so I can get rid of this. I have read the PHP manual, but not quite getting it.Or if there is a better way? This is how the files work. update-corrections-input.php (user inputs info by a form). This file includes another file - restricted.inc. The form in update-corrections-input.php calls update-corrections-write.php which processes the input and then includes update-corrections-input.php again. So basically it just brings the user back to the form again. Any input is appreciated Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /usr/local/apache/htdocs/supreme/updates/update-corrections-write.php:2) in /usr/local/apache/php/includes/restricted.inc on line 1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Headers Problem
Beauford wrote: > I'm getting the following error. My question is, where would I use the > ob_start() and ob_end_flush() function so I can get rid of this. I > have read the PHP manual, but not quite getting it.Or if there is a better way? > Don't work around the problem with output buffering; try fixing it. > Warning: session_start() [function.session-start]: Cannot send session > cache limiter - headers already sent (output started at > /usr/local/apache/htdocs/supreme/updates/update-corrections-write.php: > 2) in /usr/local/apache/php/includes/restricted.inc on line 1 You must have session_start() before any output. You've placed it on line 1 of restricted.inc, but output was started on line 2 of update-corrections-write.php. If you're going to include restricted.inc and start a session, include it before there is output. Just a clarification, session_start() is on the first line of restricted.inc and restricted.inc is included on the first line of update-corrections-input.php. All update-corrections-write.php does is write info to a database and includes update-corrections-input.php on the last line. So I'm still not understanding where the output from update-corrections-write.php is coming from. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Headers Problem
Yes, there was a blank line. Now I just have to test it to see if that was it. One other question though. It appears that Windows does not have this problem - the site in question is on a Linux box. Why would this be? The two sites are identical, I just use the Windows one for developing and testing. I have looked at both php.ini files, and other than the OS specific stuff, they are the same as well. Thanks again... -Original Message- From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] Sent: December 24, 2003 8:52 AM To: Beauford Cc: 'PHP' Subject: Re: [PHP] Headers Problem From: "Beauford" <[EMAIL PROTECTED]> > Just a clarification, session_start() is on the first line of restricted.inc > and restricted.inc is included on the first line of > update-corrections-input.php. All update-corrections-write.php does is write > info to a database and includes update-corrections-input.php on the > last line. So I'm still not understanding where the output from > update-corrections-write.php is coming from. Sounds like you have a blank line as the first line in update-corrections-write.php. If "http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date problems
Hi All, I have a database with a bunch of dates in it. I want to count the number of entries for each year and then display the year and the count. i.e. YearCount 200622 200518 200414 200322 This is what I have tried but just not quite getting it. $query "select count(date) as count, YEAR(date) as thisyear from stats group by thisyear"; This is the error: Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\Websites\Website\test.php on line 29 So obviously I must have the syntax not quite right. If I run just "select YEAR(date) from stats" from the mysql command line it works fine, so I believe the database is set up right. Any help is appreciated. B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date problems
Yea, I just figured this out. When I cut and pasted I must have overwrote the =. Thanks > -Original Message- > From: Stut [mailto:[EMAIL PROTECTED] > Sent: January 4, 2007 4:27 PM > To: Beauford > Cc: PHP > Subject: Re: [PHP] Date problems > > Beauford wrote: > > $query "select count(date) as count, YEAR(date) as thisyear > from stats > > group > ^ = needed here > > by thisyear"; > > -Stut > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Windows directory listings
Hi, I am trying to write a script that reads a directory on Windows. All the PHP functions I have looked at all seem to work with the Linux dietary structure. Is there another way to do this. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Windows directory listings
Maybe I should clarify. When I use a windows path (c:\whatever) I get an error that it can't find the path. In Linux the same code works fine (/usr/local/whatever). Here is all the relevent info. Warning: opendir(f:\downloads\): failed to open dir: Invalid argument in c:\web\index.php on line 30 * This is line 30 - if ( $handle = opendir ( $page ) ) This is the code: $page = "f:\\downloads"; // $mode : "FULL"|"DIRS"|"FILES" // $d : must not be defined $display = searchdir($page); $num = count($display); $i = 0; for($i = 0; $i <= $num; $i++) { echo $i." ".$display[$i].""; } function searchdir ( $page , $maxdepth = -1 , $mode = "FILES" , $d = 0 ) { if ( substr ( $page , strlen ( $page ) - 1 ) != '\\' ) { $page .= '\\' ; } $dirlist = array () ; if ( $mode != "FILES" ) { $dirlist[] = $page ; } if ( $handle = opendir ( $page ) ) { while ( false !== ( $file = readdir ( $handle ) ) ) { if ( $file != '.' && $file != '..' ) { $file = $file ; if ( ! is_dir ( $file ) ) { if ( $mode != "DIRS" ) { $dirlist[] = $file ; } } elseif ( $d >=0 && ($d < $maxdepth || $maxdepth < 0) ) { $result = searchdir ( $file . '\\' , $maxdepth , $mode , $d + 1 ) ; $dirlist = array_merge ( $dirlist , $result ) ; } } } closedir ( $handle ) ; } if ( $d == 0 ) { natcasesort ( $dirlist ) ; } return ( $dirlist ) ; } ?> > -Original Message- > From: Jochem Maas [mailto:[EMAIL PROTECTED] > Sent: January 7, 2007 10:25 AM > To: Beauford > Cc: PHP > Subject: Re: [PHP] Windows directory listings > > Beauford wrote: > > Hi, > > > > I am trying to write a script that reads a directory on > Windows. All > > the PHP functions I have looked at all seem to work with the Linux > > dietary > > it sounds more like you have found an examples that show > windows being used (i.e. windows file paths). > > > structure. Is there another way to do this. > > you must be reading a manual that only exists in your > particular parallel universe, all relevant php function work > in windows as well as linux: > > http://php.net/manual/en/ref.filesystem.php > http://php.net/dir > > > > > Thanks > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Windows directory listings
> -Original Message- > From: Jochem Maas [mailto:[EMAIL PROTECTED] > Sent: January 7, 2007 8:35 PM > To: Beauford > Cc: 'PHP' > Subject: Re: [PHP] Windows directory listings > > with regard to trolling - I'd don't *just* do that :-) > > sometime I even get the answer to the question correct :-) > let's see if I can help ... > > Beauford wrote: > > Maybe I should clarify. When I use a windows path > (c:\whatever) I get > > an error that it can't find the path. In Linux the same code works > > fine (/usr/local/whatever). > > > > Here is all the relevent info. > > > > Warning: opendir(f:\downloads\): failed to open dir: > Invalid argument > > in c:\web\index.php on line 30 > > > > * This is line 30 - if ( $handle = opendir ( $page ) ) > > > > This is the code: > > > > $page = "f:\\downloads"; > > you got this part right (escaping the backslash) > > > // $mode : "FULL"|"DIRS"|"FILES" > > // $d : must not be defined > > > > $display = searchdir($page); > > > > $num = count($display); > > $i = 0; > > > > for($i = 0; $i <= $num; $i++) { echo $i." ".$display[$i].""; } > > > > > > > > function searchdir ( $page , $maxdepth = -1 , $mode = > "FILES" , $d = 0 ) { > >if ( substr ( $page , strlen ( $page ) - 1 ) != '\\' ) { > $page .= > > '\\' ;} > > this if statement will run given the value of $page, it's not > needed AFAIKT. > then again I can't see it causing problems. This makes no difference. I took it out before and got the same error. > btw: php defines a constant DIRECTORY_SEPARATOR automatically > which may help you make your code more portable, and save you > having to think/worry about the blacksdlashing 'problem'. > > >$dirlist = array () ; > >if ( $mode != "FILES" ) { $dirlist[] = $page ; } > > right here I suggest adding a check using is_dir() and > is_readable() on the $page var. > for now stick in a bit of debug code ... > > echo ''; > var_dump($path, is_dir($path), is_readable($path)); echo ''; I checked the NTFS permissions and they are fine, and the local directory displays fine. By this I mean the directory where this script is. So if the script is in c:\test I can read c:\test, c:\test\test2. c:\test\test3, ../test2. etc. It only happens when I go outside of the current drive. So if I put $page = "test", or $page = "test3", or $page = "../" they will all work. As soon as I add a drive letter, it gives me the error. Even on the local machine. I am trying to access a networked drive, but I have a share on the PC where the script is . May this is the issue. Is there a way to use a UNC path? > I'm guessing that is_readable() is going to return false, > which would point the fact that either the drive or the > directory is not readable by the webserver process (you don't > mention whether you are running via a the webserver but I > assume you are given the output your generating include a > '') - the situation maybe compounded by the fact that F: > is actually a mapped drive of some sorts (I have no idea what > kind of trouble this could cause). > > > > >if ( $handle = opendir ( $page ) ) > >{ > >while ( false !== ( $file = readdir ( $handle ) ) ) > >{ > >if ( $file != '.' && $file != '..' ) > >{ > >$file = $file ; > >if ( ! is_dir ( $file ) ) { if ( $mode != "DIRS" ) { > > $dirlist[] = $file ; } } > >elseif ( $d >=0 && ($d < $maxdepth || > $maxdepth < 0) ) > >{ > >$result = searchdir ( $file . '\\' , $maxdepth , > > $mode , $d + 1 ) ; > >$dirlist = array_merge ( $dirlist , $result ) ; > >} > >} > >} > >closedir ( $handle ) ; > >} > >if ( $d == 0 ) { natcasesort ( $dirlist ) ; } > >return ( $dirlist ) ; > > } > > > > ?> > > > >> -Original Message- > >> From: Jochem Maas [mailto:[EMAIL PROTECTED] > >> Sent: January 7, 2007 10:25 AM > >> To: Beauford > >> Cc: PHP > >> Subject: Re: [PHP] Windows directory listings > >> > >> Beauford wrote: > >>> Hi, > >>> > >>> I am trying to write a script that reads a directory on > >> Windows. All > >>> the PHP functions I have looked at all seem to work with > the Linux > >>> dietary > >> it sounds more like you have found an examples that show windows > >> being used (i.e. windows file paths). > >> > >>> structure. Is there another way to do this. > >> you must be reading a manual that only exists in your particular > >> parallel universe, all relevant php function work in > windows as well > >> as linux: > >> > >>http://php.net/manual/en/ref.filesystem.php > >>http://php.net/dir > >> > >>> Thanks > >>> > >> > >> > > > > -- > PHP General Mailing List (http://www.php.net/) To > unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Forms and destroying values
Hi, How do I stop contents of a form from being readded to the database if the user hits the refresh button on their browser. I have tried to unset/destroy the variables in several different ways, but it still does it. After the info is written I unset the variables by using unset($var1, $var2, $etc). I have also tried unset($_POST['var1'], $_POST['var2'], $_POST['etc']). I even got deperate and tried $var = ""; or $_POST['var'] = ""; What do I need to do to get rid of these values??? Obviously I am missing something. Any help is appreciated. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Forms and destroying values
So the answer is, there is no way to destroy the values. Question then, what is unset() used for as it doesn't seem to do anything? With a language as good as PHP I though there would be some way to do this. I have got a workaround, but that's exactly what it is - a work around. I am also still confused as to why giving them a null value doesn't work. Thanks to all. > -Original Message- > From: Satyam [mailto:[EMAIL PROTECTED] > Sent: January 12, 2007 8:21 AM > To: Beauford; PHP > Subject: Re: [PHP] Forms and destroying values > > This issue comes over and over again. The trick, as I > learned from this list, is to send a redirect to the browser > to a confirmation page, so the browser remembers the page > redirected to and completely ignores the page that made the > redirection so that neither a refresh nor going back to it > can repeat the operation. > > So, if the database update has been succesful, use the > header() function to send a 'location' header along with > enough arguments in the URL to display a significant > confirmation message but make sure that it is different from > the URL that makes the database update. It will be this > address, not the > post that made the database update, that the browser will remember. > > Satyam > > > > - Original Message - > From: "Beauford" <[EMAIL PROTECTED]> > To: "PHP" > Sent: Friday, January 12, 2007 9:27 AM > Subject: [PHP] Forms and destroying values > > > > Hi, > > > > How do I stop contents of a form from being readded to the > database if the > > user hits the refresh button on their browser. > > > > I have tried to unset/destroy the variables in several > different ways, but > > it still does it. > > > > After the info is written I unset the variables by using > unset($var1, > > $var2, > > $etc). I have also tried unset($_POST['var1'], $_POST['var2'], > > $_POST['etc']). I even got deperate and tried $var = ""; or > $_POST['var'] > > = > > ""; > > > > What do I need to do to get rid of these values??? > Obviously I am missing > > something. > > > > Any help is appreciated. > > > > Thanks > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Forms and destroying values
Thanks, a little confusing there. You would think though that once the info is transmitted by the browser it would be forgotten by the browser. Anyway, I do have a work around, and since PHP can't do anything about what the browser does, this will have to suffice. Thanks all. > -Original Message- > From: Stut [mailto:[EMAIL PROTECTED] > Sent: January 12, 2007 11:38 AM > To: Beauford > Cc: 'PHP' > Subject: Re: [PHP] Forms and destroying values > > Beauford wrote: > > So the answer is, there is no way to destroy the values. Question > > then, what is unset() used for as it doesn't seem to do > anything? With > > a language as good as PHP I though there would be some way > to do this. > > I have got a workaround, but that's exactly what it is - a work > > around. I am also still confused as to why giving them a > null value doesn't work. > > > > You need to get it clear in your head when PHP is sending > data to the client and when it is not. Your assumption is > basically that the data in $_POST is actually *connected* to > the form displayed in the browser. > This is not the case. When you change the contents of $_POST > it has no effect on what the browser displays or uses since > it's not actually sent to the browser unless you specifically > output it in the form of a, erm, form. > > When the user hits refresh, or uses the back button it is up > to the browser what it does. In the case of refresh, if the > page being refreshed was created in response to a form being > submitted the browser will ask the user if they want to > resubmit the data. When using the back button the browser > will usually use its cached copy of the page rather than > hitting the server again. > > Hope that makes it clearer. > > -Stut > > >> -Original Message- > >> From: Satyam [mailto:[EMAIL PROTECTED] > >> Sent: January 12, 2007 8:21 AM > >> To: Beauford; PHP > >> Subject: Re: [PHP] Forms and destroying values > >> > >> This issue comes over and over again. The trick, as I > learned from > >> this list, is to send a redirect to the browser to a confirmation > >> page, so the browser remembers the page redirected to and > completely > >> ignores the page that made the redirection so that neither > a refresh > >> nor going back to it can repeat the operation. > >> > >> So, if the database update has been succesful, use the > >> header() function to send a 'location' header along with enough > >> arguments in the URL to display a significant confirmation > message > >> but make sure that it is different from > >> the URL that makes the database update. It will be this > >> address, not the > >> post that made the database update, that the browser will remember. > >> > >> Satyam > >> > >> > >> > >> - Original Message - > >> From: "Beauford" <[EMAIL PROTECTED]> > >> To: "PHP" > >> Sent: Friday, January 12, 2007 9:27 AM > >> Subject: [PHP] Forms and destroying values > >> > >> > >> > >>> Hi, > >>> > >>> How do I stop contents of a form from being readded to the > >>> > >> database if the > >> > >>> user hits the refresh button on their browser. > >>> > >>> I have tried to unset/destroy the variables in several > >>> > >> different ways, but > >> > >>> it still does it. > >>> > >>> After the info is written I unset the variables by using > >>> > >> unset($var1, > >> > >>> $var2, > >>> $etc). I have also tried unset($_POST['var1'], $_POST['var2'], > >>> $_POST['etc']). I even got deperate and tried $var = ""; or > >>> > >> $_POST['var'] > >> > >>> = > >>> ""; > >>> > >>> What do I need to do to get rid of these values??? > >>> > >> Obviously I am missing > >> > >>> something. > >>> > >>> Any help is appreciated. > >>> > >>> Thanks > >>> > >>> -- > >>> PHP General Mailing List (http://www.php.net/) To unsubscribe, > >>> visit: http://www.php.net/unsub.php > >>> > >>> > >> -- > >> PHP General Mailing List (http://www.php.net/) To > unsubscribe, visit: > >> http://www.php.net/unsub.php > >> > >> > >> > >> > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Stripslashes
Hi, Anyone know how I can strip slashes from $_POST variables. I have tried about a hundred different ways of doing this and nothing works. i.e. if(!empty($_POST)){ foreach($_POST as $x => $y){ $_POST[$x] = stripslashes($y); } } This came about after someone tried to enter O'Toole in a form, and it appeared as O\'Toole. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Stripslashes
I guess I'm just doing something wrong, 'cause that doesn't work either - nor do the hundreds of other snippets I've used. Here's the scenario. I have a form - after they submit the form it shows what they have entered, this is where I get the \. It also does it if the form redisplays after the user has input invalid data. All this is being done on the same page. > -Original Message- > From: Jim Lucas [mailto:[EMAIL PROTECTED] > Sent: January 14, 2007 1:02 AM > To: Beauford > Cc: PHP > Subject: Re: [PHP] Stripslashes > > Beauford wrote: > > Hi, > > > > Anyone know how I can strip slashes from $_POST variables. I have > > tried about a hundred different ways of doing this and > nothing works. > > > > i.e. > > > > if(!empty($_POST)){ > > foreach($_POST as $x => $y){ > > $_POST[$x] = stripslashes($y); > > } > > } > > > > This came about after someone tried to enter O'Toole in a > form, and it > > appeared as O\'Toole. > > > > Thanks > > > > > This is what I use, and it has worked ever time. > > if ( get_magic_quotes_gpc() ) { > $_POST = array_map("stripslashes", $_POST); } > > Jim Lucas > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Stripslashes
I just turned off get_magic_quotes in my PHP.ini, but not sure if the hosting company has it on or not once I upload the site. > -Original Message- > From: Beauford [mailto:[EMAIL PROTECTED] > Sent: January 14, 2007 11:34 AM > To: 'PHP' > Subject: RE: [PHP] Stripslashes > > > I guess I'm just doing something wrong, 'cause that doesn't > work either - nor do the hundreds of other snippets I've used. > > Here's the scenario. I have a form - after they submit the > form it shows what they have entered, this is where I get the > \. It also does it if the form redisplays after the user has > input invalid data. > > All this is being done on the same page. > > > -Original Message----- > > From: Jim Lucas [mailto:[EMAIL PROTECTED] > > Sent: January 14, 2007 1:02 AM > > To: Beauford > > Cc: PHP > > Subject: Re: [PHP] Stripslashes > > > > Beauford wrote: > > > Hi, > > > > > > Anyone know how I can strip slashes from $_POST variables. I have > > > tried about a hundred different ways of doing this and > > nothing works. > > > > > > i.e. > > > > > > if(!empty($_POST)){ > > > foreach($_POST as $x => $y){ > > > $_POST[$x] = stripslashes($y); > > > } > > > } > > > > > > This came about after someone tried to enter O'Toole in a > > form, and it > > > appeared as O\'Toole. > > > > > > Thanks > > > > > > > > This is what I use, and it has worked ever time. > > > > if ( get_magic_quotes_gpc() ) { > > $_POST = array_map("stripslashes", $_POST); } > > > > Jim Lucas > > > > > > > > -- > 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] Stripslashes
I'm familiar with the .htaccess file and I am told by the hosting company that apache is set up to use it, I've just never used it much - especially for PHP. If this works I'd even like to set an includes file for PHP. Here is the file. # -FrontPage- IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* order deny,allow deny from all allow from all order deny,allow deny from all AuthName www.site.com AuthUserFile /home/user/public_html/dir/file.pwd AuthGroupFile /home/user/public_html/dir/file.grp php_value magic_quotes_gpc 0 - Thanks > -Original Message- > From: Larry Garfield [mailto:[EMAIL PROTECTED] > Sent: January 15, 2007 12:02 AM > To: Beauford; PHP-General > Subject: Re: [PHP] Stripslashes > > Copying this back on list where it belongs... > > If the apache process on the server is configured to support > .htaccess files, then there shouldn't be anything special you > need to do. Do you have any other htaccess directives in use > that could be affecting it? Remember that it's not > "htaccess", it's a ".htaccess" file. Mind the period. > > > On Sunday 14 January 2007 9:56 pm, Beauford wrote: > > Hi Larry, > > > > I'm sending this off list. I put this in the .htaccess file on the > > hosting server, but still have the same problems. Is there > a special > > way this needs to be done? > > > > Thanks > > > > > Thanks > > > > > > > -Original Message- > > > > From: Larry Garfield [mailto:[EMAIL PROTECTED] > > > > Sent: January 14, 2007 4:39 PM > > > > To: php-general@lists.php.net > > > > Subject: Re: [PHP] Stripslashes > > > > > > > > On a real web host, they'll let you have a .htaccess file where > > > > you can disable them like so: > > > > > > > > php_value magic_quotes_gpc 0 > > > > > > > > (I keep saying "real web host" because I've just recently > > > > > > had to deal > > > > > > > with a few web hosts that a client insisted on that > didn't have a > > > > standard configuration and didn't support .htaccess files. > > > > > > I lost 6 > > > > > > > hours of my life right before Christmas trying to work > around that > > > > fact, and I can't get them back. If you find yourself > in the same > > > > situation, vote with your feet and let such hosts die a > > > > > > horrible and > > > > > > > bankrupt death.) > > > > > > > > On Sunday 14 January 2007 10:46 am, Beauford wrote: > > > > > I just turned off get_magic_quotes in my PHP.ini, but not > > > > > > > > sure if the > > > > > > > > > hosting company has it on or not once I upload the site. > > > -- > Larry GarfieldAIM: LOLG42 > [EMAIL PROTECTED] ICQ: 6817012 > > "If nature has made any one thing less susceptible than all > others of exclusive property, it is the action of the > thinking power called an idea, which an individual may > exclusively possess as long as he keeps it to himself; but > the moment it is divulged, it forces itself into the > possession of every one, and the receiver cannot dispossess > himself of it." -- Thomas Jefferson > > -- > PHP General Mailing List (http://www.php.net/) To > unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] FW: Eregi question
Hi, Hopefully this is my last question so I can put this site to bed. Is there a good article that explains how to do the patterns for eregi. I have read tons of articles, but none really explains what everything means. Like why some things have square brackets and some have round, what does the * and $ do? Etc. i.e. "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)[EMAIL PROTECTED](\.[a-z0-9-]{1,})*\.([a-z]{2,}){1} $" The problem I am having is I'm trying to create a small function to validate a web address. i.e. www.site.com (no http://). I have tried "[a-z0-9]+.[a-z0-9]+.[a-z0-9]", but it only works partially. If I input www.bob I get an error - www.bob.com I get no error, but it doesn't stop. www.bob.com.bob.bob.bob also produces no error. How do I stop it after it matches the 3 patterns? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] I lied, another question / problem
I have file which I use for validating which includes the following function: function invalidchar($strvalue) { if(!ereg("^[[:alpha:][:space:]\'-.]*$", $strvalue)) { return "*"; } } Here is the problem. If I don't use the function, like below, there is no problem. if (empty($person)) { $formerror['person'] = "*"; } elseif(!ereg("^[[:alpha:][:space:]\'-.]*$", $person)) { $formerror['person'] = "*"; } If I use the one below it says $formerror['person'] is set, but if I echo it there is nothing in it. But here is the kicker, I have several other scripts that use the same function with no problems. In fact, I have another form which uses the code below with no problems. So I am at a loss as to what the problem is. I have deleted all other validating except for the one below to try and narrow this down, but still at a loss. One last thing, if I unset $formerror['person'] at the end of the code below, it works. So obviously it has a value - but what is it and how is it getting it?? Am I just losing it if (empty($person)) { $formerror['person'] = "*"; } else { $formerror['person'] = invalidchar($person); } Any help before I go insane. This is the entire code::: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I lied, another question / problem
> -Original Message- > From: Roman Neuhauser [mailto:[EMAIL PROTECTED] > Sent: January 15, 2007 7:09 PM > To: Beauford > Cc: PHP > Subject: Re: [PHP] I lied, another question / problem > > # [EMAIL PROTECTED] / 2007-01-15 16:31:32 -0500: > > I have file which I use for validating which includes the following > > function: > > > > function invalidchar($strvalue) > > { > > if(!ereg("^[[:alpha:][:space:]\'-.]*$", $strvalue)) { > > That regexp matches if $strvalue consists of zero or more > ocurrences of a letter, a whitespace character, and any > character whose numeric value lies between the numeric values > of "'" and "." in your locale. > Zero or more means it also matches an empty string. > I'm still confused. This works perfectly on my other two pages with the exact same code. So why is it only this one page that is causing a problem? If I enter the word "test" in my form, without the quotes, then why is the fuction returning anything since this is a valid entry. Should it not only return a value if there is a problem. All I want to accomplish here is to allow the user to enter a to z, A to Z, and /\'-_. and a space. Is there a better way to do this? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I lied, another question / problem
> -Original Message- > From: Roman Neuhauser [mailto:[EMAIL PROTECTED] > Sent: January 15, 2007 7:09 PM > To: Beauford > Cc: PHP > Subject: Re: [PHP] I lied, another question / problem > > # [EMAIL PROTECTED] / 2007-01-15 16:31:32 -0500: > > I have file which I use for validating which includes the following > > function: > > > > function invalidchar($strvalue) > > { > > if(!ereg("^[[:alpha:][:space:]\'-.]*$", $strvalue)) { > > That regexp matches if $strvalue consists of zero or more > ocurrences of a letter, a whitespace character, and any > character whose numeric value lies between the numeric values > of "'" and "." in your locale. > Zero or more means it also matches an empty string. > > > -- > How many Vietnam vets does it take to screw in a light bulb? > You don't know, man. You don't KNOW. > Cause you weren't THERE. http://bash.org/?255991 > > -- > PHP General Mailing List (http://www.php.net/) To > unsubscribe, visit: http://www.php.net/unsub.php Further to my previous email, there is something weird going on here. I just tried using this: if (!ereg('^[A-Za-z0-9]', $strvalue)) { return "error"; } When I enter the word Test, which is valid, I am still getting an error returned - but only on this one page. So there has got to be something on this page that is screwing this up, but what. I have been over and over this and can't see a problem. I could really use another pair of eyes on this as it is driving me nuts. I am now into hour 6 with this. Absolutely ridiculous. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I lied, another question / problem
> -Original Message- > From: 'Roman Neuhauser' [mailto:[EMAIL PROTECTED] > Sent: January 15, 2007 7:53 PM > To: Beauford > Cc: 'PHP' > Subject: Re: [PHP] I lied, another question / problem > > # [EMAIL PROTECTED] / 2007-01-15 18:33:31 -0500: > > > From: Roman Neuhauser [mailto:[EMAIL PROTECTED] # > > > [EMAIL PROTECTED] / 2007-01-15 16:31:32 -0500: > > > > I have file which I use for validating which includes the > > > > following > > > > function: > > > > > > > > function invalidchar($strvalue) > > > > { > > > > if(!ereg("^[[:alpha:][:space:]\'-.]*$", $strvalue)) { > > > > > > That regexp matches if $strvalue consists of zero or more > ocurrences > > > of a letter, a whitespace character, and any character > whose numeric > > > value lies between the numeric values of "'" and "." in > your locale. > > > Zero or more means it also matches an empty string. > > > > I'm still confused. This works perfectly on my other two pages with > > the exact same code. So why is it only this one page that > is causing a problem? > > I don't know, I don't care. You have enough problems with the > single regex, let's concentrate on fixing this first. This certainly has a bearing. If the code works here then there is nothing wrong with the code. There is something else going on. > > If I enter the word "test" in my form, without the quotes, > then why is > > the fuction returning anything since this is a valid entry. > Should it > > not only return a value if there is a problem. > > I don't understand that paragraph. The regexp matches, and > the function returns *nothing* just as you programmed it. > That, of course, means that the variable you are assigning > this *nothing* gets set to *nothing*, which, in PHP lingo, is null. The problem is that it is returning *something*, and that's what I am trying to figure out. If I put this in my code after I do the checking it works, but it should not work if the function is retuning *nothing*. So the original question remains, what is being returned and why? If($formerror) echo "Testing"; This will display Testing - it should not display anything since nothing should be returned. > > > All I want to accomplish here is to allow the user to enter > a to z, A > > to Z, and /\'-_. and a space. Is there a better way to do this? > > 1. Do you really want to let them enter backslashes, or are you trying >to "escape" the apostrophe? > 2. Does that mean that "/\'-_." (without the quotes) and " " (that's >three spaces) are valid entries? Where do you see 3 spaces? In any event, I don't think this is the problem. As I have said the code works fine on two other pages, which logically suggests that there is something on this page that is causing a problem. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I lied, another question / problem
Does anyone have any idea to this problem? All the code is in the emails I have written to the list. I have temporarily solved the problem by writing my own function not using any pregs, eregs, or any other regs and it works perfectly. It's probably not considered good programming, but it works the way it is supposed to. I would however like to know what the issue is with the original code, or if this is actually a bug in PHP. Thanks > -Original Message- > From: Beauford [mailto:[EMAIL PROTECTED] > Sent: January 15, 2007 7:22 PM > To: 'PHP' > Subject: RE: [PHP] I lied, another question / problem > > > > > -Original Message- > > From: 'Roman Neuhauser' [mailto:[EMAIL PROTECTED] > > Sent: January 15, 2007 7:53 PM > > To: Beauford > > Cc: 'PHP' > > Subject: Re: [PHP] I lied, another question / problem > > > > # [EMAIL PROTECTED] / 2007-01-15 18:33:31 -0500: > > > > From: Roman Neuhauser [mailto:[EMAIL PROTECTED] # > > > > [EMAIL PROTECTED] / 2007-01-15 16:31:32 -0500: > > > > > I have file which I use for validating which includes the > > > > > following > > > > > function: > > > > > > > > > > function invalidchar($strvalue) > > > > > { > > > > > if(!ereg("^[[:alpha:][:space:]\'-.]*$", $strvalue)) { > > > > > > > > That regexp matches if $strvalue consists of zero or more > > ocurrences > > > > of a letter, a whitespace character, and any character > > whose numeric > > > > value lies between the numeric values of "'" and "." in > > your locale. > > > > Zero or more means it also matches an empty string. > > > > > > I'm still confused. This works perfectly on my other two > pages with > > > the exact same code. So why is it only this one page that > > is causing a problem? > > > > I don't know, I don't care. You have enough problems with > the single > > regex, let's concentrate on fixing this first. > > This certainly has a bearing. If the code works here then > there is nothing wrong with the code. There is something else > going on. > > > > If I enter the word "test" in my form, without the quotes, > > then why is > > > the fuction returning anything since this is a valid entry. > > Should it > > > not only return a value if there is a problem. > > > > I don't understand that paragraph. The regexp matches, and the > > function returns *nothing* just as you programmed it. > > That, of course, means that the variable you are assigning this > > *nothing* gets set to *nothing*, which, in PHP lingo, is null. > > The problem is that it is returning *something*, and that's > what I am trying to figure out. > > If I put this in my code after I do the checking it works, > but it should not work if the function is retuning *nothing*. > So the original question remains, what is being returned and why? > > If($formerror) echo "Testing"; This will display Testing - > it should not display anything since nothing should be returned. > > > > > > > All I want to accomplish here is to allow the user to enter > > a to z, A > > > to Z, and /\'-_. and a space. Is there a better way to do this? > > > > 1. Do you really want to let them enter backslashes, or are > you trying > >to "escape" the apostrophe? > > 2. Does that mean that "/\'-_." (without the quotes) and " > " (that's > >three spaces) are valid entries? > > Where do you see 3 spaces? In any event, I don't think this > is the problem. > As I have said the code works fine on two other pages, which > logically suggests that there is something on this page that > is causing a problem. > > Thanks > > -- > 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] I lied, another question / problem
My apologies, but I am just so frustrated right now. It seems my function doesn't work either (if that's even the problem, which at this time I just don't know). Somehow my variable is still getting a value, and I have no idea how. Even if I don't return anything it still gets a value. Basically this has just broken my whole site. If anyone can figure this out let me know, right now I just have to put this site up with no validation. Thanks > -Original Message- > From: Beauford > Sent: January 15, 2007 10:26 PM > To: 'PHP' > Subject: RE: [PHP] I lied, another question / problem > > Does anyone have any idea to this problem? All the code is in > the emails I have written to the list. I have temporarily > solved the problem by writing my own function not using any > pregs, eregs, or any other regs and it works perfectly. It's > probably not considered good programming, but it works the > way it is supposed to. > > I would however like to know what the issue is with the > original code, or if this is actually a bug in PHP. > > Thanks > > > -Original Message- > > From: Beauford [mailto:[EMAIL PROTECTED] > > Sent: January 15, 2007 7:22 PM > > To: 'PHP' > > Subject: RE: [PHP] I lied, another question / problem > > > > > > > > > -Original Message- > > > From: 'Roman Neuhauser' [mailto:[EMAIL PROTECTED] > > > Sent: January 15, 2007 7:53 PM > > > To: Beauford > > > Cc: 'PHP' > > > Subject: Re: [PHP] I lied, another question / problem > > > > > > # [EMAIL PROTECTED] / 2007-01-15 18:33:31 -0500: > > > > > From: Roman Neuhauser [mailto:[EMAIL PROTECTED] # > > > > > [EMAIL PROTECTED] / 2007-01-15 16:31:32 -0500: > > > > > > I have file which I use for validating which includes the > > > > > > following > > > > > > function: > > > > > > > > > > > > function invalidchar($strvalue) { > > > > > > if(!ereg("^[[:alpha:][:space:]\'-.]*$", $strvalue)) { > > > > > > > > > > That regexp matches if $strvalue consists of zero or more > > > ocurrences > > > > > of a letter, a whitespace character, and any character > > > whose numeric > > > > > value lies between the numeric values of "'" and "." in > > > your locale. > > > > > Zero or more means it also matches an empty string. > > > > > > > > I'm still confused. This works perfectly on my other two > > pages with > > > > the exact same code. So why is it only this one page that > > > is causing a problem? > > > > > > I don't know, I don't care. You have enough problems with > > the single > > > regex, let's concentrate on fixing this first. > > > > This certainly has a bearing. If the code works here then there is > > nothing wrong with the code. There is something else going on. > > > > > > If I enter the word "test" in my form, without the quotes, > > > then why is > > > > the fuction returning anything since this is a valid entry. > > > Should it > > > > not only return a value if there is a problem. > > > > > > I don't understand that paragraph. The regexp matches, and the > > > function returns *nothing* just as you programmed it. > > > That, of course, means that the variable you are assigning this > > > *nothing* gets set to *nothing*, which, in PHP lingo, is null. > > > > The problem is that it is returning *something*, and that's > what I am > > trying to figure out. > > > > If I put this in my code after I do the checking it works, but it > > should not work if the function is retuning *nothing*. > > So the original question remains, what is being returned and why? > > > > If($formerror) echo "Testing"; This will display Testing - > it should > > not display anything since nothing should be returned. > > > > > > > > > > > All I want to accomplish here is to allow the user to enter > > > a to z, A > > > > to Z, and /\'-_. and a space. Is there a better way to do this? > > > > > > 1. Do you really want to let them enter backslashes, or are > > you trying > > >to "escape" the apostrophe? > > > 2. Does that mean that "/\'-_." (without the quotes) and " > > " (that's > > >three spaces) are valid entries? > > > > Where do you see 3 spaces? In any event, I don't think this is the > > problem. > > As I have said the code works fine on two other pages, > which logically > > suggests that there is something on this page that is causing a > > problem. > > > > Thanks > > > > -- > > 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] I lied, another question / problem
Obviously I'm not quite understanding, maybe a further explanation is needed to help me understand. This is how I see it from what you said - am in in the right ballpark. The function is returning a null value if there is no error, and I guess PHP sees 'null' or "" as a value. So how do I get around this? This is how I call the function. if($result = ValidateString($orgname, 1)) { $formerror['orgname'] = $result; } If there is an error an error string will be returned (i.e. Error in field), if not I want nothing returned. Later on in the page I use - if(!$formerror) blah blah. This is where the problem is because if null or "" is being returned then $formerror has a value which breaks the above if. I hope this helps. Thanks > -Original Message- > From: Roman Neuhauser [mailto:[EMAIL PROTECTED] > Sent: January 16, 2007 5:49 AM > To: Beauford > Cc: 'PHP' > Subject: Re: [PHP] I lied, another question / problem > > # [EMAIL PROTECTED] / 2007-01-15 19:22:24 -0500: > > > From: 'Roman Neuhauser' [mailto:[EMAIL PROTECTED] # > > > [EMAIL PROTECTED] / 2007-01-15 18:33:31 -0500: > > > > > From: Roman Neuhauser [mailto:[EMAIL PROTECTED] # > > > > > [EMAIL PROTECTED] / 2007-01-15 16:31:32 -0500: > > > > > > I have file which I use for validating which includes the > > > > > > following > > > > > > function: > > > > > > > > > > > > function invalidchar($strvalue) { > > > > > > if(!ereg("^[[:alpha:][:space:]\'-.]*$", $strvalue)) { > > > > > > > > > > That regexp matches if $strvalue consists of zero or more > > > > > ocurrences of a letter, a whitespace character, and any > > > > > character whose numeric value lies between the > numeric values of > > > > > "'" and "." in your locale. Zero or more means it > also matches > > > > > an empty string. > > > > > All I want to accomplish here is to allow the user to enter > > > a to z, A > > > > to Z, and /\'-_. and a space. Is there a better way to do this? > > > > > > 1. Do you really want to let them enter backslashes, or > are you trying > > >to "escape" the apostrophe? > > > 2. Does that mean that "/\'-_." (without the quotes) and > " " (that's > > >three spaces) are valid entries? > > > > Where do you see 3 spaces? > > That's a value the regexp will match. Is that intended? > > > In any event, I don't think this is the problem. > > As I have said the code works fine on two other pages, > which logically > > suggests that there is something on this page that is > causing a problem. > > You don't understand that single function, and it does > something else than you think it does. I told you what it > actually does, but you chose to ignore the information. I > don't know how I could help you more. > > -- > How many Vietnam vets does it take to screw in a light bulb? > You don't know, man. You don't KNOW. > Cause you weren't THERE. http://bash.org/?255991 > > -- > 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] I lied, another question / problem
> This is a bad way to test for a value also, unless you > expecting only TRUE or FALSE and you are sure that it will > always be set. > Otherwise you should do something like this > > if ( isset($formerror) && $formerror != '' ) { > // Display Error > } The problem here is this. formerror is an array and can have formerror['a'], formerror['b'], etc. I don't care how many errors there are, I only want to know if there was an error somewhere along the way. Example: if I have two fields, Name and Age and they both have errors, I would echo $formerror['name'] and $formerror['age'] Then I check if(!$formerror) { do something.. This would not get done as the above two have errors, which is what I want. The problem still lies with something being returned from the function even if there are no errors. So if(!$formerror) never gets done. Which is the problem. Another question, and not related, how do I kill a session when someone leaves a particular page. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I lied, another question / problem
> $formerror = array(); > > ... do your validation here which may/may not add to the array. > > if (!empty($formerror)) { >echo "Something went wrong!"; >print_r($formerror); > } else { >echo "Everything is ok!"; > } As I said the problem is that a value is being returned, how I check it is really not an issue as I know there is value there. I guess I need to figure out how to only return something if there is an error, and not return anything if there is no error, or just totally revise the way I am doing this period. I have corrected the problem, but it is messy and it is cumbersome, but it will have to do until I can work out something better. At least now I can take my time and work on this. I appreciate all the suggestions and maybe I can incorporate some of them once I do a rewrite. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] One last try at this!
I hope I can explain this so I can get this figured out, 'cause if not I may just have to find an alternative to PHP. I can't be wasting 3 and 4 days on something as simple as this. Below are 3 validation routines. When I first enter the page 'Optional' is displayed for all of them as it should be, but when I click submit on the form without entering any data, the first one displays optional (which it should), but the 2nd and 3rd ones execute the elseif and the validation routine says there are invalid characters in the string. If nothing is entered in the form where is it getting a value It should never get to the elseif to start with if nothing is entered in the form. So how can I make a reliable check? if(empty($orgname)) { $formerror['orgname'] = "Optional"; } elseif($result = ValidateString($orgname, "2")) { $formerror['orgname'] = $result; } if(empty($website)) { $formerror['website'] = "Optional"; } if($result = ValidateString($website, "2")) { $formerror['website'] = $result; } if(empty($event)) { $formerror['event'] = "Optional"; } if($result = ValidateString($event, "2")) { $formerror['event'] = $result; } Again, sorry to be a pain, but I just don't get it. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] One last try at this!
Your right. I have been sitting here at this computer for 3 days straight with all the various problems, and I missed this. I need a break, I need a KitKat. Thanks to the list for all the help over the last couple of days. I'm going to watch CSI and get away from this. > Take a little closer look at what you think are elseif > statements below You are missing the else part :( > > if(empty($website)) { $formerror['website'] = "Optional"; } > if($result > > = ValidateString($website, "2")) { $formerror['website'] = > $result; } > > > > if(empty($event)) { $formerror['event'] = "Optional"; } > if($result = > > ValidateString($event, "2")) { $formerror['event'] = $result; } > > > > Again, sorry to be a pain, but I just don't get it. > > > > Thanks > > > > > > -- > 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] One last try at this!
This is what I am trying to do, and for the most part it works, but it also may be causing some of my other problems. If $event contains invalid characters, I am returning a string that says "Invalid Characters" So $result now contains the value 'Invalid Characters'. Then $formerror['event'] = $result - is self explanatory. If there are no errors nothing is returned and $result should contain anything. But this doesn't always seem to be the case. This is one of the problems I am having. This is the code in a nutshell. if($result = ValidateString($event)) { $formerror['event'] = $result; function ValidateString($string) { if(!preg_match("/^[-A-Za-z0-9_.' ]+$/", $string)) { return "Invalid Characters"; } Thanks > -Original Message- > From: Jim Lucas [mailto:[EMAIL PROTECTED] > Sent: January 17, 2007 4:36 PM > To: Jay Blanchard > Cc: Beauford; PHP > Subject: Re: [PHP] One last try at this! > > Jay Blanchard wrote: > > [snip] > > > >> The second condition of each if statement does not contain > equality > >> checking, it sets the $result to ValidateString($event, "2"). That > >> should be if($result == ValidateString($event, "2")) or if($result > >> === ValidateString($event, "2")) > >> > >> > >> > > What if the intension was to fail if the result of ValidateString() > > was false?? > > > > Then it should be writen as such. > > > > if ( ( $result = ValidateString($event, "2") ) !== FALSE ) { > > $formerror['event'] = $result; > > } > > [/snip] > > > > Hmmm.did you test that? > > $result = ValidateString($event, "2") is always TRUE, > $result has had > > something assigned to it unless the function ValidateString > returns a > > FALSE. The OP never provided the code for the function so we just > > don't know. Also, the OP forgot to run subsequent conditions in an > > elseif check, instead he used 3 if statements that will be > executed each time. > > > > > At one point he mentioned changing ValidateString() to return > false on an error. > > At least that is what I thought he said. > > -- > 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] One last try at this!
> -Original Message- > From: Jim Lucas [mailto:[EMAIL PROTECTED] > Sent: January 17, 2007 8:10 PM > To: Jim Lucas > Cc: Beauford; 'PHP' > Subject: Re: [PHP] One last try at this! > > Jim Lucas wrote: > > Beauford wrote: > >> This is what I am trying to do, and for the most part it > works, but > >> it also may be causing some of my other problems. > >> > >> If $event contains invalid characters, I am returning a > string that > >> says "Invalid Characters" So $result now contains the > value 'Invalid > >> Characters'. > >> Then $formerror['event'] = $result - is self explanatory. > >> > >> If there are no errors nothing is returned and $result > should contain > >> anything. But this doesn't always seem to be the case. > This is one of > >> the problems I am having. > >> > >> This is the code in a nutshell. > >> > >> if($result = ValidateString($event)) { $formerror['event'] > = $result; > >> function ValidateString($string) { > >> > >> if(!preg_match("/^[-A-Za-z0-9_.' ]+$/", $string)) { > >> return "Invalid Characters"; > >> } > >> > >> Thanks > >> > >> > > In your regex you have a "." this will match anything > > > > try this: > > > > > > > function ValidateString($string) { > > if ( preg_match("/[^a-zA-Z0-9\_\.\' -]+/", $string) ) { > > return "Invalid Characters"; > > } > > return false; > > } > > > > $formerror = array(); > forgot to say that all you need to do to get rid of the > default values is remove the following two lines > > > $formerror['firstAttempt'] = 'first attempt'; > > $formerror['secondAttempt'] = 'second attempt'; > > > > $event = "A-Z and a-z plus 0-9 and an '_' are allowed."; if ( ( > > $result = ValidateString($event) ) !== false ) { > > $formerror['firstAttempt'] = $result; } > > > > $event = "But bad chars like [EMAIL PROTECTED] and %^&* are not > allowed."; if ( ( > > $result = ValidateString($event) ) !== false ) { > > $formerror['secondAttempt'] = $result; } > > > > var_dump($formerror); > > > > ?> > > > > Jim Lucas > > The regex itself was not really the problem, although I appreciate the help on that, but I'm not sure I follow the rest of what your saying. I tried your line below, and whether or not there were errors, an error was always returned. So ABC or @#$ would give me the same result. if ( ($result = ValidateString($event) ) !== false ) { $formerror['firstAttempt'] = $result; } Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Php / MySQL DESC tablename
Hi, First off thanks to everyone for the previous help. I managed to get it sorted out and used several of the suggestions made. I am trying to do a DESC table_name using PHP so it looks like it would it you did it from the command line. i.e. | Field | Type | Null | Key | Default | Extra | +---+--+--+-+-++ | id| int(11) | NO | PRI | NULL| auto_increment | | name | varchar(30) | NO | | NULL|| What I have found is that the following does not work the way I would have thought. $query = "DESC table ".$currenttb; $result = mysql_query($query); while ($row = mysql_fetch_row($result)) { etc. I have found something that works, but it is still not like the above and is really bulky. I can not get the type (varchar, etc) to show like above, it will show string, blob, etc, and the last problem is it puts the last 4 fields in one variable (flags). Does anyone know of a way to get this to output as shown above. I am putting this into a form for editing, so I need everything in the proper places. Thanks Here is the entire code: mysql_select_db($_SESSION['currentdb']); $result = mysql_query("SELECT * FROM ".$_SESSION['currenttb']); $fields = mysql_num_fields($result); $rows = mysql_num_rows($result); $table = mysql_field_table($result, 0); for ($i=0; $i < $fields; $i++) { $type = mysql_field_type($result, $i); $name = mysql_field_name($result, $i); $len = mysql_field_len($result, $i); $flags = mysql_field_flags($result, $i); echo all the filds } This outputs (depending on the order you echo them): username string 50 [not_null primary_key auto_increment] value in [] is one value. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] preg_match problem
I'm trying to get this but not quite there. I want to allow the following characters. [EMAIL PROTECTED]&()*;:_.'/\ and a space. Is there a special order these need to be in or escaped somehow. For example, if I just allow _' the ' is fine, if I add the other characters, the ' gets preceded by a \ and an error is returned. If I take the ' out of the sting below it works fine, I get no errors returned. I am also using stripslashes on the variable. This is my code. (although I have tried various things with it trying to get it right) if(preg_match("/[EMAIL PROTECTED]&\(\)\*;:_.\'\$ ]+$/", $string)) { Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] preg_match problem
> -Original Message- > From: Paul Novitski [mailto:[EMAIL PROTECTED] > Sent: January 22, 2007 6:58 PM > To: PHP > Subject: Re: [PHP] preg_match problem > > At 1/22/2007 03:04 PM, Beauford wrote: > >I'm trying to get this but not quite there. I want to allow the > >following characters. > > > >[EMAIL PROTECTED]&()*;:_.'/\ and a space. > > > >Is there a special order these need to be in or escaped somehow. For > >example, if I just allow _' the ' is fine, if I add the other > >characters, the ' gets preceded by a \ and an error is > returned. If I > >take the ' out of the sting below it works fine, I get no errors > >returned. I am also using stripslashes on the variable. > > > >This is my code. (although I have tried various things with > it trying > >to get it right) > > > >if(preg_match("/[EMAIL PROTECTED]&\(\)\*;:_.\'\$ ]+$/", $string)) { > > > Please read this page: > > Pattern Syntax -- Describes PCRE regex syntax > http://ca.php.net/manual/en/reference.pcre.pattern.syntax.php > > specifically the section on character classes: > http://ca.php.net/manual/en/reference.pcre.pattern.syntax.php# > regexp.reference.squarebrackets > > In PREG there are few characters that you need to escape in a > character class expression: > > 1) ^ must be escaped (\^) if it's the first character (it > negates the match when it's unescaped in the first position). > > 2) ] must be escaped (\]) unless it's the first character of > the class (it closes the class if it appears later and is not > escaped). > > 3) \ must be escaped (\\) if you're referring to the > backslash character rather than using backslash to escape > another character. > > 4) Control codes such as \b for backspace (not to be confused > with \b which means word boundary outside of a character class). > > > In addition, you may need to escape certain characters in PHP if > you're expressing the RegExp pattern in a quoted string, such as > single or double quotes (whichever you're using to quote the pattern): > > '[\'"]' escape the apostophe > "['\"]" escape the quotation mark > > Those are PHP escapes -- by the time PREG sees the pattern, the PHP > compiler has rendered it to: > > ['"] > > And then of course there's the complication that both PREG and PHP > use the backslash as the escape character, so the pattern: > > [\\] escape the backslash > > must be expressed in PHP as: > > [] escape the escape and the backslash > > Interestingly, PHP compiles both \\\ and as \\, go figure. I > use to escape both backslashes to maintain some semblance of > logic and order in these eye-crossing expressions. > > Because PHP requires quotes to be escaped, I find it easier to write > & debug patterns in PHP if I express them in heredoc where quoting > and most escaping is unnecessary: > > $sPattern = <<<_ > ['"] > _; > > becomes the PREG pattern ['"\\]. > > > So to address your character class: > > >[EMAIL PROTECTED]&()*;:_.'/\ and a space. > > I'd use the pattern: > > [EMAIL PROTECTED]&()*;:_.'/\\ ] > > where the only character I need to escape is the backslash itself. > > In PHP this would be: > > $sPattern = '[EMAIL PROTECTED]&()*;:_.\'/ ]'; > (escaped apostrophe & blackslash) > or: > $sPattern = "[EMAIL PROTECTED]&()*;:_.'/ ]"; > (escaped blackslash) > or: > $sPattern = <<<_ > [EMAIL PROTECTED]&()*;:_.'/ ] > _; > (escaped blackslash) I've probably read 100 pages on this, and no matter what I try it doesn't work. Including all of what you suggested above - is my PHP possessed? if(preg_match("/[EMAIL PROTECTED]&()*;:_.'/\\ ]+$/", $string)) { gives me this error. Warning: preg_match() [function.preg-match]: Unknown modifier '\' in /constants.php on line 107 So if If you wouldn't mind, could you show me exactly what I need right from the beginning and explain why it works. i.e. if(preg_match(what goes here", $string)) { Echo "You got it"; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] preg_match problem
> if (preg_match('/[EMAIL PROTECTED]&()*;:_.'\\/ ]+$/', $string)) > > Use single quotes and double back-slashes. PHP strings also > have escape sequences that use the back-slash as escape > character, that's why you have to double them. And single > quotes to avoid the $ character interpreted as the start of a > variable. > > PS: Will we be risking going the perl way if we ask that PHP > supported regular expressions natively (I mean: without > having to provide them as strings)? I have tried all the examples posted in the last couple of days, and none of them, including the above work. Is there another solution to this, as this just seems to be way to buggy? Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /constants.php on line 107 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in //constants.php on line 107 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /constants.php on line 107 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /constants.php on line 107 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in //constants.php on line 107 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in //constants.php on line 107 Parse error: syntax error, unexpected ']' in //constants.php on line 107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] preg_match problem
> You need to escape that forward slash in the character class: > > preg_match("/[EMAIL PROTECTED]&()*;:_.'\/ > > Also, you've got only two backslashes in your char class. PHP is > reducing this to a single backslash before the space character. I > think you intend this to be two backslashes in the pattern so you > need four backslashes in PHP: > > preg_match("/[EMAIL PROTECTED]&()*;:_.'\/ ]+$/", $string) > On top of this, every time a ' is entered it gets preceded by \. If I just check for the characters like below that doesn't happen. Totally confused. if(preg_match("/^[-A-Za-z0-9_.' ]+$/", $string)) { -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] preg_match problem
> You don't need to escape the apostrophe if the pattern isn't > quoted with apostrophes in PHP or delimited by apostrophes in > the PREG pattern. But generally there's no harm in escaping > characters unnecessarily; it just makes for messier code. > > Here is a simple test of the regexp I recommended yesterday > using the pattern: > "/[EMAIL PROTECTED]&()*;:_.'\/ ]+$/" Ok, after a lot of testing and seriously losing it, this is what appears to be the issue. Blank lines or \n or some kind of carriage return is not allowed. The first example works, the others don't. I tried adding a carriage return, but who knows, I may be way out on left field with this. It's insane. sdfasd:spacespacespace http://fsdgas.asfs.asfs/ dfgfasg --- sdfasd:spacespacespace http://fsdgas.asfs.asfs/ dfgfasg --- Abcdefg [EMAIL PROTECTED] If there is another solution to doing this, I would definitely prefer it. This is just way to buggy, and I ran out of patience a week ago. This is on a production site, and is the only reason I have tried to get it working. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] preg_match problem
> Here is my rendition of what I think you are looking for. > > $str = 'tab( )/space( )/[EMAIL PROTECTED]&*();:...'; > > if ( preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]+$|', $str) ) { > echo 'success'; > } else { > echo 'failure'; > } > Here is the problem, and it is strange. If I enter each of the above characters into my form one at a time and hit submit after each one, NO error is produced for any of them. If I cut and past this all at once: [EMAIL PROTECTED]&*();:_.\ then an error IS returned. If I continue to remove one character at a time, submitting the form each time, errors ARE still produced. This is the code in a nutshell: If(isset($submit)) { $name = stripslashes($_POST['name']); >> I have tried this with and without $formerror = array(); unset($result); >> I have tried this with and without if($result = ValidateString($name)) { $formerror['name'] = $invalidcharacters; Function ValidateString($string) { if (!preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]+$|', $string) ) { return invalidchars; } } } Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] preg_match problem
Hi Jim, Thanks for all the help, but where is the link. > Here is a link to a page that has this on it, but with the added "'" > > Plus a link to the source code for it. > > Jim > > -- > PHP General Mailing List (http://www.php.net/) To > unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] LOL, preg_match still not working.
Hi, I previously had some issues with preg_match and many of you tried to help, but the same problem still exists. Here it is again, if anyone can explain to me how to get this to work it would be great - otherwise I'll just remove it as I just spent way to much time on this. Thanks Here's the code. if(empty($comment)) { $formerror['comment'] = nocomments; } elseif(!preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]+$|', $comment)) { $formerror['comment'] = invalidchars; } This produces an error, which I believe it should not. Testing 12345. This is a test of the emergency broadcast system. WAKE UP!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] LOL, preg_match still not working.
I've been over this a thousand times with various users on this list and escaping this and escaping that just doesn't matter. The error is that it thinks valid characters are invalid. In the case of the example I included, the ! and the period are invalid, which they should not be. The nocomments and invalidchars are constants. Thanks > -Original Message- > From: Ray Hauge [mailto:[EMAIL PROTECTED] > Sent: February 17, 2007 9:45 AM > To: Beauford > Cc: PHP > Subject: Re: [PHP] LOL, preg_match still not working. > > Maybe you just copied it wrong, but nocomments and > invalidchars are not > quoted, or they're constants. > > I don't think you have to, but you might need to escape some of the > characters (namely * and .) in your regex. It's been a while, so I'd > have to look it up. > > What's the error you are getting? > > Ray Hauge > Primate Applications > > > Beauford wrote: > > Hi, > > > > I previously had some issues with preg_match and many of > you tried to help, > > but the same problem still exists. Here it is again, if > anyone can explain > > to me how to get this to work it would be great - otherwise > I'll just remove > > it as I just spent way to much time on this. > > > > Thanks > > > > Here's the code. > > > > if(empty($comment)) { $formerror['comment'] = nocomments; > > } > > elseif(!preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]+$|', > > $comment)) { > > $formerror['comment'] = invalidchars; > > } > > > > This produces an error, which I believe it should not. > > > > Testing 12345. This is a test of the emergency broadcast system. > > > > WAKE UP!! > > > > -- > 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] LOL, preg_match still not working.
I am running PHP 4.4.4 on Slackware 10. > -Original Message- > From: Vahan Yerkanian [mailto:[EMAIL PROTECTED] > Sent: February 17, 2007 11:58 AM > To: php-general@lists.php.net > Subject: Re: [PHP] LOL, preg_match still not working. > > Are you running under FreeBSD 6.2 and/or upgraded recently > from 5.2.1 to > 5.2.2? > > I had the same problem on FreeBSD 6.2, with php5 installed from ports > collection after I portupgraded to 5.2.1. > > For me it appeared to be some kind weird misconfiguration > problem that > happened during the portupgrade... > > I had to: > > pkg_delete -rv "php5*" > rm -rf /var/db/ports/php5* > rm -rf /usr/local/lib/* > cd /usr/ports/lang/php5 > make install clean > cd /usr/ports/lang/php5-extensions > make install clean > > A bit harsh, but all of the preg_* errors disappeared since then. > > HTH, > Vahan > > > Steffen Ebermann wrote: > > Addendum: I encountered a problem when the string contains > linebreaks. Maybe > > adding \n\r into the brackets fixes your problem. > > > > > > On Sat, Feb 17, 2007 at 09:27:59AM -0500, Beauford wrote: > >> Hi, > >> > >> I previously had some issues with preg_match and many of > you tried to help, > >> but the same problem still exists. Here it is again, if > anyone can explain > >> to me how to get this to work it would be great - > otherwise I'll just remove > >> it as I just spent way to much time on this. > >> > >> Thanks > >> > >> Here's the code. > >> > >>if(empty($comment)) { $formerror['comment'] = nocomments; > >>} > >>elseif(!preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]+$|', > >> $comment)) { > >>$formerror['comment'] = invalidchars; > >>} > >> > >> This produces an error, which I believe it should not. > >> > >> Testing 12345. This is a test of the emergency broadcast system. > >> > >> WAKE UP!! > >> > >> -- > >> PHP General Mailing List (http://www.php.net/) > >> To unsubscribe, visit: http://www.php.net/unsub.php > >> > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: LOL, preg_match still not working.
Mails been down since this morning (sorry, that's yesterday morning). Anyway, not sure if this went through, so here it is again. -- The bottom line is I want to allow everything in the expression and nothing else. The new line does not seem to be an issue - I can put as many returns as I want, but as soon as I add some punctuation, it falls apart. As I said before, the ! and the period from my original example are reported as invalid - as they are in the expression they should be valid, I'm sure there are other examples as well, but you can see what the problem is. If I take out the ! and period from my example and leave the new lines in, it works fine. Thanks > -Original Message- > From: Gregory Beaver [mailto:[EMAIL PROTECTED] > Sent: February 17, 2007 12:21 PM > To: Beauford > Cc: PHP > Subject: [PHP] Re: LOL, preg_match still not working. > > Beauford wrote: > > Hi, > > > > I previously had some issues with preg_match and many of > you tried to help, > > but the same problem still exists. Here it is again, if > anyone can explain > > to me how to get this to work it would be great - otherwise > I'll just remove > > it as I just spent way to much time on this. > > > > Thanks > > > > Here's the code. > > > > if(empty($comment)) { $formerror['comment'] = nocomments; > > } > > elseif(!preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]+$|', > > $comment)) { > > $formerror['comment'] = invalidchars; > > } > > > > This produces an error, which I believe it should not. > > > > Testing 12345. This is a test of the emergency broadcast system. > > > > WAKE UP!! > > Hi, > > Your sample text contains newlines. If you wish to allow newlines, > instead of " \t" you should use the whitespace selector "\s" > > $comment = 'Testing 12345. This is a test of the emergency > broadcast system. > > WAKE UP!!'; > if(!preg_match('|[EMAIL PROTECTED]&*();:_.\s/-]+$|', $comment)) { > echo 'oops'; > } else { > echo 'ok'; > } > ?> > > Try that code sample, and you'll see that it says "ok" > > What exactly are you trying to accomplish with this > preg_match()? What > exactly are you trying to filter out? I understand you want to > eliminate "invalid characters" but why are they invalid? I > ask because > there may be a simpler way to solve the problem, if you can > explain what > the problem is. > > Thanks, > Greg > > -- > 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] Re: LOL, preg_match still not working.
Read my original email for the example string, I have referred to this in every one of my emails. It's even at the bottom of this one. -Original Message- From: Al [mailto:[EMAIL PROTECTED] Sent: February 18, 2007 10:35 AM To: php-general@lists.php.net Subject: [PHP] Re: LOL, preg_match still not working. If you want help, you must provide some example text strings that are to be matched. You keep posting your pattern and that's the problem. Beauford wrote: > Mails been down since this morning (sorry, that's yesterday morning). > Anyway, not sure if this went through, so here it is again. > > -- > > The bottom line is I want to allow everything in the expression and nothing > else. The new line does not seem to be an issue - I can put as many returns > as I want, but as soon as I add some punctuation, it falls apart. > > As I said before, the ! and the period from my original example are reported > as invalid - as they are in the expression they should be valid, I'm sure > there are other examples as well, but you can see what the problem is. If I > take out the ! and period from my example and leave the new lines in, it > works fine. > > Thanks > > > >> -Original Message- >> From: Gregory Beaver [mailto:[EMAIL PROTECTED] >> Sent: February 17, 2007 12:21 PM >> To: Beauford >> Cc: PHP >> Subject: [PHP] Re: LOL, preg_match still not working. >> >> Beauford wrote: >>> Hi, >>> >>> I previously had some issues with preg_match and many of >> you tried to help, >>> but the same problem still exists. Here it is again, if >> anyone can explain >>> to me how to get this to work it would be great - otherwise >> I'll just remove >>> it as I just spent way to much time on this. >>> >>> Thanks >>> >>> Here's the code. >>> >>> if(empty($comment)) { $formerror['comment'] = nocomments; >>> } >>> elseif(!preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]+$|', >>> $comment)) { >>> $formerror['comment'] = invalidchars; >>> } >>> >>> This produces an error, which I believe it should not. >>> >>> Testing 12345. This is a test of the emergency broadcast system. >>> >>> WAKE UP!! >> Hi, >> >> Your sample text contains newlines. If you wish to allow newlines, >> instead of " \t" you should use the whitespace selector "\s" >> >> > $comment = 'Testing 12345. This is a test of the emergency >> broadcast system. >> >> WAKE UP!!'; >> if(!preg_match('|[EMAIL PROTECTED]&*();:_.\s/-]+$|', $comment)) { >> echo 'oops'; >> } else { >> echo 'ok'; >> } >> ?> >> >> Try that code sample, and you'll see that it says "ok" >> >> What exactly are you trying to accomplish with this >> preg_match()? What >> exactly are you trying to filter out? I understand you want to >> eliminate "invalid characters" but why are they invalid? I >> ask because >> there may be a simpler way to solve the problem, if you can >> explain what >> the problem is. >> >> Thanks, >> Greg >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> >> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
FW: [PHP] Re: LOL, preg_match still not working.
I pasted this right from my PHP file, so it is correct. Just to elaborate. I have tested this until my eyes are bleeding. Sometimes this works sometimes it doesn't. One minute !!!##$$ This is a test &&%% will work the way it is supposed to, the next minute it does not. It seems that the first time through it is fine, but on the second time and on it is not. So if I keep hitting submit on my form with the above string, it will be ok on the first submit, but on subsequent submits it says there are invalid characters. Suffice it to say, it is wonky. It seems like it works when it wants to. Thanks -Original Message- From: Janet Valade [mailto:[EMAIL PROTECTED] Sent: February 18, 2007 11:07 AM To: Beauford Subject: Re: [PHP] Re: LOL, preg_match still not working. Perhaps the code in your email, that is working for other people, is not the same code that you are testing and having problems with. Perhaps you should try clipboarding the code from the email into a file to test yourself. Perhaps there is a typo in the code you are actually testing, so that it is not the same as the code in the email you sent to the list. Anyway, you can test that by clipboarding the code from your email, like others are doing, and testing it. Janet Beauford wrote: > Mails been down since this morning (sorry, that's yesterday morning). > Anyway, not sure if this went through, so here it is again. > > -- > > The bottom line is I want to allow everything in the expression and nothing > else. The new line does not seem to be an issue - I can put as many returns > as I want, but as soon as I add some punctuation, it falls apart. > > As I said before, the ! and the period from my original example are reported > as invalid - as they are in the expression they should be valid, I'm sure > there are other examples as well, but you can see what the problem is. If I > take out the ! and period from my example and leave the new lines in, it > works fine. > > Thanks > > > > >>-Original Message- >>From: Gregory Beaver [mailto:[EMAIL PROTECTED] >>Sent: February 17, 2007 12:21 PM >>To: Beauford >>Cc: PHP >>Subject: [PHP] Re: LOL, preg_match still not working. >> >>Beauford wrote: >> >>>Hi, >>> >>>I previously had some issues with preg_match and many of >> >>you tried to help, >> >>>but the same problem still exists. Here it is again, if >> >>anyone can explain >> >>>to me how to get this to work it would be great - otherwise >> >>I'll just remove >> >>>it as I just spent way to much time on this. >>> >>>Thanks >>> >>>Here's the code. >>> >>> if(empty($comment)) { $formerror['comment'] = nocomments; >>> } >>> elseif(!preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]+$|', >>>$comment)) { >>> $formerror['comment'] = invalidchars; >>> } >>> >>>This produces an error, which I believe it should not. >>> >>>Testing 12345. This is a test of the emergency broadcast system. >>> >>>WAKE UP!! >> >>Hi, >> >>Your sample text contains newlines. If you wish to allow newlines, >>instead of " \t" you should use the whitespace selector "\s" >> >>>$comment = 'Testing 12345. This is a test of the emergency >>broadcast system. >> >>WAKE UP!!'; >>if(!preg_match('|[EMAIL PROTECTED]&*();:_.\s/-]+$|', $comment)) { >>echo 'oops'; >>} else { >>echo 'ok'; >>} >>?> >> >>Try that code sample, and you'll see that it says "ok" >> >>What exactly are you trying to accomplish with this >>preg_match()? What >>exactly are you trying to filter out? I understand you want to >>eliminate "invalid characters" but why are they invalid? I >>ask because >>there may be a simpler way to solve the problem, if you can >>explain what >>the problem is. >> >>Thanks, >>Greg >> >>-- >>PHP General Mailing List (http://www.php.net/) >>To unsubscribe, visit: http://www.php.net/unsub.php >> >> >> > > -- Janet Valade -- janet.valade.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Upload and resize file
I downloaded this 'upload and resize image' script, and since I have no idea what I am looking at as this is something I have never done, could someone have a look and see what the problem might be. I've been searching around but haven't come across anything that makes any sense yet. When a picture needs to be resized I am getting the following error. If it is the same size or under I don't get this error. Warning: unlink() [function.unlink]: No such file or directory in /usr/local/apache/htdocs/website/upload.php on line 92 The full code is below. Thanks -- web.blazonry : PHP : Upload and Resize an Image ERRORImage Extension Unknown."; print "Please upload only a JPEG image with the extension .jpg or .jpeg ONLY"; print "The file you uploaded had the following extension: $pext\n"; /*== delete uploaded file ==*/ unlink($imgfile); exit(); } //-- RE-SIZING UPLOADED IMAGE /*== only resize if the image is larger than 250 x 200 ==*/ $imgsize = GetImageSize($imgfile); /*== check size 0=width, 1=height ==*/ if (($imgsize[0] > 250) || ($imgsize[1] > 200)) { /*== temp image file -- use "tempnam()" to generate the temp file name. This is done so if multiple people access the script at once they won't ruin each other's temp file ==*/ $tmpimg = tempnam("/tmp", "MKUP"); /*== RESIZE PROCESS 1. decompress jpeg image to pnm file (a raw image type) 2. scale pnm image 3. compress pnm file to jpeg image ==*/ /*== Step 1: djpeg decompresses jpeg to pnm ==*/ system("djpeg $imgfile >$tmpimg"); /*== Steps 2&3: scale image using pnmscale and then pipe into cjpeg to output jpeg file ==*/ system("pnmscale -xy 250 200 $tmpimg | cjpeg -smoo 10 -qual 50 >$imgfile"); /*== remove temp image ==*/ unlink($tmpimg); } /*== setup final file location and name ==*/ /*== change spaces to underscores in filename ==*/ $final_filename = str_replace(" ", "_", $imgfile_name); $newfile = $uploaddir . "/$final_filename"; /*== do extra security check to prevent malicious abuse==*/ if (is_uploaded_file($imgfile)) { /*== move file to proper directory ==*/ if (!copy($imgfile,"$newfile")) { /*== if an error occurs the file could not be written, read or possibly does not exist ==*/ print "Error Uploading File."; exit(); } } /*== delete the temporary uploaded file ==*/ unlink($imgfile); print(""); /*== DO WHATEVER ELSE YOU WANT SUCH AS INSERT DATA INTO A DATABASE ==*/ } ?> Upload and Resize an Image Upload Image: Click browse to upload a local file -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Upload and resize file
Been finding that out about the script. I have downloaded another and it works great. I just have to do some tweaking to suit my needs, but bottom line is it works. Thx > -Original Message- > From: Børge Holen [mailto:[EMAIL PROTECTED] > Sent: August 23, 2007 3:30 PM > To: php-general@lists.php.net > Subject: Re: [PHP] Re: Upload and resize file > > On Thursday 23 August 2007 14:50, Al wrote: > > Suggest you find another script. That one is weird and not > simple PHP > > code, which will do your task easily. > > just my thoughts to > > > > > Beauford wrote: > > > I downloaded this 'upload and resize image' script, and > since I have > > > no idea what I am looking at as this is something I have > never done, > > > could someone have a look and see what the problem might > be. I've > > > been searching around but haven't come across anything that makes > > > any sense yet. > > > > > > When a picture needs to be resized I am getting the > following error. > > > If it is the same size or under I don't get this error. > > > > > > Warning: unlink() [function.unlink]: No such file or directory in > > > /usr/local/apache/htdocs/website/upload.php on line 92 > > > > > > The full code is below. > > > > > > Thanks > > > > > > -- > > > > > > > > > > > > > > > web.blazonry : PHP : Upload and Resize an Image > > > > > > > > > > > if ($_SERVER['REQUEST_METHOD'] == "POST") { > > > > > > /* SUBMITTED INFORMATION - use what you need > > > * temporary filename (pointer): $imgfile > > > * original filename : $imgfile_name > > > * size of uploaded file : $imgfile_size > > > * mime-type of uploaded file : $imgfile_type > > > */ > > > > > > /*== upload directory where the file will be stored > > > relative to where script is run ==*/ > > > > > > $uploaddir = "images"; > > > > > > > > > /*== get file extension (fn at bottom of script) ==*/ > > > /*== checks to see if image file, if not do not allow > upload ==*/ > > > $pext = getFileExtension($imgfile_name); > > > $pext = strtolower($pext); > > > if (($pext != "jpg") && ($pext != "jpeg")) > > > { > > > print "ERRORImage Extension Unknown."; > > > print "Please upload only a JPEG image with > the extension > > > .jpg or .jpeg ONLY"; > > > print "The file you uploaded had the following extension: > > > $pext\n"; > > > > > > /*== delete uploaded file ==*/ > > > unlink($imgfile); > > > exit(); > > > } > > > > > > > > > //-- RE-SIZING UPLOADED IMAGE > > > > > > /*== only resize if the image is larger than 250 x 200 ==*/ > > > $imgsize = GetImageSize($imgfile); > > > > > > /*== check size 0=width, 1=height ==*/ > > > if (($imgsize[0] > 250) || ($imgsize[1] > 200)) > > > { > > > /*== temp image file -- use "tempnam()" to > generate the temp > > > file name. This is done so if multiple > people access the > > > script at once they won't ruin each other's > temp file ==*/ > > > $tmpimg = tempnam("/tmp", "MKUP"); > > > > > > /*== RESIZE PROCESS > > > 1. decompress jpeg image to pnm file (a raw > image type) > > > 2. scale pnm image > > > 3. compress pnm file to jpeg image > > > ==*/ > > > > > > /*== Step 1: djpeg decompresses jpeg to pnm ==*/ > > > system("djpeg $imgfile >$tmpimg"); > > > > > > > > > /*== Steps 2&3: scale image using pnmscale and then > > > pipe into cjpeg to output jpeg file ==*/ > > > system("pnmscale -xy 250 200 $tmpimg | cjpeg > -smoo 10 -qual > > > 50 > > > > > >> $imgfile"); > > > > > > /*== remove temp image ==*/ > > > unlink($tmpimg); > > > > > >
[PHP] How do I get Apache 1.3.36 to use PHP 5
Not to sound like a total nob, but how do I get Apache 1.3.36 to use PHP5. I have both 4 and 5 installed, but it still uses 4. I never had a problem with 4. I read the followed the INSTALL file for PHP5, below. I reinstall Apache as well and nothing - step 11. I tried putting LoadModule php5_module /usr/local/apache/libphp5.so in my http.conf, but it doesn't exist. Any help is appreciated. Example 2-2. Installation Instructions (Static Module Installation for Apache) for PHP 1. gunzip -c apache_1.3.x.tar.gz | tar xf - 2. cd apache_1.3.x 3. ./configure 4. cd .. 5. gunzip -c php-5.x.y.tar.gz | tar xf - 6. cd php-5.x.y 7. ./configure --with-mysql --with-apache=../apache_1.3.x 8. make 9. make install 10. cd ../apache_1.3.x 11. ./configure --prefix=/www --activate-module=src/modules/php5/libphp5.a (The above line is correct! Yes, we know libphp5.a does not exist at this stage. It isn't supposed to. It will be created.) 12. make (you should now have an httpd binary which you can copy to your Apache bin d ir if it is your first install then you need to "make install" as well) 13. cd ../php-5.x.y 14. cp php.ini-dist /usr/local/lib/php.ini -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] List
Does anyone else have this problem with the list. It seems that every time I check my email there is one or more messages from the list that royally screws up Outlook. I usually have to delete all list messages from the actual server and reboot. It only happens with emails from [EMAIL PROTECTED] Just trying to narrow down the problem. Not sure if this is spam that's sneaking into the list messing things up or what. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP 5, Windows, and MySQL
Aside from my previous gd problems, here's another problem. It appears that PHP5 (for Windows anyways) does not support MySQL (which in itself is riduculous), but here's my problem. I have a script I just downloaded that works perfectly on Linux/Apche/MySQL/PHP5, but when I run it on Windows 2000 with PHP 4.4 I get a page full of errors. Lets forget about the errors, does anyone have any idea how to get PHP5 and MySQL to work on Windows. I have already tried 100 different variations of things from information I found searching out this problem, but maybe someone has a new idea. If it were me I'd just run this site on Linux, but this is for a friend who wants to use IIS. If your curious the errors are below. Thanks B Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in G:\Websites\Webtest\caalogin\include\database.php on line 207 Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in G:\Websites\Webtest\caalogin\include\database.php on line 218 Warning: session_start(): Cannot send session cookie - headers already sent by (output started at G:\Websites\Webtest\caalogin\include\database.php:207) in G:\Websites\Webtest\caalogin\include\session.php on line 46 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at G:\Websites\Webtest\caalogin\include\database.php:207) in G:\Websites\Webtest\caalogin\include\session.php on line 46 Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in G:\Websites\Webtest\caalogin\include\database.php on line 218 Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in G:\Websites\Webtest\caalogin\include\database.php on line 207 Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in G:\Websites\Webtest\caalogin\include\database.php on line 218 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP 5, Windows, and MySQL
>From what I have been reading this is a known issue with PHP5. There is something in the php_mysql.dll which is not compatible. I wasted 3 hours today trying all the tips and tricks I could find, but the bottom line is that it won't work. This was my reason for posting to this group to see if anyone has any ideas. Here is one of the many links I was looking at to try and solve this. http://codewalkers.com/forum/index.php?action=displaythread&forum=phphelp&id =370&realm=default Thanks -Original Message- From: Janet Valade [mailto:[EMAIL PROTECTED] Sent: June 26, 2006 4:08 PM To: Beauford Subject: Re: [PHP] PHP 5, Windows, and MySQL Activating MySQL in PHP 5 is pretty simple. Open the php.ini file and uncomment the line for the extension that you want to use--php_mysql.dll or php_mysqli.dll. Restart the web server. Using the mysql functions is described in the php documentation. http://us3.php.net/manual/en/ref.mysql.php or http://us3.php.net/manual/en/ref.mysqli.php Janet Beauford wrote: > Aside from my previous gd problems, here's another problem. It appears > that > PHP5 (for Windows anyways) does not support MySQL (which in itself is > riduculous), but here's my problem. I have a script I just downloaded > that works perfectly on Linux/Apche/MySQL/PHP5, but when I run it on > Windows 2000 with PHP 4.4 I get a page full of errors. Lets forget > about the errors, does anyone have any idea how to get PHP5 and MySQL > to work on Windows. I have already tried 100 different variations of > things from information I found searching out this problem, but maybe someone has a new idea. > > If it were me I'd just run this site on Linux, but this is for a > friend who wants to use IIS. If your curious the errors are below. > > Thanks > > B > > Warning: mysql_numrows(): supplied argument is not a valid MySQL > result resource in G:\Websites\Webtest\caalogin\include\database.php > on line 207 > > Warning: mysql_numrows(): supplied argument is not a valid MySQL > result resource in G:\Websites\Webtest\caalogin\include\database.php > on line 218 > > Warning: session_start(): Cannot send session cookie - headers already > sent by (output started at > G:\Websites\Webtest\caalogin\include\database.php:207) > in G:\Websites\Webtest\caalogin\include\session.php on line 46 > > Warning: session_start(): Cannot send session cache limiter - headers > already sent (output started at > G:\Websites\Webtest\caalogin\include\database.php:207) in > G:\Websites\Webtest\caalogin\include\session.php on line 46 > > Warning: mysql_numrows(): supplied argument is not a valid MySQL > result resource in G:\Websites\Webtest\caalogin\include\database.php > on line 218 > > Warning: mysql_numrows(): supplied argument is not a valid MySQL > result resource in G:\Websites\Webtest\caalogin\include\database.php > on line 207 > > Warning: mysql_numrows(): supplied argument is not a valid MySQL > result resource in G:\Websites\Webtest\caalogin\include\database.php > on line 218 > -- Janet Valade -- janet.valade.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: PHP 5, Windows, and MySQL
Done all this, I spent another two hours last night and have gone back to PHP 4.4 which works perfect. I have followed every article I could find to the 'T' and it just refuses to work. I have version 4.1.15 of MySQL. I'm afraid to upgrade that as who know what mess it will cause. libmysql.dll is in /winnt, /system, /sytem32, /php and php is in my path. If it can't find it it ain't looking hard enough. I'll just keep it the way it is for now - can't afford anymore time on it. Thanks -Original Message- From: Jeremy Schreckhise [mailto:[EMAIL PROTECTED] Sent: June 27, 2006 11:14 AM To: php-general@lists.php.net Subject: [PHP] Re: PHP 5, Windows, and MySQL I ran into the same problems; here is how I solved them. 1. Install MySQL 5 2. Install PHP 5 3. Modify php.ini extensions directive to point to php_mysql.dll (the one that was packaged with php 5) 4. Here is the tricky one make sure mysql is finding the libmysql.dll packaged WITH MYSQL NOT PHP; 5. net stop mysql 6. net start mysql 7. work hard; play hard -Original Message- From: João Cândido de Souza Neto [mailto:[EMAIL PROTECTED] Sent: Monday, June 26, 2006 8:13 PM To: php-general@lists.php.net Subject: [PHP] Re: PHP 5, Windows, and MySQL I've got it running fine on my windows. Mysql 5.0.19 PHP 5.1.4 I just activate php_mysql.dll and php_mysqli.dll. Which versions of php and mysql are you using? ""Beauford"" <[EMAIL PROTECTED]> escreveu na mensagem news:!&!AAAYAFzLTDhDwWBHpzgX5w1qDiPigAAAEJiz/MDHLf9Fmsyy [EMAIL PROTECTED] > Aside from my previous gd problems, here's another problem. It appears > that > PHP5 (for Windows anyways) does not support MySQL (which in itself is > riduculous), but here's my problem. I have a script I just downloaded > that works perfectly on Linux/Apche/MySQL/PHP5, but when I run it on > Windows 2000 with PHP 4.4 I get a page full of errors. Lets forget > about the errors, does anyone have any idea how to get PHP5 and MySQL > to work on Windows. I have already tried 100 different variations of > things from information I found searching out this problem, but maybe > someone has a new idea. > > If it were me I'd just run this site on Linux, but this is for a > friend who wants to use IIS. If your curious the errors are below. > > Thanks > > B > > Warning: mysql_numrows(): supplied argument is not a valid MySQL > result resource in G:\Websites\Webtest\caalogin\include\database.php > on line 207 > > Warning: mysql_numrows(): supplied argument is not a valid MySQL > result resource in G:\Websites\Webtest\caalogin\include\database.php > on line 218 > > Warning: session_start(): Cannot send session cookie - headers already > sent by (output started at > G:\Websites\Webtest\caalogin\include\database.php:207) > in G:\Websites\Webtest\caalogin\include\session.php on line 46 > > Warning: session_start(): Cannot send session cache limiter - headers > already sent (output started at > G:\Websites\Webtest\caalogin\include\database.php:207) in > G:\Websites\Webtest\caalogin\include\session.php on line 46 > > Warning: mysql_numrows(): supplied argument is not a valid MySQL > result resource in G:\Websites\Webtest\caalogin\include\database.php > on line 218 > > Warning: mysql_numrows(): supplied argument is not a valid MySQL > result resource in G:\Websites\Webtest\caalogin\include\database.php > on line 207 > > Warning: mysql_numrows(): supplied argument is not a valid MySQL > result resource in G:\Websites\Webtest\caalogin\include\database.php > on line 218 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP 5, Windows, and MySQL
I have done everything that everyone has suggested here, and 1000 other variations that I have found along the way. So if I'm doing something wrong - please let me know, 'cause I don't see it. MySQL 4.1 has been working great for 4 years and PHP4.4 gives me no problems. Anything 5 and above won't work. Windows is 2000 SP4. PHP is installed as an ISAPI module. ;cgi.force_redirect = 1 libmysql.dll is in /winnt, /system, /sytem32, /php and php is in my path. If it can't find it it ain't looking hard enough. I've also tried many variations of this. The error below is similar to what I got. I was also getting memory errors, but don't have that one to post. Results: Warning: PHP Startup: Unable to load dynamic library 'c:/php/ext/php_mysql.dll' - The specified procedure could not be found. in Unknown on line 0 Content-type: text/html X-Powered-By: PHP/5.0.0 php running Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\CAFGPHP\test.php on line 4 PHP Warning: PHP Startup: Unable to load dynamic library 'c:/php/ext/php_mysql.dll' - The specified procedure could not be found. in Unknown on line 0 Thanks -Original Message- From: Janet Valade [mailto:[EMAIL PROTECTED] Sent: June 26, 2006 7:43 PM To: Beauford Subject: Re: [PHP] PHP 5, Windows, and MySQL Well, I don't know what you mean by a known issue. All your message says is that PHP 5 does not support MySQL. Yes, it does. It has no problem. I have installed it and used it a million times. So, you are doing something wrong. Did you test PHP 5 by itself, to make sure that it works without accessing MySQL? Did you test MySQL by itself, to be sure the server is running correctly when it is accessed outside of PHP 5. Did you install MysQL using its installer? That's the best way. What version of MySQL? What Windows? Did you turn cgi.force_redirect off in the php.ini file? You have to do that if you are using IIS. What error do you get? Janet Beauford wrote: >>From what I have been reading this is a known issue with PHP5. There >>is > something in the php_mysql.dll which is not compatible. > > I wasted 3 hours today trying all the tips and tricks I could find, > but the bottom line is that it won't work. > > This was my reason for posting to this group to see if anyone has any ideas. > > Here is one of the many links I was looking at to try and solve this. > http://codewalkers.com/forum/index.php?action=displaythread&forum=php > elp&id > =370&realm=default > > Thanks > > -Original Message- > From: Janet Valade [mailto:[EMAIL PROTECTED] > Sent: June 26, 2006 4:08 PM > To: Beauford > Subject: Re: [PHP] PHP 5, Windows, and MySQL > > Activating MySQL in PHP 5 is pretty simple. Open the php.ini file and > uncomment the line for the extension that you want to > use--php_mysql.dll or php_mysqli.dll. Restart the web server. > > Using the mysql functions is described in the php documentation. > http://us3.php.net/manual/en/ref.mysql.php or > http://us3.php.net/manual/en/ref.mysqli.php > > Janet > > Beauford wrote: > > >>Aside from my previous gd problems, here's another problem. It appears >>that >>PHP5 (for Windows anyways) does not support MySQL (which in itself is >>riduculous), but here's my problem. I have a script I just downloaded >>that works perfectly on Linux/Apche/MySQL/PHP5, but when I run it on >>Windows 2000 with PHP 4.4 I get a page full of errors. Lets forget >>about the errors, does anyone have any idea how to get PHP5 and MySQL >>to work on Windows. I have already tried 100 different variations of >>things from information I found searching out this problem, but maybe > > someone has a new idea. > >>If it were me I'd just run this site on Linux, but this is for a >>friend who wants to use IIS. If your curious the errors are below. >> >>Thanks >> >>B >> >>Warning: mysql_numrows(): supplied argument is not a valid MySQL >>result resource in G:\Websites\Webtest\caalogin\include\database.php >>on line 207 >> >>Warning: mysql_numrows(): supplied argument is not a valid MySQL >>result resource in G:\Websites\Webtest\caalogin\include\database.php >>on line 218 >> >>Warning: session_start(): Cannot send session cookie - headers already >>sent by (output started at >>G:\Websites\Webtest\caalogin\include\database.php:207) >>in G:\Websites\Webtest\caalogin\include\session.php on line 46 >> >>Warning: session_start(): Cannot send session cache limiter - headers >>already sent (output started at >>G:\Websites\Webtest\caalogin\include\database.php:207) in >>G:\Websit
[PHP] Ereg problem
One more in my recent woes. The last elseif does not work in the code below - even if the string is correct it always says it's incorrect. Even if I remove everything else and just have the ereg satement is doesn't work either. The code below is in a function and $_POST['password1'] is passed to the function. $field = "password1"; //Use field name for password if(!$subpass){ $form->setError($field, " Password not entered"); } elseif(strlen($subpass) < 6) { $form->setError($field, " Too Short"); } elseif(strlen($subpass) > 10) { $form->setError($field, " Too Long"); } elseif(!ereg('[^A-Za-z0-9]', trim($subpass))) { $form->setError($field, " Not alphanumeric"); } Thanks B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: PHP 5, Windows, and MySQL
Neither one will work. -Original Message- From: Jeremy Schreckhise [mailto:[EMAIL PROTECTED] Sent: June 27, 2006 11:37 AM To: 'Beauford'; php-general@lists.php.net Subject: RE: [PHP] Re: PHP 5, Windows, and MySQL But is libmysql.dll the dll from mysql; the one packaged with php 5 will not work. Jeremy Schreckhise, M.B.A -Original Message----- From: Beauford [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 27, 2006 10:33 AM To: php-general@lists.php.net Subject: RE: [PHP] Re: PHP 5, Windows, and MySQL Done all this, I spent another two hours last night and have gone back to PHP 4.4 which works perfect. I have followed every article I could find to the 'T' and it just refuses to work. I have version 4.1.15 of MySQL. I'm afraid to upgrade that as who know what mess it will cause. libmysql.dll is in /winnt, /system, /sytem32, /php and php is in my path. If it can't find it it ain't looking hard enough. I'll just keep it the way it is for now - can't afford anymore time on it. Thanks -Original Message- From: Jeremy Schreckhise [mailto:[EMAIL PROTECTED] Sent: June 27, 2006 11:14 AM To: php-general@lists.php.net Subject: [PHP] Re: PHP 5, Windows, and MySQL I ran into the same problems; here is how I solved them. 1. Install MySQL 5 2. Install PHP 5 3. Modify php.ini extensions directive to point to php_mysql.dll (the one that was packaged with php 5) 4. Here is the tricky one make sure mysql is finding the libmysql.dll packaged WITH MYSQL NOT PHP; 5. net stop mysql 6. net start mysql 7. work hard; play hard -Original Message- From: João Cândido de Souza Neto [mailto:[EMAIL PROTECTED] Sent: Monday, June 26, 2006 8:13 PM To: php-general@lists.php.net Subject: [PHP] Re: PHP 5, Windows, and MySQL I've got it running fine on my windows. Mysql 5.0.19 PHP 5.1.4 I just activate php_mysql.dll and php_mysqli.dll. Which versions of php and mysql are you using? ""Beauford"" <[EMAIL PROTECTED]> escreveu na mensagem news:!&!AAAYAFzLTDhDwWBHpzgX5w1qDiPigAAAEJiz/MDHLf9Fmsyy [EMAIL PROTECTED] > Aside from my previous gd problems, here's another problem. It appears > that > PHP5 (for Windows anyways) does not support MySQL (which in itself is > riduculous), but here's my problem. I have a script I just downloaded > that works perfectly on Linux/Apche/MySQL/PHP5, but when I run it on > Windows 2000 with PHP 4.4 I get a page full of errors. Lets forget > about the errors, does anyone have any idea how to get PHP5 and MySQL > to work on Windows. I have already tried 100 different variations of > things from information I found searching out this problem, but maybe > someone has a new idea. > > If it were me I'd just run this site on Linux, but this is for a > friend who wants to use IIS. If your curious the errors are below. > > Thanks > > B > > Warning: mysql_numrows(): supplied argument is not a valid MySQL > result resource in G:\Websites\Webtest\caalogin\include\database.php > on line 207 > > Warning: mysql_numrows(): supplied argument is not a valid MySQL > result resource in G:\Websites\Webtest\caalogin\include\database.php > on line 218 > > Warning: session_start(): Cannot send session cookie - headers already > sent by (output started at > G:\Websites\Webtest\caalogin\include\database.php:207) > in G:\Websites\Webtest\caalogin\include\session.php on line 46 > > Warning: session_start(): Cannot send session cache limiter - headers > already sent (output started at > G:\Websites\Webtest\caalogin\include\database.php:207) in > G:\Websites\Webtest\caalogin\include\session.php on line 46 > > Warning: mysql_numrows(): supplied argument is not a valid MySQL > result resource in G:\Websites\Webtest\caalogin\include\database.php > on line 218 > > Warning: mysql_numrows(): supplied argument is not a valid MySQL > result resource in G:\Websites\Webtest\caalogin\include\database.php > on line 207 > > Warning: mysql_numrows(): supplied argument is not a valid MySQL > result resource in G:\Websites\Webtest\caalogin\include\database.php > on line 218 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP 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] Ereg problem
-Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: June 27, 2006 12:58 PM To: Beauford Cc: PHP-General Subject: Re: [PHP] Ereg problem On Tue, 2006-06-27 at 12:14, Beauford wrote: > One more in my recent woes. The last elseif does not work in the code > below > - even if the string is correct it always says it's incorrect. Even if > I remove everything else and just have the ereg satement is doesn't > work either. > > The code below is in a function and $_POST['password1'] is passed to > the function. > > $field = "password1"; //Use field name for password > > if(!$subpass){ > $form->setError($field, " Password not entered"); > } > elseif(strlen($subpass) < 6) { > $form->setError($field, " Too Short"); > } > elseif(strlen($subpass) > 10) { > $form->setError($field, " Too Long"); > } > elseif(!ereg('[^A-Za-z0-9]', trim($subpass))) { > $form->setError($field, " Not alphanumeric"); > } You're double negating. You check the negative return of ereg() and ereg checks for the pattern NOT existing. Ahhh, I was thinking of it the other way round. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Quick Question re: Windows/Linux PHP
Hi, I'm just curious, because I come across this from time to time. Why does the code below work on Windows and not on Linux. PHP is 5.0 on Linux and 4.4 on Windows (still can't get 5 on Windows). The code at the very bottom is how I got it to work on Linux. Also, why is it with the same setup I can't call a function within a function in Linux, but can in Windows. Sorry I don't have the error, but something about calling a static function. Would this be a difference between OS's or with the different versions of PHP? Thanks B --- if (empty($subemail)) { $form->setError($field, emailnotentered); } else { $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*" ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*" ."\.([a-z]{2,}){1}$"; if(!eregi($regex,$subemail)){ $form->setError($field, emailinvalid); } $subemail = stripslashes($subemail); } elseif(in_array(strtolower($a), $language)) $form->setError($field, profanity); elseif(in_array(strtolower($b), $language)) $form->setError($field, profanity); elseif(in_array(strtolower($c), $language)) $form->setError($field, profanity); else { $query = "SELECT * FROM users WHERE $subemail = 'email'"; $result = mysql_query($query)or $mysqlerror = mysql_error(); if ($mysqlerror) { $form->setError($field, tberror); } else { $numrows = mysql_fetch_row($result); if($numrows = mysql_num_rows($result)) { $form->setError($field, duplicatepassword); } } } --- $field = "email"; list ($a, $b, $c) = split ('[EMAIL PROTECTED]', $subemail); $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)[EMAIL PROTECTED](\.[a-z0-9-]{1,})*\.([a-z]{2,}){1} $"; if (empty($subemail)) { $form->setError($field, emailnotentered); } elseif(!eregi($regex,$subemail)){ $form->setError($field, emailinvalid); } elseif(in_array(strtolower($a), $language)) $form->setError($field, profanity); elseif(in_array(strtolower($b), $language)) $form->setError($field, profanity); elseif(in_array(strtolower($c), $language)) $form->setError($field, profanity); else { $query = "SELECT * FROM users WHERE $subemail = 'email'"; $result = mysql_query($query)or $mysqlerror = mysql_error(); if ($mysqlerror) { $form->setError($field, tberror); } else { $numrows = mysql_fetch_row($result); if($numrows = mysql_num_rows($result)) { $form->setError($field, duplicatepassword); } } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php_mysql.dll
Good luck. I have tried 1001 ways to try and get PHP 5.xx to work on Windows with no luck. Everyone says it's simple, but I believe there is a bug in PHP 5. I have no problem in Linux, but on Windows - that's another story. If you do a search of the archives for this list I'm sure there are tons of posts about it. Let me know if you figure it out as I'd be curious to know how you did it. For now I'll just stay with PHP 4.4. B -Original Message- From: João Cândido de Souza Neto [mailto:[EMAIL PROTECTED] Sent: July 8, 2006 10:53 PM To: php-general@lists.php.net Subject: [PHP] php_mysql.dll Hi everyone. I'm having some troubles in php5 on windows trying to load php_mysql.dll. When i try to run a page that just has it gives me the follow error: PHP Warning: PHP Startup: Unable to load dynamic library './ext/php_mysql.dll' - Não foi possível encontrar o módulo especificado. in Unknown on line 0 Someone knows wath i ought to do for solve that? Thanks in advantage... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Question on explode and join.
Hi, I have a form which I want to check for inappropriate words before it is posted. I have used explode to put the string into an array using a space as the delimiter and then I check it against another array that contains the inappropriate words. I then replace the inappropriate words with *'s and join the array back into a string. This works perfectly except for one thing. If the word in the string has a any kind of punctuation after it (period, comma) it won't be matched. So if moron is an inappropriate word then "you are a moron" works, but "you are a moron." won't. Any ideas? Thanks This is my code. function badwords($string) { $language = array(contains the inappropriate words); $words = explode(" ",$string); $count = count(explode(" ", $string)); for($i = 0; $i < $count; $i++) { if(in_array(strtolower($words[$i]), $language)) { $words[$i] = "*"; } } $newcomments = join(" ",$words); return $newcomments; }
RE: [PHP] Question on explode and join.
There ya go. Works and is shorter than what I did. Thanks. One other question. if I have bunny and bunnyhole in the badword array. if someone types in bunnyhole, I end up getting *hole in the clean string. If I change the order of the words in the array would that solve the problem? Thanks _ From: Eric Butera [mailto:[EMAIL PROTECTED] Sent: September 13, 2006 1:07 PM To: Beauford Cc: php Subject: Re: [PHP] Question on explode and join. On 9/13/06, Beauford <[EMAIL PROTECTED]> wrote: Hi, I have a form which I want to check for inappropriate words before it is posted. I have used explode to put the string into an array using a space as the delimiter and then I check it against another array that contains the inappropriate words. I then replace the inappropriate words with *'s and join the array back into a string. This works perfectly except for one thing. If the word in the string has a any kind of punctuation after it (period, comma) it won't be matched. So if moron is an inappropriate word then "you are a moron" works, but "you are a moron." won't. Any ideas? Thanks This is my code. function badwords($string) { $language = array(contains the inappropriate words); $words = explode(" ",$string); $count = count(explode(" ", $string)); for($i = 0; $i < $count; $i++) { if(in_array(strtolower($words[$i]), $language)) { $words[$i] = "*"; } } $newcomments = join(" ",$words); return $newcomments; } Perhaps you could try an approach like this: string: ". $string; echo "clean: ". $clean; GENERATES: string: Lorem ipsum ius no etiam veniam, usu alii novum ne, sed cu molestiae eloquentiam. Vero invenire philosophia est ne, quo nemore timeam an. clean: Lorem * ius no etiam veniam, usu alii novum ne, sed cu molestiae *. * invenire philosophia est ne, quo nemore timeam an.
RE: [PHP] Question on explode and join.
The problem with scripts like these is there is so many variables to deal with. First, this doesn't deal with uppercase. So a word like bAdWoRd would not get detected, or a word beginning a sentence. Also, a word within a word like wordbadwordword would not be detected, and I'm sure there are more I haven't discovered yet. I haven't had much time to play around with it since earlier today, so I haven't experimented with it, but ideas are welcome. Thanks -Original Message- From: Ducarom [mailto:[EMAIL PROTECTED] Sent: September 13, 2006 2:26 PM To: Beauford Cc: php Subject: Re: [PHP] Question on explode and join. I made some changes to the script from Butera. Now it only replaces complete words. $dirty = array( 'ipsum', 'eloquentiam', 'Vero' ); foreach ($dirty as $key => $word) { $dirty[$key] = '/\b'. $word . '\b/'; } $string = "Lorem ipsum ius no etiam veniam, usu alii novum ne, sed cu molestiae eloquentiam. Vero invenire philosophia est ne, quo nemore timeam an."; $clean = preg_replace($dirty, '*', $string); echo "string: ". $string; echo "clean: ". $clean; On 9/13/06, Beauford <[EMAIL PROTECTED]> wrote: > > There ya go. Works and is shorter than what I did. Thanks. > > One other question. if I have bunny and bunnyhole in the badword > array. if someone types in bunnyhole, I end up getting *hole in the > clean string. If I change the order of the words in the array would > that solve the problem? > > Thanks > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question on explode and join.
I read your email, but I'm not using sessions and not really planning too. But some of your code may be able to be modified to do what I need. Thanks for the input. B _ From: Dave Goodchild [mailto:[EMAIL PROTECTED] Sent: September 14, 2006 8:52 AM To: Beauford Subject: Re: [PHP] Question on explode and join. Hi. If you re-read my reponse you will see that it uses preg_replace with the i flag which ignores case and will match banned words within words. With a little modification (I can help if you like) you can easily use it in your case.
[PHP] Override php.ini
Is there a way I can use <% %> instead of for the opening and closing tags of a php script. I thought I read this somewhere but can't find anything on it now. Is there something that I could do with override php.ini command? I don't have access to the php.ini file on this server. Thanks B
RE: [PHP] Override php.ini
I wouldn't use it myself, but a buddy who is using Frontpage is complaining that it automatically changes and wanted to know how to get around this. I suggested not using FP and get a real editor. Thanks to others that replied. B -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: September 22, 2006 8:02 PM To: Beauford Cc: PHP Subject: Re: [PHP] Override php.ini On Fri, September 22, 2006 11:42 am, Beauford wrote: > Is there a way I can use <% %> instead of for the opening and > closing tags of a php script. I thought I read this somewhere but > can't find anything on it now. > > Is there something that I could do with override php.ini command? I > don't have access to the php.ini file on this server. You can do this in .htaccess under Apache, or with ini_set (which would have to be in But you SHOULD NOT DO THIS Nobody else on the planet is using <% for PHP, and it's unlikely to be all that useful to you. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Query question
Hi, I have a MySQL database with a date field and a bunch of other fields. The date field is in the format - 01/01/2006. What I want to do is query the database and create a table that shows just the year and how many instances of the year there is. I have been taxing my brain for a simple solution, but just not getting it. Any suggestions? Thanks Example output. YearCount 20025 20038 20049 200515 200622 ps - I get this information sent to me and I can't change any of the data. I just enter it in the db and then hopefully do the query on it.
RE: [PHP] Query question
I posted this here as I figured I would need to manipulate this using PHP. The code below doesn't quite work because the date is in the format of 05/05/2006. So I am getting totals for each date, not each year. I need the totals for each year, regardless of the day or month. This is why I figured I'd need to use PHP to maybe put it in an array first or something. Thanks -Original Message- From: Joe Wollard [mailto:[EMAIL PROTECTED] Sent: October 28, 2006 10:30 PM To: Ed Lazor Cc: Beauford; PHP Subject: Re: [PHP] Query question Agreed, this should go to a MySQL list. But in the spirit of helping I think the following should give you a good starting point. SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote: > > Use the mysql list :) > > > On Oct 28, 2006, at 3:01 PM, Beauford wrote: > > > Hi, > > > > I have a MySQL database with a date field and a bunch of other > > fields. The date field is in the format - 01/01/2006. What I want to > > do is query the database and create a table that shows just the year > > and how many instances of the year there is. I have been taxing my > > brain for a simple solution, but just not getting it. Any > > suggestions? > > > > Thanks > > > > Example output. > > > > Year Count > > > > 2002 5 > > 2003 8 > > 2004 9 > > 2005 15 > > 2006 22 > > > > ps - I get this information sent to me and I can't change any of the > > data. I just enter it in the db and then hopefully do the query on > > it. > > > > > > -- > 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] Query question
This is what I finally figured out, which works just perfectly. select count(date) as count, substring(date,8) as year from stats group by year; Thanks to all for the input. -Original Message- From: Joe Wollard [mailto:[EMAIL PROTECTED] Sent: October 29, 2006 12:15 AM To: Beauford Cc: PHP Subject: Re: [PHP] Query question Look into the MySQL YEAR() function to extract the year from a specific date. Start here: http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html On 10/28/06, Beauford <[EMAIL PROTECTED]> wrote: > > I posted this here as I figured I would need to manipulate this using PHP. > The code below doesn't quite work because the date is in the format of > 05/05/2006. So I am getting totals for each date, not each year. I > need the totals for each year, regardless of the day or month. This is > why I figured I'd need to use PHP to maybe put it in an array first or > something. > > Thanks > > -Original Message- > From: Joe Wollard [mailto:[EMAIL PROTECTED] > Sent: October 28, 2006 10:30 PM > To: Ed Lazor > Cc: Beauford; PHP > Subject: Re: [PHP] Query question > > Agreed, this should go to a MySQL list. But in the spirit of helping I > think the following should give you a good starting point. > > SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC > > > On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote: > > > > Use the mysql list :) > > > > > > On Oct 28, 2006, at 3:01 PM, Beauford wrote: > > > > > Hi, > > > > > > I have a MySQL database with a date field and a bunch of other > > > fields. The date field is in the format - 01/01/2006. What I want > > > to do is query the database and create a table that shows just the > > > year and how many instances of the year there is. I have been > > > taxing my brain for a simple solution, but just not getting it. > > > Any suggestions? > > > > > > Thanks > > > > > > Example output. > > > > > > Year Count > > > > > > 2002 5 > > > 2003 8 > > > 2004 9 > > > 2005 15 > > > 2006 22 > > > > > > ps - I get this information sent to me and I can't change any of > > > the data. I just enter it in the db and then hopefully do the > > > query on it. > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: > > http://www.php.net/unsub.php > > > > > > -- > PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: > http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Query question
This is how I get the data and I have no control over the actual layout of the database. So I have to work with what I have. Robert: LOL, I don't know either. The format is - 01/01/2006. When I first did it I used 7, which should be right, but I ended up getting /2002 /2003, etc. So I went to 8 and all was well. Beats me. B -Original Message- From: Satyam [mailto:[EMAIL PROTECTED] Sent: October 29, 2006 2:14 AM To: Beauford; 'PHP' Subject: Re: [PHP] Query question If that works then you have a problem: you are storing dates as a plain string ( varchar or whatever) instead of a native date/time datatype, which precludes the use of a large number of native SQL date/time functions, such as year() which should suit you nicely in this case. Eventually, you will bump into something more elaborate which you won't be able to do on the SQL side just with string functions and that will force you to bring whole tables into PHP to do more extensive processing. Satyam - Original Message - From: "Beauford" <[EMAIL PROTECTED]> To: "'PHP'" Sent: Sunday, October 29, 2006 7:05 AM Subject: RE: [PHP] Query question > This is what I finally figured out, which works just perfectly. > > select count(date) as count, substring(date,8) as year from stats group by > year; > > Thanks to all for the input. > > -Original Message- > From: Joe Wollard [mailto:[EMAIL PROTECTED] > Sent: October 29, 2006 12:15 AM > To: Beauford > Cc: PHP > Subject: Re: [PHP] Query question > > Look into the MySQL YEAR() function to extract the year from a specific > date. > Start here: > http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html > > > > > On 10/28/06, Beauford <[EMAIL PROTECTED]> wrote: >> >> I posted this here as I figured I would need to manipulate this using >> PHP. >> The code below doesn't quite work because the date is in the format of >> 05/05/2006. So I am getting totals for each date, not each year. I >> need the totals for each year, regardless of the day or month. This is >> why I figured I'd need to use PHP to maybe put it in an array first or >> something. >> >> Thanks >> >> -Original Message- >> From: Joe Wollard [mailto:[EMAIL PROTECTED] >> Sent: October 28, 2006 10:30 PM >> To: Ed Lazor >> Cc: Beauford; PHP >> Subject: Re: [PHP] Query question >> >> Agreed, this should go to a MySQL list. But in the spirit of helping I >> think the following should give you a good starting point. >> >> SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC >> >> >> On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote: >> > >> > Use the mysql list :) >> > >> > >> > On Oct 28, 2006, at 3:01 PM, Beauford wrote: >> > >> > > Hi, >> > > >> > > I have a MySQL database with a date field and a bunch of other >> > > fields. The date field is in the format - 01/01/2006. What I want >> > > to do is query the database and create a table that shows just the >> > > year and how many instances of the year there is. I have been >> > > taxing my brain for a simple solution, but just not getting it. >> > > Any suggestions? >> > > >> > > Thanks >> > > >> > > Example output. >> > > >> > > Year Count >> > > >> > > 2002 5 >> > > 2003 8 >> > > 2004 9 >> > > 2005 15 >> > > 2006 22 >> > > >> > > ps - I get this information sent to me and I can't change any of >> > > the data. I just enter it in the db and then hopefully do the >> > > query on it. >> > > >> > > >> > >> > -- >> > PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: >> > http://www.php.net/unsub.php >> > >> > >> >> -- >> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: >> http://www.php.net/unsub.php >> >> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP 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] Query question
I don't see this as a particular problem as the data will always be the same. Now under other circumstances in another database, I can see what you are saying. -Original Message- From: Satyam [mailto:[EMAIL PROTECTED] Sent: October 29, 2006 4:30 AM To: Beauford; 'PHP' Subject: Re: [PHP] Query question I said that you have a problem,not that you caused it, and my observation might (hopefully) help newbies in the list. Satyam - Original Message - From: "Beauford" <[EMAIL PROTECTED]> To: "'PHP'" Sent: Sunday, October 29, 2006 9:06 AM Subject: RE: [PHP] Query question > This is how I get the data and I have no control over the actual layout of > the database. So I have to work with what I have. > > Robert: > > LOL, I don't know either. The format is - 01/01/2006. When I first did it > I > used 7, which should be right, but I ended up getting /2002 /2003, etc. So > I > went to 8 and all was well. Beats me. > > > B > > -Original Message- > From: Satyam [mailto:[EMAIL PROTECTED] > Sent: October 29, 2006 2:14 AM > To: Beauford; 'PHP' > Subject: Re: [PHP] Query question > > If that works then you have a problem: you are storing dates as a plain > string ( varchar or whatever) instead of a native date/time datatype, > which > precludes the use of a large number of native SQL date/time functions, > such > as year() which should suit you nicely in this case. Eventually, you will > bump into something more elaborate which you won't be able to do on the > SQL > side just with string functions and that will force you to bring whole > tables into PHP to do more extensive processing. > > Satyam > > - Original Message - > From: "Beauford" <[EMAIL PROTECTED]> > To: "'PHP'" > Sent: Sunday, October 29, 2006 7:05 AM > Subject: RE: [PHP] Query question > > >> This is what I finally figured out, which works just perfectly. >> >> select count(date) as count, substring(date,8) as year from stats group >> by >> year; >> >> Thanks to all for the input. >> >> -Original Message- >> From: Joe Wollard [mailto:[EMAIL PROTECTED] >> Sent: October 29, 2006 12:15 AM >> To: Beauford >> Cc: PHP >> Subject: Re: [PHP] Query question >> >> Look into the MySQL YEAR() function to extract the year from a specific >> date. >> Start here: >> http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html >> >> >> >> >> On 10/28/06, Beauford <[EMAIL PROTECTED]> wrote: >>> >>> I posted this here as I figured I would need to manipulate this using >>> PHP. >>> The code below doesn't quite work because the date is in the format of >>> 05/05/2006. So I am getting totals for each date, not each year. I >>> need the totals for each year, regardless of the day or month. This is >>> why I figured I'd need to use PHP to maybe put it in an array first or >>> something. >>> >>> Thanks >>> >>> -Original Message- >>> From: Joe Wollard [mailto:[EMAIL PROTECTED] >>> Sent: October 28, 2006 10:30 PM >>> To: Ed Lazor >>> Cc: Beauford; PHP >>> Subject: Re: [PHP] Query question >>> >>> Agreed, this should go to a MySQL list. But in the spirit of helping I >>> think the following should give you a good starting point. >>> >>> SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC >>> >>> >>> On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote: >>> > >>> > Use the mysql list :) >>> > >>> > >>> > On Oct 28, 2006, at 3:01 PM, Beauford wrote: >>> > >>> > > Hi, >>> > > >>> > > I have a MySQL database with a date field and a bunch of other >>> > > fields. The date field is in the format - 01/01/2006. What I want >>> > > to do is query the database and create a table that shows just the >>> > > year and how many instances of the year there is. I have been >>> > > taxing my brain for a simple solution, but just not getting it. >>> > > Any suggestions? >>> > > >>> > > Thanks >>> > > >>> > > Example output. >>> > > >>> > > Year Count >>> > > >>> > > 2002 5 >>> > > 2003 8 >>> > > 2004 9 >>> > > 2005 15 >>> > > 2006
[PHP] php.ini & ini_set
I am working on a website for a friend that is being hosted by a third party (which uses Linux) and I don't have access to the php.ini or any other system files. The problem I am having is this. When an email is sent from the website and the user receives it, it says it is from [EMAIL PROTECTED] instead of the websites email address. How can I get it to say it is coming from the website address. I do have access to a cgi bin, and maybe .htaccess if something can be done with these. I thought though that I could use ini_set to do this. Any thoughts. Thanks
RE: [PHP] php.ini & ini_set
Can you be more specific. I only see 4 parameters and none of them apply. -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: October 31, 2006 9:13 PM To: Beauford Cc: PHP Subject: Re: [PHP] php.ini & ini_set Beauford wrote: > I am working on a website for a friend that is being hosted by a third > party (which uses Linux) and I don't have access to the php.ini or any > other system files. > > The problem I am having is this. When an email is sent from the > website and the user receives it, it says it is from > [EMAIL PROTECTED] instead of the websites email address. How can I > get it to say it is coming from the website address. I do have access > to a cgi bin, and maybe .htaccess if something can be done with these. > I thought though that I could use ini_set to do this. http://www.php.net/mail Check the 5th parameter usage and associated comments. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php.ini & ini_set
That doesn't work. Here is what I have. mail($email,$subject,$body,$from); Which is (senders address, the subject, the body of the message, and the from address) The from address is taken from this, and I added the -f in front of it. define("regaddress", "[EMAIL PROTECTED]"); It still says it comes from: Nobody [EMAIL PROTECTED]; on behalf of; Registrar [EMAIL PROTECTED] Thanks -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: October 31, 2006 9:38 PM To: Beauford Cc: 'PHP' Subject: Re: [PHP] php.ini & ini_set Beauford wrote: > Can you be more specific. I only see 4 parameters and none of them apply. Oops sent you to the wrong page. http://www.php.net/manual/en/function.mail.php There are 5 parameters: bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] ) Look for this: additional_parameters (optional) and look at example 3. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
FW: [PHP] php.ini & ini_set
Sorry, this should be. Which is (to address, the subject, the body of the message, and the from address) - That doesn't work. Here is what I have. mail($email,$subject,$body,$from); Which is (senders address, the subject, the body of the message, and the from address) The from address is taken from this, and I added the -f in front of it. define("regaddress", "[EMAIL PROTECTED]"); It still says it comes from: Nobody [EMAIL PROTECTED]; on behalf of; Registrar [EMAIL PROTECTED] Thanks -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: October 31, 2006 9:38 PM To: Beauford Cc: 'PHP' Subject: Re: [PHP] php.ini & ini_set Beauford wrote: > Can you be more specific. I only see 4 parameters and none of them apply. Oops sent you to the wrong page. http://www.php.net/manual/en/function.mail.php There are 5 parameters: bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] ) Look for this: additional_parameters (optional) and look at example 3. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Viruses
Does the PHP list not monitor spam or filter out viruses? I am getting a lot of this junk coming through the list. I am also getting some directly to this address, but obviously that is out of the lists control. Thanks B
[PHP] PHP Installation question
Hi, I am trying to install vBulletin and keep getting this error: Fatal error: Call to undefined function: gzinflate(). The only thing I can find on this is that zlib needs to be configured with PHP at compile time. So I reinstalled PHP using the following: ./configure --with-mysql --with-apache=../apache_1.3.36 --with-zlib --with-gd make make install The above finishes with no error. I rebooted, but still get same error, and zlib or gd doesn't show up in my phpinfo output. zlib is installed, and from my understanding gd is included with PHP, all the other libraries for gd are also installed. So what am I doing wrong? Also, how do I find out where something is installed? i.e. zlib. If I do a search on it I get hundreds of hits... Last. In the above ./configure line I get a message from PHP saying I am using the built in version of MySQL - if I point it to the actual MySQL source directory I get the following error. configure: error: Cannot find libmysqlclient library under ../mysql-5.0.22 Any help is appreciated. I am using Slacware 10, PHP 4.4.4, MySQL5.0, and Apache 1.3.36 Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Installation question
I have zlib-1.2.1.1-i486-1. Whether that is zlib-devel or zlib-dev I have no idea, and not sure how to find out. Sort of figured out the MySQL problem, but now I get an error when I run 'make'. This is not a biggie, but the other problem I need to get resolved. Thanks -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: December 6, 2006 7:35 PM To: Beauford Cc: php-general@lists.php.net Subject: Re: [PHP] PHP Installation question Beauford wrote: > Hi, > > I am trying to install vBulletin and keep getting this error: Fatal error: > Call to undefined function: gzinflate(). > > The only thing I can find on this is that zlib needs to be configured > with PHP at compile time. So I reinstalled PHP using the following: > > ./configure --with-mysql --with-apache=../apache_1.3.36 --with-zlib > --with-gd make make install > > The above finishes with no error. > > I rebooted, but still get same error, and zlib or gd doesn't show up > in my phpinfo output. zlib is installed, and from my understanding gd > is included with PHP, all the other libraries for gd are also > installed. So what am I doing wrong? Check if you have zlib-devel or zlib-dev package installed. You need this to be able to compile support into other applications. No idea how you do this on slackware. Also try specifying the path to zlib: --with-zlib=/usr for example. > Also, how do I find out where something is installed? i.e. zlib. If I > do a search on it I get hundreds of hits... No idea about slackware. Do a search or ask a slackware list/forum. > Last. In the above ./configure line I get a message from PHP saying I > am using the built in version of MySQL - if I point it to the actual > MySQL source directory I get the following error. > > configure: error: Cannot find libmysqlclient library under > ../mysql-5.0.22 Install the mysql-dev/devel &/or mysql-client packages most likely. Or point it to the right directory. You need to point it to the base of the mysql package. Eg if mysql is installed in /usr/local/mysql (so binaries are under /usr/local/mysql/bin & libs are in /usr/local/mysql/lib) then --with-mysql=/usr/local/mysql -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Installation question
I'm thinking though that this isn't really the problem. When I install Slackware, I install everything (except for games). On my older PC I installed version 8.1 and had no problems, but now with version 10 I have problems. I'm pretty sure that zlib-dev or zlib-devel has never been included in either version of Slack. So I think I'm just going around in circles with this. Thoughts.. B -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: December 7, 2006 12:15 AM To: Beauford Cc: php-general@lists.php.net Subject: Re: [PHP] PHP Installation question Beauford wrote: > I have zlib-1.2.1.1-i486-1. Whether that is zlib-devel or zlib-dev I > have no idea, and not sure how to find out. Zlib is different to zlib-dev/zlib-devel. The zlib package only contains the binaries and man pages. The zlib-devel package contains the header files (zlib.h for example) you need for compiling against it. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Installation question
On the old PC zlib.h is in /usr/local/inlude. On the new PC it's in /usr/include and /usr/include/linux. I'm in the process of reinstalling PHP, but I have my doubts. Thanks -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: December 7, 2006 8:21 PM To: Beauford Cc: php-general@lists.php.net Subject: Re: [PHP] PHP Installation question Beauford wrote: > I'm thinking though that this isn't really the problem. When I install > Slackware, I install everything (except for games). On my older PC I > installed version 8.1 and had no problems, but now with version 10 I > have problems. I'm pretty sure that zlib-dev or zlib-devel has never > been included in either version of Slack. So I think I'm just going > around in circles with this. locate zlib.h if that returns nothing, then the problem is still that you need the zlib-dev package installed. If it does return something then what does it return ? Maybe you need to specify the path to zlib in the php configure line. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Installation question
Solved. Ditched Slackware 10 and installed Slackware 11. Both were installed the exact same way, so who knows Thanks to all. -Original Message- From: Ryan Creaser [mailto:[EMAIL PROTECTED] Sent: December 7, 2006 10:05 PM To: Beauford Cc: php-general@lists.php.net Subject: Re: [PHP] PHP Installation question Beauford wrote: > Hi, > > I am trying to install vBulletin and keep getting this error: Fatal error: > Call to undefined function: gzinflate(). > > The only thing I can find on this is that zlib needs to be configured > with PHP at compile time. So I reinstalled PHP using the following: > > ./configure --with-mysql --with-apache=../apache_1.3.36 --with-zlib > --with-gd make make install > > The above finishes with no error. > > I rebooted, but still get same error, and zlib or gd doesn't show up > in my phpinfo output. zlib is installed, and from my understanding gd > is included with PHP, all the other libraries for gd are also > installed. So what am I doing wrong? > > Also, how do I find out where something is installed? i.e. zlib. If I > do a search on it I get hundreds of hits... > > Last. In the above ./configure line I get a message from PHP saying I > am using the built in version of MySQL - if I point it to the actual > MySQL source directory I get the following error. > > configure: error: Cannot find libmysqlclient library under > ../mysql-5.0.22 > > Any help is appreciated. > > I am using Slacware 10, PHP 4.4.4, MySQL5.0, and Apache 1.3.36 > > Thanks > > > Did you recompile apache after running php's make install? Using --with-apache builds a module that gets compiled *into* apache (as opposed to --with-apxs which creates a dynamic module), ie. you need to rebuild apache after building php. My guess is the gzinflate error probably comes from an old php module. - rjc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Embedded Video
Not sure if this can be done with PHP, or if I would need to use a java script or something. If anyone has any ideas it would be appreciated. I have a video on my site and I want something to say that the video is loading and then disappear once the video starts. Thanks again. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Clearing POST variable on page refresh
Hi, I have a page with a form on it which posts to itself. The problem is when someone refreshes the page it enters the data into the DB again. How do I clear these variables so that doesn't happen. I tried the unset function, but no luck. I really don't want to use sessions or cookies as this is just a simple little page, but still, it has to work right. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Clearing POST variable on page refresh
> -Original Message- > From: Richard Lynch [mailto:[EMAIL PROTECTED] > Sent: December 18, 2006 3:46 PM > To: Beauford > Cc: PHP > Subject: Re: [PHP] Clearing POST variable on page refresh > > On Sun, December 17, 2006 4:59 pm, Beauford wrote: > > I have a page with a form on it which posts to itself. The > problem is > > when someone refreshes the page it enters the data into the > DB again. > > How do I clear these variables so that doesn't happen. I tried the > > unset function, but no luck. I really don't want to use sessions or > > cookies as this is just a simple little page, but still, it has to > > work right. > > The redirect solution has several "gotchas" > > It tends to mess up the "back" button, which is annoying to > some users. (Okay, maybe that's just me.) > > It's possible for an impatient user to hit "Back" and "Stop" > fast enough to re-submit the data anyway, in some browsers, > so it doesn't solve the problem 100%, really. > > A header() to redirect chews up HTTP connections, which can > be problematic on a heavy-traffic site, because it has to > send the 302 to the browser, which then has to send back > another HTTP request to the server to get the "new" page. So > you double your traffic load and number of Apache children > needed to provide the feature-set of this page. On a > much-visited page on a busy server, that can be a real issue, > instead of the non-issue it usually is. YMMV NAIAA > > > Embedding a "token" in the FORM, and tracking that "token" as > used in a session or db is what I prefer, personally. > > Since you don't want to use sessions, you can simply have one > more table in your DB: > > create table used_token ( > token char(32) unique not null primary key, > whatdate date > ); > create index used_token_whatdate_index on used_token(whatdate); > > Then in your original FORM part of the script: > > > Rest of form here > > > In the processing section: >$token = $_POST['token']; > if (!preg_match('/[0-9a-g]{32}/i', $token)) die("Bad Guy"); > $query = "select count(*) from used_token where token = '$token'"; > $used = mysql_query($query, $connection) or die("Database Offline" . > error_log(mysql_error($connection)); > $used = mysql_result($used, 0, 0); > if (!$used){ > //insert form contents to DB (your existing code goes here) > $query = "insert into used_token(token, whatdate) > values('$token', now())"; > mysql_query($query, $connection) or die("Database Offline" . > error_log(mysql_error($conection)); > } > else{ > //do whatever you want to do with a re-submission, > possibly nothing > } > ?> > > > Then you'll want a cron job to clear out any token in > used_token where the whatdate field is, say, a week or more > old. Less than a week on an ultra busy server. > >//cron job to clear out old data > $query = "delete from used_token where whatdate < > date_sub(now(), interval 1 week)"; > mysql_query($query, $connection) or > die(mysql_error($connection)); ?> > > There is a 1 in a billion chance that two users could get the > same token, but you can play games with that as well to > guarantee uniqueness. > > -- Hmm. I was thinking more of a one liner that would just clear the memory buffer of these variables, but it seems this is a little more involved than I anticipated. And it's not that I didn't want to use sessions, I just didn't want the extra work - but what you suggested above is way more work than sessions. So now I've just used a simple session. If it's true, don't add the user, if false add user. Still not exactly what I want, but will do until I find something better. This is most likely not a php thing, but would there be a way to refresh the page, fooling the browser into thinking it's being freshly loaded? Thanks to all. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Captcha v1.0 (http://www.php.meezerk.com/index.php?page=captcha)
Hi, I am trying to get a program, Captcha v1.0, working and not having much luck. The program says I need PHP version 4.3.10 or later or PHP version 5 and GD Library version 2.0 or later with JPEG support. I know I have PHP 5, but not sure about the GD Library. I was reading on one page I was on that this is built in to PHP, but at this point I'm lost. When I try to compile the latest version on my Slackware box I get nothing but errors. Any help would be appreciated. Thanks B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Captcha v1.0 (http://www.php.meezerk.com/index.php?page=captcha)
The following are the errors I am getting - quite lengthy. Thanks $ make make all-recursive make[1]: Entering directory `/home/beauford/gd-2.0.33' Making all in config make[2]: Entering directory `/home/beauford/gd-2.0.33/config' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/home/beauford/gd-2.0.33/config' Making all in test make[2]: Entering directory `/home/beauford/gd-2.0.33/test' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/home/beauford/gd-2.0.33/test' make[2]: Entering directory `/home/beauford/gd-2.0.33' if /bin/sh ./libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I. -I/usr/include/freetype2 -g -O2 -MT gdft.lo -MD -MP -MF ".deps/gdft.Tpo" -c -o gdft.lo gdft.c; \ then mv -f ".deps/gdft.Tpo" ".deps/gdft.Plo"; else rm -f ".deps/gdft.Tpo"; exit 1; fi mkdir .libs gcc -DHAVE_CONFIG_H -I. -I. -I. -I/usr/include/freetype2 -g -O2 -MT gdft.lo -MD -MP -MF .deps/gdft.Tpo -c gdft.c -fPIC -DPIC -o .libs/gdft.lo gdft.c:1366:35: fontconfig/fontconfig.h: No such file or directory gdft.c:1429: error: parse error before '*' token gdft.c:1429: error: parse error before '*' token gdft.c: In function `find_font': gdft.c:1431: error: `FcResult' undeclared (first use in this function) gdft.c:1431: error: (Each undeclared identifier is reported only once gdft.c:1431: error: for each function it appears in.) gdft.c:1431: error: parse error before "result" gdft.c:1433: error: `pattern' undeclared (first use in this function) gdft.c:1433: error: `FcMatchPattern' undeclared (first use in this function) gdft.c:1434: error: `FcMatchFont' undeclared (first use in this function) gdft.c:1437: error: `result' undeclared (first use in this function) gdft.c:1437: warning: return makes pointer from integer without a cast gdft.c: At top level: gdft.c:1442: error: parse error before '*' token gdft.c: In function `find_postscript_font': gdft.c:1444: error: `FcPattern' undeclared (first use in this function) gdft.c:1444: error: `font' undeclared (first use in this function) gdft.c:1447: error: `fontpattern' undeclared (first use in this function) gdft.c:1449: error: `fontname' undeclared (first use in this function) gdft.c:1450: error: `FcChar8' undeclared (first use in this function) gdft.c:1450: error: `family' undeclared (first use in this function) gdft.c:1452: error: `pattern' undeclared (first use in this function) gdft.c:1454: error: `FC_FAMILY' undeclared (first use in this function) gdft.c:1454: error: `FcTypeString' undeclared (first use in this function) gdft.c:1455: error: `FC_STYLE' undeclared (first use in this function) gdft.c:1460: error: `FcResultMatch' undeclared (first use in this function) gdft.c: In function `font_pattern': gdft.c:1479: error: `FcPattern' undeclared (first use in this function) gdft.c:1479: error: `font' undeclared (first use in this function) gdft.c:1480: error: `FcChar8' undeclared (first use in this function) gdft.c:1480: error: `file' undeclared (first use in this function) gdft.c:1481: error: `pattern' undeclared (first use in this function) gdft.c:1494: error: parse error before "FcChar8" gdft.c:1501: error: `FC_FILE' undeclared (first use in this function) gdft.c:1501: error: `FcResultMatch' undeclared (first use in this function) make[2]: *** [gdft.lo] Error 1 make[2]: Leaving directory `/home/beauford/gd-2.0.33' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/beauford/gd-2.0.33' make: *** [all] Error 2 -Original Message- From: chris smith [mailto:[EMAIL PROTECTED] Sent: May 20, 2006 9:29 PM To: Beauford Cc: php-general@lists.php.net Subject: Re: [PHP] Captcha v1.0 (http://www.php.meezerk.com/index.php?page=captcha) On 5/21/06, Beauford <[EMAIL PROTECTED]> wrote: > Hi, > > I am trying to get a program, Captcha v1.0, working and not having > much luck. The program says I need PHP version 4.3.10 or later or PHP > version 5 and GD Library version 2.0 or later with JPEG support. > > I know I have PHP 5, but not sure about the GD Library. I was reading > on one page I was on that this is built in to PHP, but at this point > I'm lost. When I try to compile the latest version on my Slackware box > I get nothing but errors. > > Any help would be appreciated. Help with which bit? gd - create a phpinfo page and it will show you the version if gd is available. compile issues - can't help without seeing the errors. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Upgrade problems PHP 5.1.4 (Windows)
Hi, I just upgraded to PHP 5.1.4 and now none of my sites will connect to MySQL. I keep getting the error: Fatal error: Call to undefined function mysql_connect() I enabled php_mysql.dll in php.ini as one article suggested, but still no go. Any suggestions? Thanks Beauford -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP, Javascript, and Forms
Hi, I have a form with about 20 fields in it and have two drop down menus in which the second one changes depending on the previous one. This is done with a javascript which reloads the page. The problem with this is that everything the user has put in so far gets erased when the page reloads. I am using PHP sessions, but at this point these fields are not saved yet. Is there a way to do this using sessions, or some other PHP function. All the javascript I've looked at reloads the page. This also screws up my validation routines. Thanks B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session variables and words with spaces
Hi, I have a form in which a drop down field is populated from a MySQL database. I am also using sessions. The problem is this. After I submit the form the session variable only shows the part of the input before the space. Example: if I choose Niagra Falls from the drop down list, then I only see Niagra when I display it. I'm not sure though if it is the session or the forms variable that is causing the problem. I haven't been able to find much on this. See code below Thanks session_start( ); ..Open database and connect to server... Include("connect.inc"); !! Start of form !! -- Select Province -- "$line['location']."\n"; } } !! Rest of Form !! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session variables and words with spaces
Thanks - Done that though. It shows the way it should be. Example: Niagara Falls -Original Message- From: Brad Bonkoski [mailto:[EMAIL PROTECTED] Sent: May 31, 2006 2:28 PM To: Beauford Cc: php-general@lists.php.net Subject: Re: [PHP] Session variables and words with spaces Perhaps you should load up your initial form and then use the "view source" option in your browser as this will probably give you insight into your problems... -Brad Beauford wrote: >Hi, > >I have a form in which a drop down field is populated from a MySQL database. >I am also using sessions. > >The problem is this. After I submit the form the session variable only >shows the part of the input before the space. > >Example: if I choose Niagra Falls from the drop down list, then I only >see Niagra when I display it. > >I'm not sure though if it is the session or the forms variable that is >causing the problem. I haven't been able to find much on this. > >See code below > >Thanks > > > >session_start( ); > >..Open database and connect to server... > >Include("connect.inc"); > >!! Start of form !! > > >-- Select Province -- > > >$query = "select pid, location from province order by location"; >$results = >mysql_query($query) or $mysqlerror = mysql_error(); if ($mysqlerror) { > $dberror = "Messed Up"; > include("index.php"); > exit; > } > >while ($line = mysql_fetch_array($results)) { > if($line['pid'] == 1) { > echo "Value="$line['location'].">"$line['location']."\n"; > } >} > > > >!! Rest of Form !! > > > -- 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] Session variables and words with spaces
Not sure why I would get a parse error, but that did correct the problem. I just completely missed the single quote. I never even clue'd in when I looked at the source of the page. Sometimes another pair of eyes does the trick. Maybe it's time for a break. Thanks >> I'm surprised you're not getting a parse error... echo "" . $line['location'] . "\n"; -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- 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] Session variables and words with spaces
Yep, I see that now. I really need to take a break - been at this way to long. Thanks to all. -Original Message- From: Brad Bonkoski [mailto:[EMAIL PROTECTED] Sent: May 31, 2006 3:02 PM To: Beauford Cc: php-general@lists.php.net Subject: Re: [PHP] Session variables and words with spaces Beauford wrote: > >Thanks - Done that though. It shows the way it should be. > >Example: Niagara Falls > > > > which of course is wrong and explains perfectly why you are getting the results you are getting... it *should* display: Niagra Falls (View source is a powerful tool!) -Brad >-Original Message- >From: Brad Bonkoski [mailto:[EMAIL PROTECTED] >Sent: May 31, 2006 2:28 PM >To: Beauford >Cc: php-general@lists.php.net >Subject: Re: [PHP] Session variables and words with spaces > >Perhaps you should load up your initial form and then use the "view source" >option in your browser as this will probably give you insight into your >problems... >-Brad > >Beauford wrote: > > > >>Hi, >> >>I have a form in which a drop down field is populated from a MySQL >> >> >database. > > >>I am also using sessions. >> >>The problem is this. After I submit the form the session variable only >>shows the part of the input before the space. >> >>Example: if I choose Niagra Falls from the drop down list, then I only >>see Niagra when I display it. >> >>I'm not sure though if it is the session or the forms variable that is >>causing the problem. I haven't been able to find much on this. >> >>See code below >> >>Thanks >> >> >> >>session_start( ); >> >>..Open database and connect to server... >> >>Include("connect.inc"); >> >>!! Start of form !! >> >> >>-- Select Province -- >> >>> >>$query = "select pid, location from province order by location"; >>$results = >>mysql_query($query) or $mysqlerror = mysql_error(); if ($mysqlerror) { >> $dberror = "Messed Up"; >> include("index.php"); >> exit; >> } >> >>while ($line = mysql_fetch_array($results)) { >> if($line['pid'] == 1) { >> echo ">Value="$line['location'].">"$line['location']."\n"; >> } >>} >> >> >> >>!! Rest of Form !! >> >> >> >> >> > >-- > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GD
Hi, I am trying to get GD working so I can use a captcha script and not having much luck. I can get it to work in Windows, but not Linux. I have seen a few comments suggesting that PHP needs to be compiled with the GD switch. Is there another way to do this? I have PHP, MySQL and Apache installed and working great, I don't want to have to recompile PHP and have it screw up everything just for one program. Any help is appreciated. B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] GD
I'm using Slackware 10 and installed GD as an install package. I also changed some lines in the php.ini file for GD. Tom: I have no idea how this program works, all I know is that I need it for the captcha program to display the image. I wouldn't even bother otherwise. Thanks. B -Original Message- From: Ray Hauge [mailto:[EMAIL PROTECTED] Sent: June 12, 2006 7:35 PM To: php-general@lists.php.net Cc: Beauford Subject: Re: [PHP] GD On Monday 12 June 2006 16:11, Beauford wrote: > Hi, > > I am trying to get GD working so I can use a captcha script and not > having much luck. I can get it to work in Windows, but not Linux. > > I have seen a few comments suggesting that PHP needs to be compiled > with the GD switch. Is there another way to do this? I have PHP, MySQL > and Apache installed and working great, I don't want to have to > recompile PHP and have it screw up everything just for one program. > > Any help is appreciated. > > B Depending on your Linux distribution, you might be able to find a GD module for PHP. That way you don't have to re-compile PHP. If you use an RPM based distro, this would be very easy. Free-BSD you could just compile the port. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Includes, Require, Location, Other
Hi, If I were to have something like the following, what is the best way (or best practice) to reload the page and display the error - or is there a better way to do this. I want to keep the site uniform and don't want errors popping up and making a mess. Thanks B - $query = "select idn, name from manager order by name"; $results = mysql_query($query) or $mysqlerror = mysql_error(); if ($mysqlerror) { $error = "$table_error$mysqlerror"; include("season.php"); - This is not what I really want and in some cases it cause problems. exit; } else { The rest of the code } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php