Jump to content

u00a


doddsey_65

Recommended Posts

here is the code which inserts the content into the database:

 

$sql = "INSERT INTO ".TBL_PREFIX."posts
                (p_tid, 
                p_fid, 
                p_poster, 
                p_name, 
                p_content, 
                p_time_posted)
                VALUES
                (:topic_id, 
                :forum_id, 
                :poster, 
                :post_name, 
                :post_content, 
                :time_posted)";
        
        // prepare the sql statement        
        $sth = $db->prepare($sql);
        
        // execute the sql statement
        $sth->execute(array(
            ':topic_id'        => $data->post[3]->topic_id,
            ':forum_id'        => $data->post[2]->forum_id,
            ':poster'        => $user['u_username'],
            ':post_name'    => $data->post[0]->subject,
            ':post_content'    => $data->post[1]->content,
            ':time_posted'    => time()
            )
        )or die($db->printError($sql));

 

Link to comment
Share on other sites

you wont be able to test it without registering, sorry.

 

I think it could be json_encode() which is converting new lines to 'u00a'.

 

here is the code to insert to the database:

 

$db = db_pdo::$instance;
    
    $data = json_decode(stripslashes($data));
    
    $user = sessionsClass::$data;
    
    if(empty($data->post[0]->subject))
    {
        $data->post[0]->subject = 'No Subject';
    }
    
    if(empty($data->post[1]->content))
    {
        $data->status[0]->error = 'You must supply a message body';
    }    
// sql for post insertion
        $sql = "INSERT INTO ".TBL_PREFIX."posts
                (p_tid, 
                p_fid, 
                p_poster, 
                p_name, 
                p_content, 
                p_time_posted)
                VALUES
                (:topic_id, 
                :forum_id, 
                :poster, 
                :post_name, 
                :post_content, 
                :time_posted)";
        
        // prepare the sql statement        
        $sth = $db->prepare($sql);
        
        // execute the sql statement
        $sth->execute(array(
            ':topic_id'        => $data->post[3]->topic_id,
            ':forum_id'        => $data->post[2]->forum_id,
            ':poster'        => $user['u_username'],
            ':post_name'    => $data->post[0]->subject,
            ':post_content'    => $data->post[1]->content,
            ':time_posted'    => time()
            )
        )or die($db->printError($sql));

 

when the form is submitted its contents are processed using:

 

$j('form[name="new_post_form"]').submit(function(e){
        e.preventDefault();
        var data = {
            'post':
            [
                {subject        :    asf.getInput('subject')},
                {content        :    asf.getInput('post_content')},
                {forum_id        :    '{FORUM_ID}'},
                {topic_id        :    '{TOPIC_ID}'}
            ]
        }
        
        asf.handleForm(data, './new_post.php?method=add_{METHOD}');
    });

this.handleForm = function(data, file, redirect)
    {
        data.status = [{
            error    :    '',
            success    :    ''
        }];
        
        dataString = JSON.stringify(data);
        
        $j.post(file, 
        {
            data : dataString
        }, function(result)
        {
            var obj = JSON.parse(result);
            
            if(obj.status[0].error)
            {
                handleProcess('error',obj.status[0].error);
            }
            else
            {
                handleProcess('success',obj.status[0].success);
                
                if(redirect)
                {
                    document.location = redirect;
                }
            }
            
        });
    }

 

and then sent to the above php script

 

Link to comment
Share on other sites

Edit: I started writing this about 5 replies ago.

 

new lines

 

New lines gotten from where? A keyboard typing into a form? From a copy/paste from a Word document? Also, how do you know the data is - u00a? How are you looking at or displaying that value?

 

Without all your code (the form and the from processing code from the start of the file through to that query) that duplicates the symptom, no one here can directly help you with what could be causing the problem. I could easily name 12 different things that could be altering the data or causing it to be displayed like that, from javascrpt in your form to the database table definition to a browser debugging plug-in, but no one here is going to spend time guessing what your relevant code is, to either eliminate or confirm your code as the source of the problem.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.