Jump to content
iwato

Retrieve Escaped Characters from a MySQL Data Table

Recommended Posts

DILEMMA:  My goal is to style the body of a newsletter template.  Although I am able to get the formatting into the database and -table, I am unable to retrieve it for insertion in the newsletter's template.  Please find below an example of the way in which the value string of only one of the several SQL INSERT statements is created.  The string that results is later combined with a name string and other elements of a valid INSERT statement.

EXAMPLE OF THE WAY THE INSERTED VALUE IS FORMATTED

include_once('../_utilities/php/classes/class.lunarpages.php');
$lunarpages = new Lunarpages();
$mysqli_obj = $lunarpages->get_mysqli_obj();
var_dump($mysqli_obj);

$sql_letter_val = "('";
$substr_start = 0;
$substr_length = 8;
foreach ($newsvar_names as $name => $value) {
    if (substr($name, $substr_start, $substr_length) == '$letter_') {
    $sql_letter_val .= $mysqli_obj->real_escape_string($value) . "', '";
    }
}

WHAT APPEARS IN THE DATA TABLE AFTER INSERTION

<h1>ようこそ!</h1>

<p><span style='font-family:Bradley Hand, cursive;font-size:1.8em;'>Seven Gates</span>」と言うのは文法キャプチッブのオンラインニューズレターです。</p>

<p>このニューズレターの初版は文法キャプチッブの紹介としてニューズレターの構成及び文法キャプチッブの本質をユーザー達にその母語で説明しています。第二版のニューズレター以降のニューズレターは英語で書いてあるものです。もしニューズレターの初版を英語でも読んだ方が好いとすれば、ウェブ型の変形が<a href='https://www.grammarcaptive.com/?newsletter=1' title='Seven Gates - Edition No. 1'  target='_blank'>ここに</a>見付かります。</p>

THE RETRIEVAL CODE 

public function get_letter_data() {
    $sql = "SELECT letter.*, qa.qa_question, qa.qa_answer
                FROM sevengates_letter AS letter
                JOIN sevengates_qa AS qa
                    ON qa.letter_no = letter.letter_no
                    WHERE letter.letter_no =?";

    $mysqli_stmt = $this->mysqli_obj->stmt_init();
    $mysqli_stmt->prepare($sql);
    $mysqli_stmt->bind_param('i', $this->letter_no);
    $mysqli_stmt->execute();
    $meta = $mysqli_stmt->result_metadata();
    while ($field = $meta->fetch_field()) {
        $params[] = &$row[$field->name];
    }
    call_user_func_array(array($mysqli_stmt, 'bind_result'), $params);
    while ($mysqli_stmt->fetch()) {
        foreach($row as $key => $val) {
            $c[$key] = $val;
        }
        $prelim_result[] = $c;
    }
    foreach ($prelim_result as $arr) {
        foreach ($arr as $name => $value){
            $letter_results[$name] = $value;
        }
    }
    return $letter_results;
}

WHAT IS RETRIEVED and APPEARS IN THE NEWSLETTER

ようこそ!

DISCUSSION:  Everything after the <h1> element has been omitted.  

QUESTION:  What must I do to get everything after ようそう!to appear?

Roddy

 

Share this post


Link to post
Share on other sites

Please ignore this question.  The problem has been resolved.

Roddy

Edited by iwato

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...