Jump to content

PHP cms via phpacademy


rangersko

Recommended Posts

OK i am trying to add a posters id/username onto my mysql database. I added a table and 
i am making a progress but the only part i am stuck on is the php side... I get no more errors when i create the article but it doesnt post onto mysql, it just refreshes the page kinda thing.

In artictles.php in templates
<textarea cols="40" rows="1" name="postid" disabled="disabled"><?php echo $user->username(); ?></textarea><br />


In articles.php in admin
if (isset($_POST['title'], $_POST['content'], $_POST['postid'])) {
        $title = $_POST['title'];
        $content = $_POST['content'];
        $postid = $_POST['postid'];

if (!isset($error)) {
            $article->add($title, $content, $postid);

 
I think this part is the wrong part
public function add($title, $content, $postid) {
        global $pdo;

        $query = $pdo->prepare('INSERT INTO articles (article_title, article_content, artictle_postid ,article_timestamp) VALUES (?, ?, ?, ?)');

        return $query->execute(array(
            $title,
            $content,
            $postid,
            time()
        ));
Link to comment
Share on other sites

More code would be helpful in solving this.

 

I'm guessing you ARE getting errors, but aren't seeing them. Can you check your error_logs?

 

If you actually aren't getting any errors and nothing is being inserted into that table, then the add() function isn't executing, meaning the $error variable is probably set.

 

Remember, a variable can be empty, but still "set."

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.