maintenance

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Kriek
Forum Contributor
Posts: 238
Joined: Wed May 29, 2002 3:46 am
Location: Florida
Contact:

maintenance

Post 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>");
        }
    }
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post 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'";
User avatar
Kriek
Forum Contributor
Posts: 238
Joined: Wed May 29, 2002 3:46 am
Location: Florida
Contact:

Post by Kriek »

Dan, keep in mind this isn't my code =)

I am merely attempting to solve the problem. Renaming had no effect.
User avatar
dstefani
Forum Contributor
Posts: 140
Joined: Sat Jan 11, 2003 9:34 am
Location: Meridian Idaho, USA

Post 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
Post Reply