RE: [PHP] Check for well formed html
Tedd, Finally, I can give you an answer! :) You can use html tidy. I did this before the php tidy function was fully implemented, so I don't know the syntax for that. But using tidy from the command line you can set have it either correct errors (probably not what you want) or just have it return an error flag and log the errors. http://www.php.net/manual/en/ref.tidy.php http://tidy.sourceforge.net/ Kathleen -Original Message- From: tedd [mailto:[EMAIL PROTECTED] Sent: Sunday, August 05, 2007 7:17 AM To: php-general@lists.php.net Subject: [PHP] Check for well formed html Hi gang: I have a client who wants to include html tags in his CMS. I know that I can limit what tags he can use, but how can I check if the text is well formed with the tags permitted before storing it in his CMS? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] regex to remove NL and CR
I am extracting text from a text datatype field of a database. The target text is marked (beginning and end) by html comments that have a known--but not uniform--format. Unfortunately, the web-based interface used to maintain the data inserted hard line breaks in the text. I initially tried removing all NL and CR chars from the string, which has the unanticipated result of removing some spaces between words that had wrapped in the admin interface. Now, I need to remove all NL and CR that occur within a string starting with !- and ending with -. I have no idea where to start, because the NL and CR could also occur in the strings that mark the start and end of the comments. I am very new to regex, but starting to get it. If someone could just give me a push in the right direction. Nothing I have tested in regex coach comes close to matching what I need. Kathleen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] regex to remove NL and CR
I am extracting text from a text datatype field of a database. The target text is marked (beginning and end) by html comments that have a known--but not uniform--format. Unfortunately, the web-based interface used to maintain the data inserted hard line breaks in the text. I initially tried removing all NL and CR chars from the string, which has the unanticipated result of removing some spaces between words that had wrapped in the admin interface. Now, I need to remove all NL and CR that occur within a string starting with !- and ending with -. I have no idea where to start, because the NL and CR could also occur in the strings that mark the start and end of the comments. I am very new to regex, but starting to get it. If someone could just give me a push in the right direction. Nothing I have tested in regex coach comes close to matching what I need. Kathleen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] regex help
I am at the tailend of a project that involves moving legacy data from one dbms to another. The client has added a new requirement to the data manipulation that is required. I need to remove all br / tags (there may be more that one) that appear within all h* tags. I am not very familiar with building regular expressions, but I see this as a 2 part process. First, to grab h* tags, and second, to strip the br's. I can grab the beginning of the tag easily, but my expressions grab too much. Also, I am not sure how to remove the br's. Any help would be appreciated. I have tried to find similar examples, but without any luck. Also, php5 is not an option at this point. Kathleen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] regex help needed
Sorry, Here is the code I am using to match the h* tags: h([1-9]){1}.*/h([1-9]){1} I have removed all the NL and CR chars from the string I am matching to make things easier. Also, I have run tidy on the code so the tags are all uniform. The above string seems to match the tag well now, but I still need to remove the br tags from the tag contents (.*). The strings I will be matching are html formatted text. Sample h* tags with content are below: h4Ex-Secretary Mickey Mouse br /Loses Mass. Primary/h4 h4Ex-Secretary Mickey Mouse br /Loses Mass. Primary br / Wins New Jersey/h4 h4Ex-Secretary Reich Loses Mass. Primary/h4 Again, any help is appreciated. Kathleen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: regex help needed -- Solved! Thanks!
Thanks! Works like a charm! I am the very lowest of newbies when it comes to regex and working through your solutions has been very educational. I have one question about something I couldn't figure out: #h[1-9](.*)/h[1-9]#Uie `h([1-6]).*?/h\1)`sie What is the purpose of the back-ticks and the '#'? What are 'Uie' and 'sie'? Thanks again! Kathleen -Original Message- From: Fabrice Lezoray [mailto:[EMAIL PROTECTED] Sent: Sunday, August 01, 2004 2:52 PM To: [EMAIL PROTECTED] Subject: [PHP] Re: regex help needed hi M. Sokolewicz a écrit : You could try something like: $return = preg_replace('#h[1-9](.*)/h[1-9]#Uie', 'str_replace(br /, , $1)'); - Tul Kathleen Ballard wrote: Sorry, Here is the code I am using to match the h* tags: h([1-9]){1}.*/h([1-9]){1} I think this mask is better : `h([1-6]).*?/h\1)`sie I have removed all the NL and CR chars from the string I am matching to make things easier. Also, I have run tidy on the code so the tags are all uniform. The above string seems to match the tag well now, but I still need to remove the br tags from the tag contents (.*). To remove the br / tags, you need to call preg_replace_callback() : ?php $str = 'h1hi br / ../h1 bla bla h5 br / ../h5 ...br /'; function cbk_br($match) { return 'h' . $match[1] . '' . str_replace('br /', '', $match[2]) . '/h' . $match[1] . ''; } $return = preg_replace_callback('`h([1-6])(.*?)/h\1`si', 'cbk_br', $str); echo $return; ? The strings I will be matching are html formatted text. Sample h* tags with content are below: h4Ex-Secretary Mickey Mouse br /Loses Mass. Primary/h4 h4Ex-Secretary Mickey Mouse br /Loses Mass. Primary br / Wins New Jersey/h4 h4Ex-Secretary Reich Loses Mass. Primary/h4 Again, any help is appreciated. Kathleen -- Fabrice Lezoray http://classes.scriptsphp.fr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Access Violation at 02B80AFD
I am developing a php app on a win 2003 server with iis6. Unfortunately, I don't know the version of sql server or php. I have been testing code since last Thursday and just started getting this error: PHP has encountered an Access Violation at 02B80AFD This error doesn't happen every time, even if you are just hitting refresh on the same page. It interferes with redirects and all update and insert queries fail (failure to connect) while the select queries run fine (access violation or not). The access violation is always at the same address(??) as far as I can tell. The client's server support thinks it is a permissions issue of some kind but doesn't know how to fix it. The access violation occurs now if I try to run phpinfo()--which is why I don't have the version. Php is not running as a cgi. I would really appreciate any ideas. Kathleen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] finding text strings in html code
I am beginning a project that will involve moving data from an mssql table to xml files. In addition to fixing non-xml compliant html in the text fields and outputting the data to a new xml format, I need to find certain chunks of text marked by standard html comments at the start and end, comment out everything between the comments, and insert the found text into its own xml element (which will in some cases be inline). I have played with code using substr/str_pos, running html tidy with exec() and it works. But searching the archives, it seems like the new html tidy tags in php5 will be more useful. In most cases the target text is in a one row, one cell table. Any advice on how to attack this would be appreciated. I can handle the coding, I just have a feeling I am approaching this from the hard way. Kathleen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] asp.net vs. php
I have been asked to make a fact based comparison of the pros and cons of asp.net and php. I am not trying to start a war and apologize if this is too off topic, but I know make of the list members work in other coding languages. Three areas of concern are robustness, scalability and development time. Also important is the availability of existing code (goes to development time). I have experience in asp and php, but have only read about .net. One big difference seems to be that .net is event driven vs. php which is increasingly oo. I am a bit concerned that I will be too biased in my judgement, because if immediate development time is considered, I will have to pass and lose a potentially good client. I am sure I can get up to speed quickly in .net, but not quickly enough to answer immediate needs. Any experiences, links to online articles and discussions would be welcome. Kathleen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] single quote escape questions
I would like some advice on special/reserved chars in strings, especially single quotes. I am developing an application that requires using a Name field in the url for navigation. I have a case where Toni's in the url is returned in $_SERVER['PATH_INFO'] as Toni\'s eventhough the address bar shows Toni's. I can easily add the code to stripslashes from the vars I extract, but is the single quote the only char that is an issue here? Is this a server addition or a client/browser addition? The server has magic quotes set off, so that is not the issue. Secondly, what is best/favorite way to escape chars for mysql? I know that mysql_real_escape_string() has been recommended recently. But that brings up the issue of magic quotes. Would set_magic_quotes_runtime(0) be a reliable way of making sure my code runs with magic quotes off? Thanks for your time, Kathleen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] session var problems
Dear list, I am trying to set a simple session variable on PageA. $_SESSION['CategoryID'] = intval($Data['ID']); if I print after setting the value on PageA, I will get the expected ID number. go on to PageB and $_SESSION['CategoryID'] is '0'. If I hard code in a value for $_SESSION['CategoryID'] on PageA, it prints correctly on PageB. If I set $Test = 462 and then $_SESSION['CategoryID'] = intval($Test); on PageA, it prints correctly on PageB. Does anyone have any ideas? Kathleen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] session var puzzle
Dear list, I am sorry for the second posting, but this is going to drive me to drink something other than lattes! I have one page, index.php. when it calls mod_sub, a directory type of page is printed. Here I am trying to set a session var of the most recently selected category to allow the user to return the to same place in the directory. when I do this: $_SESSION['CategoryID'] = 230; in mod_sub then in mod_profile: print($_SESSION['CategoryID']); will print 230 when I do this: $Tmp = 230; $_SESSION['CategoryID'] = $Tmp; in mod_sub in mod_profile: print($_SESSION['CategoryID']); will print 230 BUT, when I do this: $_SESSION['CategoryID'] = $Data['ID']; in mod_sub $_SESSION['CategoryID'] = intval($Data['ID']); in mod_profile: print($_SESSION['CategoryID']); will print '' and 0 I am setting several other session variables throughout the code without any unexpected behavior. I have even tried changing the index to something odd in case I am resetting 'CategoryID' somewhere and forgotten it. But no matter what I try, once I set it = $Data['ID'] I get the odd result. BTW, if I print $_SESSION['CategoryID'] from mod_sub right after setting, it holds the expected value. This is really frustrating, I must be missing something basic about the way session vars can be set. Kathleen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] unicode and php
I am trying to translate a site to Simplified Chinese. I was told the pages needed to be saved as unicode files. However, the unicode files do not process as php on my host server. ie. if you view source on a page saved as unicode, all the php code is there. My hosting company says that unicode files cannot be processed as php. I don't know enough about servers and php to know if this is true or not. Please help! Kathleen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php ms sql
Dear List, I am trying to advise a client on the feasiblity of using php with an external SQL server. Has anyone had experience with this? Pros? Cons? Kathleen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]