Jump to content


Problems with this...


  • You cannot reply to this topic
No replies to this topic

#1 Blitz

    Jedi In Training

  • Twodded Staff
  • PipPip
  • 307 posts
  • Location:California
  • Interests:Php, html, css, etc, band, trumpet, anime, my dog, TV, computers, video games, sleeping, marching band, sleeping, jazz, sleeping, metal, sleeping, classic rock, sleeping, music, jazz band, did I mention sleeping?, kicking the hell out of kids that won't take the time to spell or use proper grammar, my website, etc.

Posted 26 December 2004 - 02:05 AM

Hey, I've been trying to do something to edit my news, but this always screws up. It seems to work fine except the title always goes to 0 and nothing else changes.

Here's the snippet of code.

case "list":
 	 $selectnews = "SELECT * FROM news";
 	 $querynews = mysql_query($selectnews) or die(mysql_error());
 	 while($news = mysql_fetch_array($querynews)){
 	 extract($news);
 	 echo "<a href='shadowpanel.php?act=news&code00=edit&id=$id'>$title</a><br>";
 	 }//whileend
 	 break;
 	 case "edit":
 	 $selectna = "SELECT * FROM news WHERE id = '$id'";
 	 $queryna = mysql_query($selectna) or die(mysql_error());
 	 $title2 = mysql_result($queryna, 0, title);
 	 $author = mysql_result($queryna, 0, author);
 	 $content = mysql_result($queryna, 0, content);
 	 $email = mysql_result($queryna, 0, email);
 	 echo "<form action='shadowpanel.php?act=news&code00=editpost&id=$id' method='POST'>
 	 Title: <input type='text' name='title' value='$title2'><br>
 	 Author: <input type='text' name='author' value='$author'><br>
 	 Email: <input type='text' name='email' value='$email'><br>
 	 <textarea width='500' height='500' name='content'>$content</textarea><br>
 	 <input type='submit' value='Edit'>
 	 </form>";
 	 break;
 	 case "editpost":
 	 $title2 = $_POST[title];
 	 $author = $_POST[author];
 	 $email = $_POST[email];
 	 $content = $_POST[content];
 	 $insertedit = "UPDATE news SET title = \"$title2\" AND author = '$author' AND content = \"$content\" AND email = '$email' WHERE id = '$id'";
 	 $queryedit = mysql_query($insertedit) or die(mysql_error());
 	 if($queryedit){
 	 echo "Update complete!";
 	 }
 	 else {
 	 echo "There was a problem.";
 	 }
 	 break;

This is the part of the code that applies to the part of this. Does anyone see a problem with it? If so, how can I fix it?

Remember, this is only a part of the whole code for my administration that I'm trying to code.

EDIT: Hahaha, I got it. You don't use AND in the UPDATE query, you use commas. :) Silly me.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users