# Inhalt wird nicht oder falsch in Datenbank aufgenommen



## Freeway (7. Mai 2015)

Hallo, 

ich bin neu hier und das ist mein erster Beitrag. Bislang bin ich ganz   gut ohne Hilfestellung zurechtgekommen, aber nun habe ich ein Problem,   das ich seit 3 Tagen schon zu lösen versuche, leider erfolglos.

Ich hoffe, jemand hier kann mir helfen. Ich wäre auch bereit, diese Hilfestellung zu entlohnen.

Und zwar geht es darum ...

Ich stelle dem Nutzer ein Texterea-Feld zur Verfügung, wo er etwas   hineinschreiben kann, aber leider wird dieser Inhalt nicht in die   Datenbank aufgenommen, sondern nur diese Klammern () !

Ich habe das wie folgt in die .php.datei eingetragen:

Zeile 128 $beispieltext= JRequest::getVar('textbeispiel');
Zeile 137 $value = (explode(" ", $beispieltext));
Zeile 170 ... , '$db->quote($beispieltext)', ...



```
public static function repin() {
        $db = JFactory::getDBO();


        if (JRequest::getVar('repin_id')) {
            ob_start();
            $res['board_id'] = JRequest::getVar('board_id');
            $res['description'] = JRequest::getVar('description');
            $res['repin_id'] = JRequest::getVar('repin_id');
            $res['pin_real_pin_id'] = JRequest::getVar('pin_real_pin_id');
            $res['pin_user_id'] = JRequest::getVar('pin_user_id');
            $repin = $res['repin_id'];
            $query = "select   pin_category_id,pin_real_pin_id,pin_repin_count,pin_type_id,pin_url,pin_image,link_type   from #__pin_pins where pin_id=$repin";
            $db->setQuery($query);
            $pins = $db->loadObjectList();
            $pin_type_id = $pins[0]->pin_type_id;
            $pin_url = $pins[0]->pin_url;
            $pin_image = $pins[0]->pin_image;
            $pin_link_type = $pins[0]->link_type;
            $pin_category_id = $pins[0]->pin_category_id;
            $board_id = $res['board_id'];
            $description = $res['description'];
            $repin_count = $pins[0]->pin_repin_count + 1;
            $pin_repin_id = $repin;
            $pin_real_pin_id = $pins[0]->pin_real_pin_id;
            $pin_user_id = $res['pin_user_id'];
            $date = JFactory::getDate();
            $current_date = $date->format("Y-m-d H:i:s");
            if ($pin_real_pin_id == 0) {

                $pin_real_pin_id = $repin;
            }
            $mailer = JFactory::getMailer(); //define joomla mailer
            $app = JFactory::getApplication();
            $db = JFactory::getDBO();
            $query = "SELECT    a.pin_board_id,a.pin_description,a.pin_image,a.link_type,a.pin_id,a.pin_description,b.first_name,b.last_name,b.email
                  FROM #__pin_pins AS a
                  INNER JOIN #__pin_user_settings AS b
                  ON a.pin_user_id=b.user_id
                  WHERE pin_id=$pin_real_pin_id";

            $db->setQuery($query);
            $pin_email = $db->loadObjectList();

            $query = "SELECT board_name
                  FROM #__pin_boards
                  WHERE board_id=" . $board_id;

            $db->setQuery($query);
            $board_name = $db->loadResult();



            $query = "SELECT first_name,last_name,email,user_image
                  FROM #__pin_user_settings
                  WHERE user_id=$pin_user_id";
            $db->setQuery($query);
            $pin_user_info = $db->loadObjectList();

            $user_image = $pin_user_info[0]->user_image;

            if ($user_image != '') {
                $user_image = JURI::base() . 'images/socialpinboard/avatars/' . rawurlencode($user_image);
            } else {
                $user_image = JURI::Base() . '/components/com_socialpinboard/images/no_user.jpg';
            }

            //mail functionality
            $config = JFactory::getConfig();
            $sender = $config->get('mailfrom');
            $site_name = $config->get('sitename');
            $mailer->setSender($sender);


            //set the body
            $templateparams = $app->getTemplate(true)->params; // get the tempalte parameters
            $logo = $templateparams->get('logo'); //get the logo

            if ($logo != null) {
                $image_source = JURI::base() . '/' . htmlspecialchars($logo);
            } else {
                $image_source = JURI::base() . '/templates/socialpinboard/images/logo-large.png';
            }

            $email = $pin_email[0]->email;

            $link_type = $pin_email[0]->link_type;
            $strImgName = $pin_email[0]->pin_image;
            $pin_description = $pin_email[0]->pin_description;
            if ($link_type == 'youtube' || $link_type == 'vimeo') {
                $strImgPath = $strImgName;
            } else {
                $strImgPath = JURI::base() . '/images/pin_thumb/' . $strImgName;
            }

            //set recipient
            $mailer->addRecipient($email);
            $Pin_user_name = $pin_email[0]->first_name . ' ' . $pin_email[0]->last_name;
            $pin_affect_user = $pin_user_info[0]->first_name . ' ' . $pin_user_info[0]->last_name;
            $pin_description = $pin_email[0]->pin_description;
            $pin_id = $pin_email[0]->pin_id;

            $subject = $pin_user_info[0]->first_name . ' repinned your pin';
            $baseurl = JURI::base();
            $repinned_user_url = JURI::base() .   'index.php?option=com_socialpinboard&view=boarddisplay&uid=' .   $pin_user_id;
            $repinned_pin_url = JURI::base() . 'index.php?option=com_socialpinboard&view=pin&pinid=' . $pin_id;
            $repinned_new_board_url = JURI::base() .   'index.php?option=com_socialpinboard&view=boardpage&bId=' .   $board_id;
            $message = file_get_contents(JURI::base() . '/templates/emailtemplate/repin.html');
            $message = str_replace("{baseurl}", $baseurl, $message);
            $message = str_replace("{site_name}", $site_name, $message);
            $message = str_replace("{site_logo}", $image_source, $message);
            $message = str_replace("{Pin_user_name}", $Pin_user_name, $message);
            $message = str_replace("{repinned_user_url}", $repinned_user_url, $message);
            $message = str_replace("{repinned_user}", $pin_affect_user, $message);
            $message = str_replace("{repinned_user_image}", $user_image, $message);
            $message = str_replace("{repinned_pin_url}", $repinned_pin_url, $message);
            $message = str_replace("{repin_image}", $strImgPath, $message);
            $message = str_replace("{pin_description}", $pin_description, $message);
            $message = str_replace("{repinned_new_board_url}", $repinned_new_board_url, $message);
            $message = str_replace("{new_board}", $board_name, $message);
            $mailer->isHTML(true);
            $mailer->setSubject($subject);
            $mailer->Encoding = 'base64';
            $mailer->setBody($message);
            $send = $mailer->Send();

            $repin = JRequest::getVar('repin_id');
            $beispieltext= JRequest::getVar('textbeispiel');
            $query = "UPDATE `#__pin_pins` SET   `pin_repin_count`=$repin_count,`updated_date`='$current_date' WHERE   pin_id=$repin";

            $db->setQuery($query);
            if (!$db->query()) {
                $this->setError($db->getErrorMsg());
                return false;
            }
            $price = $gift = '';
            $value = (explode(" ", $description));
            $value = (explode(" ", $beispieltext));
            $count = count($value);
            $query = "SELECT setting_currency from #__pin_site_settings";
            $db->setQuery($query);
            $currency = $db->loadResult();

            for ($i = 0; $i <= $count - 1; $i++) {
                if (preg_match("/^[" . $currency . "]|[0-9]+[.]+$/", $value[$i])) {
                    $price = $value[$i];
                    $price = (explode($currency, $price));
                    $price=$price[1];
                    if ($price != '' && $price) {
                        $query = "SELECT setting_currency from #__pin_site_settings";
                        $db->setQuery($query);
                        $currency = $db->loadResult();

                        if (preg_match("/[" . $currency . "]/", $value[$i])) {
                            $query = "SELECT setting_currency from #__pin_site_settings";
                            $db->setQuery($query);
                            $currency = $db->loadResult();
                            $is_price = explode($currency, $value[$i]);
                            if (is_numeric($is_price[1])) {
                                $gift = '1';
                            }
                        }
                    } else {
                        $gift = '0';
                    }
                }
            }

            $query = "INSERT INTO `#__pin_pins` (`pin_id`,   `pin_board_id`, `pin_user_id`, `pin_category_id`, `pin_description`,   `pin_tag_one`, `price`,`gift`, `pin_type_id`, `pin_url`, `pin_image`,   `pin_repin_id`, `pin_real_pin_id`, `pin_repin_count`,  `pin_likes_count`,  `pin_comments_count`, `pin_views`,  `status`,`link_type`,  `created_date`, `updated_date`) VALUES
('', $board_id, $pin_user_id, $pin_category_id, '$description',   '$db->quote($beispieltext)', '$price','$gift', $pin_type_id,   '$pin_url', '$pin_image', $pin_repin_id, $pin_real_pin_id, 0, 0, 0, 0,   1,'$pin_link_type', NOW(),NOW())";
            $db->setQuery($query);
            if (!$db->query()) {
                $this->setError($db->getErrorMsg());
                return false;
            }
            return $db->insertid();
        }
    }

    function rgb2html($r, $g=-1, $b=-1) {
        if (is_array($r) && sizeof($r) == 3)
            list($r, $g, $b) = $r;

        $r = intval($r);
        $g = intval($g);
        $b = intval($b);

        $r = dechex($r < 0 ? 0 : ($r > 255 ? 255 : $r));
        $g = dechex($g < 0 ? 0 : ($g > 255 ? 255 : $g));
        $b = dechex($b < 0 ? 0 : ($b > 255 ? 255 : $b));

        $color = (strlen($r) < 2 ? '0' : '') . $r;
        $color .= ( strlen($g) < 2 ? '0' : '') . $g;
        $color .= ( strlen($b) < 2 ? '0' : '') . $b;
        return '#' . $color;
    }

    public static function showRequest() {


        $db = JFactory::getDBO();
        $query = "SELECT setting_show_request FROM #__pin_site_settings";
        $db->setQuery($query);
        $show_request = $db->loadResult();

        return $show_request;
    }
```

Anhang anzeigen 7749

Was muss in dem Code geändert werden, damit der richtige Inhalt übertragen wird?


----------



## fehlerfinder (8. Mai 2015)

Vielleicht versuchst du's nochmal in einem PHP-Forum ;-)


----------

