Jump to content

I hate coding sometimes


Noskiw

Recommended Posts

<?php if($_POST['add']):
   $obj->add_content($_POST);
elseif($_POST['update']):
   $obj->update_content($_POST);
endif;
?>

 

The error is

 

Fatal error: Call to undefined method modernCMS::update_content() in C:\xampp\htdocs\cms\admin\index.php  on line 31

 

The line is

 

$obj->update_content($_POST);

 

The function is...

 

function update_content()
{
    $title = mysql_real_escape_string($title);
    $body = mysql_real_escape_string($body);
    $id = mysql_real_escape_string($id);
    if (!$title || !$body) {
        if (!$title) {
            echo "<p>The Title is needed</p>";
        }
        if (!$body) {
            echo "<p>The Body is needed</p>";
        }

        echo "<p><a href='update-content.php?id=".$id."'>Try again!</a></p>";
    } else {
        $sql = "UPDATE cms_content SET title = '$title', body='$body' WHERE id='$id'";
        $res = mysql_query($sql) or die(mysql_error());
        echo "Row updated successfully";
    }
}

 

This function is also needed...

 

    function update_content_form($id)
    {
        $id = mysql_real_escape_string($id);
        $res = mysql_query("SELECT * FROM cms_content WHERE id='$id'") or die(mysql_error
            ());
        $row = mysql_fetch_assoc($res);
        echo '<form method="POST" action="index.php">
        <input type="hidden" name="update" value="true" />
        <input type="hidden" name="id" value="' . $row['id'] . '" />      
        <div>
        <label for="title">Title:</label>
        <input type="text" name="title" id="title" value="' . $row['title'] .
            '" />
        </div>
        <div>
        <label for="body">Body:</label>
        <textarea name="body" id="body" rows="8" cols="40">' . $row['body'] .
            '</textarea>
        </div>
        <input type="submit" name="submit" value="Edit" />
        </form>';
    }
}

 

This is buggging me. Thanfully after this is sorted, the website will be finished :')

Link to comment
Share on other sites

    function update_content($p){
        $title = mysql_real_escape_string($p['title']);
        $body = mysql_real_escape_string($p['body']);
        $id = mysql_real_escape_string($id);
        if (!$title || !$body) {
            if (!$title) {
                echo "<p>The Title is needed</p>";
            }
            if (!$body) {
                echo "<p>The Body is needed</p>";
            }

        echo "<p><a href='update-content.php?id=" . $id . "'>Try again!</a></p>";
        } else {
            $sql = "UPDATE cms_content SET title='".$title."', body='".$body."' WHERE id='".$id."'";
            $res = mysql_query($sql) or die(mysql_error());
            echo "Row updated successfully";
        }
    }

 

This is the new function. And this is there error.

 

Warning: Missing argument 1 for modernCMS::update_content(), called in C:\xampp\htdocs\cms\admin\index.php on line 33 and defined in C:\xampp\htdocs\cms\class\cms_class.php  on line 114

The Title is needed

The Body is needed

Try again!

 

EDIT: I've managed to fix the errors, but this time, it says that the row has been updated successfully, but yet, it hasn't updated... :o Any thoughts?

 

EDIT No2: It seems that when it says 'try again' The id wont show up, so the web address shows http://localhost/cms/admin/update-content?id=Which is annoying. I'm guessing that it has to do with this line

 

echo "<p><a href='update-content.php?id=" . $id . "'>Try again!</a></p>";

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.