Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] Warning: preg_match() expects parameter 2 to be string
Forum PHP.pl > Forum > Przedszkole
.::Shaman::.
Witam!
Być może ten tema był poruszany ale na prawdę jestem totalnie odporny na naukę php. Mój problem wygląda w ten sposób:

Chciał bym zmodyfikować działanie skryptu (sklep internetowy do Joomla) , tak aby e-maile informujące były wysyłane na kilka adresów.Standardowo jest to zrobione w ten sposób że wysyłane są do kupującego i do właściciela sklepu.
Tak wygląda fragment skryptu bez modyfikacji:

Kod
            /*
            * Add the text, html and embedded images.
            * The name of the image should match exactly
            * (case-sensitive) to the name in the html.
            */
            $shopper_mail_Body = $shopper_html;
            $shopper_mail_AltBody = $shopper_header . $shopper_message . $shopper_footer;

            $vendor_mail_Body = $vendor_html;
            $vendor_mail_AltBody = $vendor_header . $shopper_message . $vendor_footer;

            $imagefile = pathinfo($dbv->f("vendor_full_image"));
            $extension = $imagefile['extension'] == "jpg" ? "jpeg" : "jpeg";

            $EmbeddedImages[] = array(    'path' => IMAGEPATH."vendor/".$dbv->f("vendor_full_image"),
                                'name' => "vendor_image",
                                'filename' => $dbv->f("vendor_full_image"),
                                'encoding' => "base64",
                                'mimetype' => "image/".$extension );

            
            $shopper_mail = vmMail( $from_email, $mosConfig_fromname, $shopper_email, $shopper_subject, $shopper_mail_Body, $shopper_mail_AltBody, true, null, null, $EmbeddedImages);

            $vendor_mail = vmMail($from_email, $mosConfig_fromname, $vendor_email, $vendor_subject, $vendor_mail_Body, $vendor_mail_AltBody, true, null, null, $EmbeddedImages, null, $shopper_email);

            if ( !$shopper_mail || !$vendor_mail ) {
                
                $vmLogger->debug( 'Something went wrong while sending the order confirmation email to '.$from_email.' and '.$shopper_email );
                return false;
            }
            //
            // END: set up and send the HTML email
            ////////////////////////////////////////



A tak po wprowadzeniu modyfikacji:

Kod
            /*
            * Add the text, html and embedded images.
            * The name of the image should match exactly
            * (case-sensitive) to the name in the html.
            */
            $shopper_mail_Body = $shopper_html;
            $shopper_mail_AltBody = $shopper_header . $shopper_message . $shopper_footer;

            $vendor_mail_Body = $vendor_html;
            $vendor_mail_AltBody = $vendor_header . $shopper_message . $vendor_footer;

            $imagefile = pathinfo($dbv->f("vendor_full_image"));
            $extension = $imagefile['extension'] == "jpg" ? "jpeg" : "jpeg";

            $EmbeddedImages[] = array(    'path' => IMAGEPATH."vendor/".$dbv->f("vendor_full_image"),
                                'name' => "vendor_image",
                                'filename' => $dbv->f("vendor_full_image"),
                                'encoding' => "base64",
                                'mimetype' => "image/".$extension );

            
            $shopper_mail = vmMail( $from_email, $mosConfig_fromname, $shopper_email, $shopper_subject, $shopper_mail_Body, $shopper_mail_AltBody, true, null, null, $EmbeddedImages);
            
            $addresses = array($vendor_email, 'myaddress@mysite.com');

            $vendor_mail = vmMail($addresses, $from_email, $mosConfig_fromname, $vendor_email, $vendor_subject, $vendor_mail_Body, $vendor_mail_AltBody, true, null, null, $EmbeddedImages, null, $shopper_email);

            if ( !$shopper_mail || !$vendor_mail ) {
                
                $vmLogger->debug( 'Something went wrong while sending the order confirmation email to '.$from_email.' and '.$shopper_email );
                return false;
            }
            //
            // END: set up and send the HTML email
            ////////////////////////////////////////



Różni się on tylko tym że przed zmienną $vendor_mail dodana jest tablica z jednym przykładowym adresem. Po zmianach w kodzie w momencie kiedy powinno zostać wysłane powiadomienie o zamówieniu dostaję taki oto błąd:

Kod
Warning: preg_match() expects parameter 2 to be string, array given in /homez.374/******/www/*****/sklep/administrator/components/com_virtuemart/classes/ps_main.php on line 77



Czy mógł by mi ktoś wytłumaczyć jak to zapisać żeby zamiast tablicy był tam string?
CuteOne
Error oznacza, że nie możesz przekazać tablicy jako parametr funkcji preg_match. Innymi słowy wymagany jest string

funkcja($parametr1, $tablica['klucz']);

Przekazany został string
.::Shaman::.
Ajak zapisać adres mailowy jako string? Robię to w ten sposób:

Kod
$addresses =  myaddress@mysite.com;

            $vendor_mail = vmMail($addresses, $from_email, $mosConfig_fromname, $vendor_email, $vendor_subject, $vendor_mail_Body, $vendor_mail_AltBody, true, null, null, $EmbeddedImages, null, $shopper_email);



ale dostaję error : unexpect '@'

wookieb
Forum nie parser. Wróć do manuala i obsługi ciągów znakowych.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.