php-general Digest 22 Jul 2006 11:54:27 -0000 Issue 4252

Topics (messages 239690 through 239698):

Cleaning bad characters from var
        239690 by: Paul Nowosielski
        239691 by: John Nichel
        239695 by: Adam Zey

authorize.net
        239692 by: Skip Evans

Re: search string
        239693 by: Andrew Kreps

session
        239694 by: João Cândido de Souza Neto
        239696 by: Chris

Re: [PHP-DB] Restaurant menu
        239697 by: kartikay malhotra

Re: headers and newline at end of script
        239698 by: Martin Marques

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Dear All,

I'm trying to set up an XML feed form our news articles. My XML is validating. 
The issue  is some of the articles have a weird encoding.

It seems to be single quotes. For example:
the world<92>s largest live event producer

Notice the <92>.

I already have this to clean vars but its not doing the trick:

                // clean bad chars for valid XML
                //$patterns[0] = '/=/';
                $patterns[1] = '/</';
                $patterns[2] = '/>/';
                $patterns[3] = '/\'/';
                $patterns[4] = '/\"/';
                $patterns[5] = '/&/';

                //$replacements[0] = '/&eq/';
                $replacements[1] = '/&lt/';
                $replacements[2] = '/&gt/';
                $replacements[3] = '/&apos;/';
                $replacements[4] = '/&quot;/';
                $replacements[5] = '/&amp;/';





                // chars to replace
                $badwordchars=array(
                "\xe2\x80\x98", // left single quote
                "\xe2\x80\x99", // right single quote
                "\xe2\x80\x9c", // left double quote
                "\xe2\x80\x9d", // right double quote
                "\xe2\x80\x94", // em dash
                "\xe2\x80\xa6" // elipses
                );

                $fixedwordchars=array(
                "&#8216;",
                "&#8217;",
                '&#8220;',
                '&#8221;',
                '&mdash;',
                '&#8230;'
                );

An thoughts would be very helpful.

Thank You,

-- 
Paul Nowosielski
Webmaster

--- End Message ---
--- Begin Message ---
Paul Nowosielski wrote:
Dear All,

I'm trying to set up an XML feed form our news articles. My XML is validating. The issue is some of the articles have a weird encoding.


I wrote a function to do this for our product descriptions when sending them in a XML doc to certain vendors. It's old, crude, but you're welcome to it.

function convertString ( $string, $reverse = false ) {
        $find_array = array (
                "/&quot;/",
                "/&amp;/",
                "/&lt;/",
                "/&gt;/",
                "/&nbsp;/",
                "/&iexcl;/",
                "/&cent;/",
                "/&pound;/",
                "/&curren;/",
                "/&yen;/",
                "/&brvbar;/",
                "/&sect;/",
                "/&uml;/",
                "/&copy;/",
                "/&ordf;/",
                "/&laquo;/",
                "/&not;/",
                "/&shy;/",
                "/&reg;/",
                "/&macr;/",
                "/&deg;/",
                "/&plusmn;/",
                "/&sup2;/",
                "/&sup3;/",
                "/&acute;/",
                "/&micro;/",
                "/&para;/",
                "/&middot;/",
                "/&cedil;/",
                "/&sup1;/",
                "/&ordm;/",
                "/&raquo;/",
                "/&frac14;/",
                "/&frac12;/",
                "/&frac34;/",
                "/&iquest;/",
                "/&Agrave;/",
                "/&Aacute;/",
                "/&Acirc;/",
                "/&Atilde;/",
                "/&Auml;/",
                "/&Aring;/",
                "/&AElig;/",
                "/&Ccedil;/",
                "/&Egrave;/",
                "/&Eacute;/",
                "/&Ecirc;/",
                "/&Euml;/",
                "/&Igrave;/",
                "/&Iacute;/",
                "/&Icirc;/",
                "/&Iuml;/",
                "/&ETH;/",
                "/&Ntilde;/",
                "/&Ograve;/",
                "/&Oacute;/",
                "/&Ocirc;/",
                "/&Otilde;/",
                "/&Ouml;/",
                "/&times;/",
                "/&Oslash;/",
                "/&Ugrave;/",
                "/&Uacute;/",
                "/&Ucirc;/",
                "/&Uuml;/",
                "/&Yacute;/",
                "/&THORN;/",
                "/&szlig;/",
                "/&agrave;/",
                "/&aacute;/",
                "/&acirc;/",
                "/&atilde;/",
                "/&auml;/",
                "/&aring;/",
                "/&aelig;/",
                "/&ccedil;/",
                "/&egrave;/",
                "/&eacute;/",
                "/&ecirc;/",
                "/&euml;/",
                "/&igrave;/",
                "/&iacute;/",
                "/&icirc;/",
                "/&iuml;/",
                "/&eth;/",
                "/&ntilde;/",
                "/&ograve;/",
                "/&oacute;/",
                "/&ocirc;/",
                "/&otilde;/",
                "/&ouml;/",
                "/&divide;/",
                "/&oslash;/",
                "/&ugrave;/",
                "/&uacute;/",
                "/&ucirc;/",
                "/&uuml;/",
                "/&yacute;/",
                "/&thorn;/",
                "/&yuml;/"
        );
        $replace_array = array (
                '&#034;',
                '&#038;',
                '&#060;',
                '&#062;',
                '&#160;',
                '&#161;',
                '&#162;',
                '&#163;',
                '&#164;',
                '&#165;',
                '&#166;',
                '&#167;',
                '&#168;',
                '&#169;',
                '&#170;',
                '&#171;',
                '&#172;',
                '&#173;',
                '&#174;',
                '&#175;',
                '&#176;',
                '&#177;',
                '&#178;',
                '&#179;',
                '&#180;',
                '&#181;',
                '&#182;',
                '&#183;',
                '&#184;',
                '&#185;',
                '&#186;',
                '&#187;',
                '&#188;',
                '&#189;',
                '&#190;',
                '&#191;',
                '&#192;',
                '&#193;',
                '&#194;',
                '&#195;',
                '&#196;',
                '&#197;',
                '&#198;',
                '&#199;',
                '&#200;',
                '&#201;',
                '&#202;',
                '&#203;',
                '&#204;',
                '&#205;',
                '&#206;',
                '&#207;',
                '&#208;',
                '&#209;',
                '&#210;',
                '&#211;',
                '&#212;',
                '&#213;',
                '&#214;',
                '&#215;',
                '&#216;',
                '&#217;',
                '&#218;',
                '&#219;',
                '&#220;',
                '&#221;',
                '&#222;',
                '&#223;',
                '&#224;',
                '&#225;',
                '&#226;',
                '&#227;',
                '&#228;',
                '&#229;',
                '&#230;',
                '&#231;',
                '&#232;',
                '&#233;',
                '&#234;',
                '&#235;',
                '&#236;',
                '&#237;',
                '&#238;',
                '&#239;',
                '&#240;',
                '&#241;',
                '&#242;',
                '&#243;',
                '&#244;',
                '&#245;',
                '&#246;',
                '&#247;',
                '&#248;',
                '&#249;',
                '&#250;',
                '&#251;',
                '&#252;',
                '&#253;',
                '&#254;',
                '&#255;'
        );
$string = htmlentities ( strip_tags ( preg_replace ( "/\n|\r|\r\n/", " ", $string ) ), ENT_QUOTES );
        $string = preg_replace ( $find_array, $replace_array, $string );
        return $string;
}

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
John Nichel wrote:
Paul Nowosielski wrote:

I wrote a function to do this for our product descriptions when sending them in a XML doc to certain vendors. It's old, crude, but you're welcome to it.
<snip function that uses regular expressions for simple string replacements>


Using regular expressions for that is a very bad idea. You're using regular expressions for simple string matches, which is going to be much slower than just using the simple string replace functions. It even warns you against doing what you're doing in the manual.

Here's a function that demonstrates replacing several characters with something else

function replaceChars($string)
{
    $find_array = array("a", "b", "c");
    $replace_array = array("apple", "banana", "carambola");

    return str_replace($find_array, $replace_array, $string);
}

You can, of course, throw other string processing functions in there.

Regards, Adam Zey.

--- End Message ---
--- Begin Message ---
Hey all,

Anybody on the list know authorize.net integration really well and would be interested in earning a few bucks consulting?

I have a new install that has their tech support and myself stumped and I really want to get it going.

If so, email me off-list with your level of experience and hourly rate.
--
Skip Evans
Big Sky Penguin, LLC
61 W Broadway
Butte, Montana 59701
406-782-2240

--- End Message ---
--- Begin Message ---
You can use a regular expressions with a function called preg_match to
find the values.  For example,

(Assuming your sql statement is $sql)

preg_match("/(tbl_chassis.chasis_model LIKE \'\%[a-zA-Z0-9-]+\%\'/)",
$sql, $matches);

That will return $matches[0] with the matched data.  Similarly,

preg_match("/(AND lower\(country\) = lower\(trim\(\'(\w+)\'\)\))/",
$sql, $matches);

does the same thing, again in $matches[0].

The full description of preg_match can be found here:

http://us2.php.net/manual/en/function.preg-match.php


On 7/20/06, weetat <[EMAIL PROTECTED]> wrote:
Hi all ,

  I am using php4.3.2,MYSQL and RedHat
  I have a sql text as shown below:


  SELECT
DISTINCT(tbl_chassis.serial_no),tbl_chassis.host_name,tbl_chassis.chasis_model,tbl_chassis.country,tbl_chassis.city,tbl_chassis.building,
tbl_chassis.other,tbl_chassis.status,tbl_chassis.chasis_eos,tbl_chassis.chasis_eol,tbl_chassis.chasis_user_field_1,tbl_chassis.chasis_user_field_2,tbl_chassis.chasis_user_field_3
from tbl_chassis tbl_chassis,tbl_card tbl_card
WHERE tbl_chassis.serial_no = tbl_card.serial_no
AND tbl_chassis.chasis_model LIKE '%WS-C5500%'
AND lower(country) = lower(trim('Malaysia'))
ORDER BY country,city,building,other


I need to extract the "tbl_chassis.chasis_model LIKE '%WS-C5500%'" and
"lower(country) = lower(trim('Malaysia'))" and join them to new string.

Anyone have any suggestion how to do this?

Thanks
-weetat

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



--- End Message ---
--- Begin Message ---
I´ve got a big doubt abaout sessions and if someone help me in it, i´ll turn 
very happy.

When i get in e.g. http://www.domain.com and it uses session, a session id 
will be generated and it´ll be used in whole site.

My doubt is: if i´ve got a link that send to http://subdomain.domain.com in 
a new browser´s window it´ll give me a new session id or it´ll use the same 
session id that was created before?

Thanks a lot.

--- End Message ---
--- Begin Message --- By default it will give you a new session id. You can set the domain of your session cookie to ".domain.com" and it will be passed and read by both.

I beleive the php.ini option is session.cookie_domain, check your ini file, it should be in there.

Chris

João Cândido de Souza Neto wrote:
I´ve got a big doubt abaout sessions and if someone help me in it, i´ll turn very happy.

When i get in e.g. http://www.domain.com and it uses session, a session id will be generated and it´ll be used in whole site.

My doubt is: if i´ve got a link that send to http://subdomain.domain.com in a new browser´s window it´ll give me a new session id or it´ll use the same session id that was created before?

Thanks a lot.


--- End Message ---
--- Begin Message ---
Hey Craig,

Place all items whatever way you want in a table. Its while presenting the
menu, you have the query the database like:

 $query = "SELECT menu_id, menu_category, menu_item FROM $menu_name ORDER
BY $menu_item_attribute "ASC";

You can choose multiple tables for menu_category, in which case you shall
have to pull out a custom menu by 'joining tables'.

Regrds
KM



On 7/22/06, Craig Hoffman <[EMAIL PROTECTED]> wrote:

Hey there,
I'm working on a menu system for a catering company.  I'm having a
difficult time sorting and grouping items together.  For example,
there may be three or four appetizers that should be group together.
But I only want to display the category (appetizers) once and then
the corresponding items (A, B, C,...). I'm drawing a blank on how to
go about this.

My DB consists of 4 tables (categories, items, item_attributes,
menu) but the menu table is most the important. The menu schema is
below.

menu_id
menu_name
menu_category => pulls from the categories table (appetizers,
starters, etc...)
menu_item => pulls from the items table (Cherry Pie)
menu_item_atttribute => pulls from the attribute table (Hot, cold, etc)

Example:
Menu Name: xxxxx
Appetizers
        A
        B
        C
        D

Desserts
        A
        B

I'm open to all suggestions / ideas.
Thanks
- Craig

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



--- End Message ---
--- Begin Message ---
On Thu, 20 Jul 2006, Robert Cummings wrote:

On Thu, 2006-07-20 at 17:09, John Nichel wrote:
Adam Zey wrote:
<snip>
Note that just because the fact that it works is a feature, doesn't mean
it's good coding style. register globals is a feature too, but it isn't
exactly a good idea to use it.


Ding ding ding

Give that man a cigar.

Why would anyone wish cancer on somebody else? Seems mean to me.

jajaja

Give Robert a Beer please! ;)

--
 21:50:04 up 2 days,  9:07,  0 users,  load average: 0.92, 0.37, 0.18
---------------------------------------------------------
Lic. Martín Marqués         |   SELECT 'mmarques' ||
Centro de Telemática        |       '@' || 'unl.edu.ar';
Universidad Nacional        |   DBA, Programador,
    del Litoral             |   Administrador
---------------------------------------------------------

--- End Message ---

Reply via email to