I'm completely stumped and going cross-eyed. I'm trying to add a second field for "bio" to edit in this script, but it doesn't work. It pulls the information from the database fine, and the bio field in the DB is a varchar field, not numeric. When I submit the changes, it only takes numeric entries... and puts " 0nbsp; " at the end of it. I want text. The other field ($description) above it works just fine. If I submit without making changes, it clears the text and leaves just the "0nbsp"

The field bio was originally a duedate field. I'm pretty sure I pulled anything that would generate dates, but I'm missing something.

script one is the function on the included php in db.php

public function update_auth1($auth1ID, $description, $bio) {
        $description = $this->real_escape_string($description);
        if ($bio==''){
            $this->query("UPDATE auth1es SET description = '" . $description . "',
                 bio = NULL WHERE id = " . $auth1ID);
        } else
        $this->query("UPDATE auth1es SET description = '" . $description .
                "', bio = " . $bio
                . " WHERE id = " . $auth1ID);
    }

Here's the script on the page where I'm viewing and trying to edit info

<?php

require_once("Includes/db.php");


    /** Checks whether the element with the "auth1" key in the $_POST array is empty,
     * which means that no description was entered.
     */ else if ($_POST['auth1'] == "") {
        $auth1DescriptionIsEmpty = true;
    }
    /** The "auth1" key in the $_POST array is NOT empty, so a description is entered.
     * Adds the auth1 description and the bio to the database via auth1DB.insert_auth1
     */ else if ($_POST['auth1ID'] == "") {
        auth1DB::getInstance()->insert_auth1($authorID, $_POST['auth1'], $_POST['bio']);
        header('Location: editAuth1List.php');
        exit;
    } else if ($_POST['auth1ID'] != "") {
        auth1DB::getInstance()->update_auth1($_POST['auth1ID'], $_POST['auth1'], $_POST['bio']);
        header('Location: editAuth1List.php');
        exit;
    }
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <?php
        if ($_SERVER['REQUEST_METHOD'] == "POST")
            $auth1 = array("id" => $_POST['auth1ID'],
                "description" => $_POST['auth1'],
                "bio" => $_POST['dueDate']);
        else if (array_key_exists("auth1ID", $_GET)) {
            $auth1 = mysqli_fetch_array(auth1DB::getInstance()->get_auth1_by_auth1_id($_GET['auth1ID']));
        } else
            $auth1 = array("id" => "", "description" => "", "bio" => "");
        ?>
        <form name="editauth1" action="editAuth1.php" method="POST">
            <input type="hidden" name="auth1ID" value="<?php echo $auth1['id']; ?>" />
            Author: <input type="text" name="auth1"  value="<?php echo $auth1['description']; ?>" /><br>
            <input type="text" name="bio"  value="<?php echo $auth1['bio']; ?>" />

       <br/>
            <?php
            if ($auth1DescriptionIsEmpty)
                echo "Please enter description<br/>";
            ?>
            Bio: <br/>
            <br/>
           
           
            
            <input type="submit" name="saveauth1" value="Save Changes"/>

        </form>
    </body>
</html>
Member Avatar for diafol
$this->query("UPDATE auth1es SET description = '$description', bio = '$bio' WHERE id = $auth1ID");

that ok?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.