Jump to content

Archived

This topic is now archived and is closed to further replies.

localhost

wont edit the news properly

Recommended Posts

[code]<?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>



[/code]

does not update inside the database! any ideas?

Share this post


Link to post
Share on other sites
try this


if($sqlr2){
echo "success;
} else {
echo mysql_error();
}

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.