Page 1 of 1

maintenance

Posted: Sun Feb 09, 2003 4:47 pm
by Kriek
Trying to solve a maintenance problem that my associate is having. Everything displays correctly it just wont update the Database. This is obviously not all the code, but I assume this is where the problem is.

Code: Select all

}
        elseif(($EDITARTICLE1) && ($EDITARTICLE2)) {
            echo ("Please select something to edit.");
        }
        elseif((!$EDITARTICLE1) && ($EDITARTICLE2)) {
            $ID2 = $_POST["ID2"];
            $CATEGORY2 = $_POST["CATEGORY2"];
            $POSTER2 = $_POST["POSTER2"];
            $TOPICNAME2 = $_POST["TOPICNAME2"];
            $ARTICLE2 = $_POST["ARTICLE2"];
            $ARTICLEDESCRIPTION2 = $_POST["ARTICLEDESCRIPTION2"];
            include("dbinfo.php");
            $query = "UPDATE articles SET
                name='$TOPICNAME', poster='$POSTER', article='$ARTICLE', description='$ARTICLEDESCRIPTION'
                WHERE id='$ID'";
            $result = mysql_query($query) or die(mysql_error());
            echo ("Article $ID edited.<p><a href="maintenance.php?page=editarticle">Click here to go back</a>");
        }
    }

Posted: Sun Feb 09, 2003 5:58 pm
by hob_goblin
Could be a lot of things, maybe your not connecting to the databse correctly?

Have you tried running mysql_escape_string() on the $_POST variables?

Actually, do you notice that, you're naming variables like

ID2, CATEGORY2, POSTER2

and your query is using ID, POSTER, etc...

try changing

Code: Select all

$query = "UPDATE articles SET 
                name='$TOPICNAME', poster='$POSTER', article='$ARTICLE', description='$ARTICLEDESCRIPTION' 
                WHERE id='$ID'";
to

Code: Select all

$query = "UPDATE articles SET 
                name='$TOPICNAME2', poster='$POSTER2', article='$ARTICLE2', description='$ARTICLEDESCRIPTION2' 
                WHERE id='$ID2'";

Posted: Sun Feb 09, 2003 7:04 pm
by Kriek
Dan, keep in mind this isn't my code =)

I am merely attempting to solve the problem. Renaming had no effect.

Posted: Sun Feb 09, 2003 8:17 pm
by dstefani
Basic debugging I guess...

I see control structures, are you making it past all the conditions to make it to the query?

If you are, are you fullfilling the WHERE = ? Is there a match?

You've also got include "dbinfo.php" , this could be riddled with bugs.

Hmm, should I even post this...?

Sure.

Sorry I couldn't be more help.

- D