Jump to content


Photo

wont edit the news properly


  • Please log in to reply
6 replies to this topic

#1 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 12 July 2006 - 11:38 PM

<?php
session_start();

include('../connect.php');

$loggedin = $_SESSION['username'];

if(!$loggedin){ // IF NOT LOGGED IN
include('login.php');
die();
}

$id = $_GET['id'];

$sql = "SELECT * FROM news WHERE id = '$id'";
$sqlr = mysql_query($sql) or die(mysql_error());

while($row = mysql_fetch_array($sqlr))
{
$newsid = $row['id'];
$newstitle = $row['title'];
$newsnews = $row['news'];
}

if(isset($_POST['submit']) && !empty($_POST['title']) && !empty($_POST['news']))
{

$title = $_POST['title'];
$news = $_POST['news'];

$sql2 = "UPDATE news SET title = '$title' AND news = '$news' WHERE id = '$id'";
$sqlr2 = mysql_query($sql2) or die(mysql_error());

if($sqlr2){
echo "<script>window.location=\"../news.php\"</script>";
}
}
?>

<form action="editnews.php" method="POST">
  <p>Title: 
    <input type="text" name="title" value="<?php echo "$newstitle"; ?>"/>
    <br />
News:<BR>
<textarea name="news" cols="50" rows="20"><?php echo "$newsnews"; ?></textarea>
    <br />
    <input type="submit" name="submit" value="Edit" />
</form>




does not update inside the database! any ideas?

#2 play_

play_
  • Staff Alumni
  • Advanced Member
  • 717 posts

Posted 12 July 2006 - 11:47 PM

are you getting a mysql_error message?
regex.kat.sh --- regex library
u.kat.sh ---- url shortener
tabbit.org ---- tabbed pastebin

#3 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 12 July 2006 - 11:57 PM

no.

#4 digitalgod

digitalgod
  • Members
  • PipPipPip
  • Advanced Member
  • 374 posts

Posted 13 July 2006 - 12:05 AM

try to echo $id just before the sql statement and make sure that id exists

#5 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 13 July 2006 - 12:18 AM

it does...

#6 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 13 July 2006 - 01:14 AM

anyone please? i need to get this done soon.

#7 play_

play_
  • Staff Alumni
  • Advanced Member
  • 717 posts

Posted 13 July 2006 - 02:43 AM

try this


if($sqlr2){
echo "success;
} else {
echo mysql_error();
}
regex.kat.sh --- regex library
u.kat.sh ---- url shortener
tabbit.org ---- tabbed pastebin




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users