[PHP] Regex help...
Hi All, I rather badly need some help with a regular expression. I need to identify the occurrence of the following search string in another string, and replace it with some text followed by the identified search string. http://mysite/index.php?p=2#more-2";>(more…) The consistent part of the string is the text "(more…)" Essentially, I'm trying to figure out how to insert text prior to the opening "" in this line. Can anyone give me a hand in working this out? Many thanks in advance! Much warmth, Murray
Re: [PHP] Best way to figure out whether a query returns RESULT or NON-RESULT
Hello, mysql_query() returns non-false even if there was an UPDATE statement and the query was successful. But if I put the $result variable in mysql_num_rows() it returns an error, $result in invalid handle. I was asking how to know that where its an UPDATE statement so I dont call mysql_num_rows() at all. The problem is that if I set error_reporting( 0 ), everything works but we are required to have error_reporting ( E_ALL ) Regards, Karam --- Chris <[EMAIL PROTECTED]> wrote: > Karam Chand wrote: > > >Hello, > > > >I have an app where one module is similar to > >phpMyAdmin (well only .1%) with error_reporting() > set > >to E_ALL. > > > >Now a user can execute any query. What is the best > way > >to know whether a query is result or non-result. > > > >e.g. > > > > > > > . . . > > >Thanks in advance > > > >Regards, > >Karam > > > > > > > > As it states on http://www.php.net/mysql_query : > > " Only for SELECT,SHOW,EXPLAIN or DESCRIBE > statements *mysql_query()* > returns a resource identifier or *FALSE* if the > query was not executed > correctly. For other type of SQL statements, > *mysql_query()* returns > *TRUE* on success and *FALSE* on error. A > non-*FALSE* return value means > that the query was legal and could be executed by > the server." > > So , (false !== $result) means the query was > sucessful , and if it was > successful (true === $result) would mean that no > rows were returned. > > Chris > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php_printer functions, how to detect printer is ready to print out
On Sat, 16 Oct 2004 09:16, Ck wrote: > Hi. > > I am currently working on a project that the script should print-out > documents whenever local users wishe to print-out. > > However, my concern is how to detect THE printer is ready to print out NOT > only its driver is installed. > > Thank you in advance. > CK You'll need a client side application, such as Javascript, to handle that. -- David Robley I'd love to, but you know how we psychos are. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to figure out whether a query returns RESULT or NON-RESULT
Karam Chand wrote: Hello, mysql_query() returns non-false even if there was an UPDATE statement and the query was successful. But if I put the $result variable in mysql_num_rows() it returns an error, $result in invalid handle. I was asking how to know that where its an UPDATE statement so I dont call mysql_num_rows() at all. I Chris said, if($result === true || $result === false), no rows were returned. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] urlencode() and newlines?
hello all, For reasons beyond my immediate control i have to keep some strings of text in a text *new line delimited* text file. I also have to urlencode those strings for use in my script. Like this: ## text file This is a line\nThis is another line This is another string\nwith some more\nnew lines Problem is, that urlencoding those lines doesnt seem to work well the the \n's - when they get to where they are going (another server, not in my control) the new lines are no longer there... Can anyone tell me how to get round this issue without storing the strings in another way? - many thanks! ;-) -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] dirty words
Hi, I am useing file_get_contents on a remote page then using stristr() to make sure there are no "bad words" and its a family site. Right now I am checking for just 3 bad words which means 3 stristr() function calls, but if the bad words increase then that would mean more calls I have seen some forum software before that used to take an array of bad words and check it against the post, anybody have an idea what that function would be like coz I am pretty sure I am going about this the wrong way...php has a simple solution to most of these problems... Thanks, Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] dirty words
in_array() can check your $string against a array and return if a bad word is in string Is this what you are after? Chris Kay (CK) [EMAIL PROTECTED] -Original Message- From: Mag [mailto:[EMAIL PROTECTED] Sent: Sunday, 17 October 2004 12:41 AM To: php php Subject: [PHP] dirty words Hi, I am useing file_get_contents on a remote page then using stristr() to make sure there are no "bad words" and its a family site. Right now I am checking for just 3 bad words which means 3 stristr() function calls, but if the bad words increase then that would mean more calls I have seen some forum software before that used to take an array of bad words and check it against the post, anybody have an idea what that function would be like coz I am pretty sure I am going about this the wrong way...php has a simple solution to most of these problems... Thanks, Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. http://promotions.yahoo.com/new_mail -- 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] dirty words
Hey! Thanks, I think in_array() is what I was looking for, but by a quick glance I think its case sensitive (?), I didnt want to use a class for this coz it kind of seemed like using a gun instead of a flyswatter :-) Also, any way to check if a remote file exists? I am presently using this: $url='http://www.blah.net/movie.mpg'; $addy=parse_url($url); $addy['port']=isset($addy['port'])?$addy['port']:80; $sh=fsockopen($addy['host'],$addy['port']) or die('cant open socket'); fputs($sh,"HEAD {$addy['path']} HTTP/1.1\r\nHost: {$addy['host']}\r\n\r\n"); while($line=fgets($sh)) if(preg_match('/^Content-Length: (d+)/',$line,$m)) $size=$m[1]; echo isset($size)?"size of $url file is $size": 'no such file: '.$url; Thanks, Mag > in_array() can check your $string against a array > and return if a bad word > is in string > > Is this what you are after? > > Chris Kay (CK) > [EMAIL PROTECTED] > > > -Original Message- > From: Mag [mailto:[EMAIL PROTECTED] > Sent: Sunday, 17 October 2004 12:41 AM > To: php php > Subject: [PHP] dirty words > > Hi, > I am useing file_get_contents on a remote page then > using stristr() to make > sure there are no "bad words" > and its a family site. > Right now I am checking for just 3 bad words which > means 3 stristr() > function calls, but if the bad words increase then > that would mean more > calls > > I have seen some forum software before that used to > take an array of bad > words and check it against the post, anybody have an > idea what that function > would be like coz I am pretty sure I am going about > this the wrong way...php > has a simple solution to most of these problems... > > Thanks, > Mag > > = > -- > - The faulty interface lies between the chair and > the keyboard. > - Creativity is great, but plagiarism is faster! > - Smile, everyone loves a moron. :-) > > > > __ > Do you Yahoo!? > Yahoo! Mail Address AutoComplete - You start. We > finish. > http://promotions.yahoo.com/new_mail > > -- > 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 > > = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) ___ Do you Yahoo!? Declare Yourself - Register online to vote today! http://vote.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] urlencode() and newlines?
Nick Wilson wrote: hello all, For reasons beyond my immediate control i have to keep some strings of text in a text *new line delimited* text file. I also have to urlencode those strings for use in my script. Like this: ## text file This is a line\nThis is another line This is another string\nwith some more\nnew lines Problem is, that urlencoding those lines doesnt seem to work well the the \n's - when they get to where they are going (another server, not in my control) the new lines are no longer there... Can anyone tell me how to get round this issue without storing the strings in another way? - many thanks! ;-) Because what you are doing is not urlencoding. Try echo urlencode("This is a line\nThis is another line"); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dirty words
This one time, at band camp, Mag <[EMAIL PROTECTED]> wrote: > Hi, > I am useing file_get_contents on a remote page then > using stristr() to make sure there are no "bad words" > and its a family site. > Right now I am checking for just 3 bad words which > means 3 stristr() function calls, but if the bad words > increase then that would mean more calls $badwords = array('poo', 'bum', 'perl'); $goodString = str_replace($badwords, '***', file_get_contents($url); echo $goodString; If you are using php5 you can use str_ireplace() for a case insensitive search Kevin - "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] urlencode() and newlines?
* and then Marek Kilimajer declared > Nick Wilson wrote: > >hello all, > > > >For reasons beyond my immediate control i have to keep some strings of > >text in a text *new line delimited* text file. I also have to urlencode > >those strings for use in my script. > > > >Like this: > > > >## text file > >This is a line\nThis is another line > >This is another string\nwith some more\nnew lines > > > >Problem is, that urlencoding those lines doesnt seem to work well the > >the \n's - when they get to where they are going (another server, not in > >my control) the new lines are no longer there... > > > >Can anyone tell me how to get round this issue without storing the > >strings in another way? - many thanks! ;-) > > Because what you are doing is not urlencoding. Try > > echo urlencode("This is a line\nThis is another line"); Yep, i can see that it's encoded but when the data is POSTed to a form, it does not come out as a newline... -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] urlencode() and newlines?
Nick Wilson wrote: * and then Marek Kilimajer declared Nick Wilson wrote: hello all, For reasons beyond my immediate control i have to keep some strings of text in a text *new line delimited* text file. I also have to urlencode those strings for use in my script. Like this: ## text file This is a line\nThis is another line This is another string\nwith some more\nnew lines Problem is, that urlencoding those lines doesnt seem to work well the the \n's - when they get to where they are going (another server, not in my control) the new lines are no longer there... Can anyone tell me how to get round this issue without storing the strings in another way? - many thanks! ;-) Because what you are doing is not urlencoding. Try echo urlencode("This is a line\nThis is another line"); Yep, i can see that it's encoded but when the data is POSTed to a form, it does not come out as a newline... Are you sure the other side accepts, does not remove newlines? Create a form with textarea that posts to the server -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] urlencode() and newlines?
* and then Marek Kilimajer declared > >> > >>echo urlencode("This is a line\nThis is another line"); > > > > > >Yep, i can see that it's encoded but when the data is POSTed to a form, > >it does not come out as a newline... > > Are you sure the other side accepts, does not remove newlines? Create a > form with textarea that posts to the server yeah, i guess i'll have to, thanks Marek.. -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Fatal error
Dear members,I get an error,What does mean my error? : Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/html/votting/vote_implement.php on line 8 = -DIGITAL SIGNATURE--- ///Mohsen Pahlevanzadeh Network administrator & programmer My home phone is: +98213810146 My email address is m_pahlevanzadeh at yahoo dot com My website is: http://webnegar.net ___ Do you Yahoo!? Declare Yourself - Register online to vote today! http://vote.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Another regex problem - help!
On Sunday 17 October 2004 03:54, Murray @ PlanetThoughtful wrote: > In this case, I'm trying to perform a preg_match using the following > expression: > > preg_match("/^\[\[ft".$fn[1].":(.*)\]\]$/m",$content,$ft); Nearly there, except that ']' is not a special char and should not be escaped. > In the above example, the preg_match would be applied twice, once with a > $fn[1] value of 1, the second time with a $fn[1] value of 2. The $content > variable contains the string above. Not sure why you would want to apply the regex more than once. You use: preg_match_all('/^\[\[ft\d{1}:(.*)]]$/m', $content, $ft) That will match ft0 upto ft9, season to taste. -- 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 -- /* Life is difficult because it is non-linear. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Fatal error
In your script use set_time_limit(0), and look http://ar2.php.net/manual/en/function.set-time-limit.php for understand the function. Regards, JP > Dear members,I get an error,What does mean my error? : > Fatal error: Maximum execution time of 30 seconds > exceeded in /var/www/html/votting/vote_implement.php > on line 8 > > = > -DIGITAL SIGNATURE--- > ///Mohsen Pahlevanzadeh > Network administrator & programmer > My home phone is: +98213810146 > My email address is > m_pahlevanzadeh at yahoo dot com > My website is: http://webnegar.net > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Fatal error
This one time, at band camp, Pahlevanzadeh Mohsen <[EMAIL PROTECTED]> wrote: > Dear members,I get an error,What does mean my error? : > Fatal error: Maximum execution time of 30 seconds > exceeded in /var/www/html/votting/vote_implement.php > on line 8 It means the Maximum execution time of 30 seconds has been exceeded. Each script has a maximum of 30 seconds to do its thang. This time limit is set in php.ini and the default is 30 seconds. If your script needs a little more time, this can be changed. What are you doing in a vote script that takes so long? Look for infinite loops. Kind regards Kevin - "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Header sending
Dear members,I need to post a header without Form tag. Already i have used input tag (hidden type),But i don't kbow to how do it. Please guide me Yours,Mohsen = -DIGITAL SIGNATURE--- ///Mohsen Pahlevanzadeh Network administrator & programmer My home phone is: +98213810146 My email address is m_pahlevanzadeh at yahoo dot com My website is: http://webnegar.net ___ Do you Yahoo!? Declare Yourself - Register online to vote today! http://vote.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Is there a way to...
Is there a way to make sure that a page is only loaded via a require or include statement? or other type of SSI? I would like to make sure that a 'parent document' (namely admin_template.php) only calls the php file? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Header sending
--- Pahlevanzadeh Mohsen <[EMAIL PROTECTED]> wrote: > I need to post a header without Form tag. The header() function can be used to add a header to the response: http://www.php.net/header I'm not sure what this has to do with a form tag... Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly HTTP Developer's Handbook - Sams Coming December 2004http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is there a way to...
Your right, this is not what I was expecting, I was thinking there was another way... Sounds good.. but any other suggestions? On Sat, 16 Oct 2004 21:40:56 -0400, Minuk Choi <[EMAIL PROTECTED]> wrote: > well, this is probably not what you were expecting... but you can try this > > admin_template.php > -- > $parent = true; > include('important.php'); > -- > > important.php > -- > if (!isset($parent) || !$parent) > exit(); > > //important stuff here. > -- > > Of course, this only works assuming that the would-be hacker doesn't know > HOW you are authenticating the file. If you are going to try this method, > mix it up, use a rather unique variable name and or use a value that is hard > to guess. > > -Minuk > > > > > - Original Message - > From: "GH" <[EMAIL PROTECTED]> > To: "PHP General" <[EMAIL PROTECTED]> > Sent: Saturday, October 16, 2004 9:15 PM > Subject: [PHP] Is there a way to... > > > Is there a way to make sure that a page is only loaded via a > > > > require or include statement? or other type of SSI? > > > > I would like to make sure that a 'parent document' (namely > > admin_template.php) only calls the php file? > > > > 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] PHP App User Permissions Tecnique
However I would think that using the db would allow for you to change the persons while they are using the site and would not make them have to relog in suggestions? On Fri, 15 Oct 2004 10:52:53 +0200, Ian Firla <[EMAIL PROTECTED]> wrote: > > Definitely store them in a session. A db lookup will mean a much heavier > and process intensive procedure. > > Ian > > > > On Fri, 2004-10-15 at 09:41, Brendon wrote: > > I am building a web based community forum type software using PHP. I am > > currently working on how different user privelages are handled. Each > > user is part of a group and each group has varying degrees of privelages. > > > > I need to add in functionality which at the begginning of every script > > check the permission level of the user accessing the page. There are > > about 15 different permissions. > > > > I am debating whether i should store all the permission abilities into > > session variables and they can quickly be checked throughout the script, > > or whether i should query the database to check to see if the user has > > adequate group permissions to perform a certain function. > > > > Could someone give me some advice as to which would be more advisable? > > -- > 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] guessing timezone based on country/state/city
I have an event CMS where really, I should know the TZ of the events, which can happen world wide. However the user base is not computer heads, so I can't just "ask them". So, I'm faced with the prospect of making an educated guess based on the Country, State and Capital City information provided by the user... possibly I could interface with the files in /usr/share/zoneinfo/, or perhaps there's a database I can download to hook into. If I was limiting myself to just Australia, it'd be quite easy to hard code it, but since I'm targeting clients and events world-wide, I really need something less "manual". TIA, Justin French -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to figure out whether a query returns RESULT or NON-RESULT
Thanks. Never knew there existed (===). Silly me :) Regards, Karam --- Marek Kilimajer <[EMAIL PROTECTED]> wrote: > Karam Chand wrote: > > Hello, > > > > mysql_query() returns non-false even if there was > an > > UPDATE statement and the query was successful. > > > > But if I put the $result variable in > mysql_num_rows() > > it returns an error, $result in invalid handle. > > > > I was asking how to know that where its an UPDATE > > statement so I dont call mysql_num_rows() at all. > > I Chris said, if($result === true || $result === > false), no rows were > returned. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > ___ Do you Yahoo!? Declare Yourself - Register online to vote today! http://vote.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] guessing timezone based on country/state/city
* Thus wrote Justin French: > I have an event CMS where really, I should know the TZ of the events, > which can happen world wide. However the user base is not computer > heads, so I can't just "ask them". > > So, I'm faced with the prospect of making an educated guess based on > the Country, State and Capital City information provided by the user... > possibly I could interface with the files in /usr/share/zoneinfo/, or > perhaps there's a database I can download to hook into. It could be possible to figure out what zone one is in via the zone.tab file. It probably will be a lot of work just to figure that out, not to mention you need to be able to find the coordinates of the persons Country/State. Curt -- Quoth the Raven, "Nevermore." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Another regex problem - help!
Hi All, I'm trying to match a particular pattern in a multi-line string. The string might look like: Some text. Some more text. [[ft1: An example of the search string [[fn2 [[ft2: Another example of a search string]] Extra text In this case, I'm trying to perform a preg_match using the following expression: preg_match("/^\[\[ft".$fn[1].":(.*)\]\]$/m",$content,$ft); In the above example, the preg_match would be applied twice, once with a $fn[1] value of 1, the second time with a $fn[1] value of 2. The $content variable contains the string above. I'm attempting to accommodate a situation where the target string might contain "]]" before I want the capture to finish, as in the first example above. I'm hoping to return both the whole value matched by the preg_match, as well as the content of the matched string after the ":" character up to the final closing "]]" for the line. In essence, the closing "]]" for the match should always be at the end of the line. My attempt to build a pattern, as above, isn't working. I'm wondering if anyone can give me some advice on how to fix it? Many thanks in advance and much warmth, Murray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php