SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why won't this work?



    <!-- editauthor.php -->
    <HTML>
    <HEAD>
    <TITLE> Edit Author </TITLE>
    </HEAD>
    <BODY>
    <?php
    $dbcnx = @mysql_connect("localhost", "8888888888", "888888");if (!$dbcnx) { echo( "<P><b>Unable to connect to the database server at this time.</b></P>" ); exit();}
    mysql_select_db("petesmc_articles");

    if ($submit): // The author's details have
    // been updated.

    $sql = "UPDATE authors SET " .
    "Name='$name', " .
    "Description='$description', " .
    "Email='$email' " .
    "WHERE ID=$id";
    if (mysql_query($sql)) {
    echo("<P>Author details updated.</P>");
    } else {
    echo("<P>Error updating author details: " .
    mysql_error() . "</P>");
    }

    ?>

    <P><A HREF="authors.php">Return to Authors list</A></P>

    <?php
    else: // Allow the user to edit the author
    // with ID=$id

    $author=mysql_query("SELECT Name, Email, Descriptio " .
    "FROM Authors " .
    "WHERE ID=$id");
    if (!$author) {
    echo("<P>Error fetching author details: " .
    mysql_error() . "</P>");
    exit();
    }

    $author = mysql_fetch_array($author);

    $name = $author["Name"];
    $email = $author["Email"];
    $description = $author["Description"]

    // Add slashes to database
    // values for use as HTML attributes
    $name = addslashes($name);
    $email = addslashes($email);
    $description = addslashes($description);

    ?>

    <FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=POST>
    <P>Edit the authorBR>
    Name: <INPUT TYPE=TEXT NAME="name" VALUE="<?php echo($name); ?>" SIZE=20 MAXLENGTH=100><BR>
    eMail: <INPUT TYPE=TEXT NAME="email" VALUE="<?php echo($email); ?>" SIZE=20 MAXLENGTH=100><BR>
    Description<textarea name="description" ROWS=15 COLS=45 WRAP></textarea>
    <INPUT TYPE=HIDDEN NAME="id" VALUE="<?php echo($id); ?>">
    <INPUT TYPE=SUBMIT NAME="submit" VALUE="SUBMIT"></P>
    </FORM>

    <?php endif; ?>

    </BODY>
    </HTML>


    Can be found at http://216.74.101.27/admin.html

    select manage authors, then create an author, then try to edit it.

  2. #2
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Error on line 51 i think, the part about the slashes

  3. #3
    SitePoint Evangelist mad-onion's Avatar
    Join Date
    Aug 2000
    Location
    Land of the long white cloud
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No semicolon on the end of line 47
    $description = $author["Description"]
    it should read
    $description = $author["Description"];

    That oughta fix it!
    SiteOptions >> Services :: Products :: Contact
    Developers of PHP, C++, Visual Basic, MySQL, and more!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •