Jump to content

[SOLVED] mysql UPDATE form


tecmeister

Recommended Posts

Hi everyone,

 

I'm trying to update the date from my form but I seem to be getting a error 'parse error' this is the script that I have used:

 

<?php
		}
        if(isset($_GET['update']))
		{

			$id = $_GET['update'];

			$query = "SELECT * FROM news WHERE ID=$id LIMIT 1";
			$result = mysql_query($query);
			$r = mysql_fetch_assoc($result);

	?>
        		<form action="<?php $_SERVER['PHP_SELF']?>?update_complete=" method="post">
                	<table align="center" border=" 1px #ccc solid" cellspacing="0" cellpadding="2" style=" margin-top: 10px">
                    	<tr>
                        	<td>Header:</td>
                            <td><input type="text" name="header" value="<?php echo $r['header'] ?>" style=" width: 300px" /></td>
                            <input type="hidden" name="id" value="<?php echo $id ?>" />
                        </tr>
                        <tr>
                        	<td>News:</td>
                            <td><textarea cols="60" rows="10" name="news"><?php echo $r['news'] ?></textarea></td>
                        </tr>
                        <tr>
                        	<td>Date:</td>
                            <td><input type="text" name="date" value="<?php echo $r['date'] ?>" /></td>
                        </tr>
                        <tr>
                        	<td></td>
                            <td><input type="submit" value="Add News" name="update_news" /></td>
                        </tr>
                    </table>
                </form>
        <?php
		}
	?>
        

<?php
if(isset($_POST['update_news']))
{
	$id = $_POST['id'];
	$header = $_POST['header'];
	$news = $_POST['news'];
	$date = $_POST['date']

	mysql_query("UPDATE news SET header='$header', news='$news', date='$date' WHERE ID=$id");
}
?>

 

Thanks for you help,

 

tecmeister.

Link to comment
https://forums.phpfreaks.com/topic/152487-solved-mysql-update-form/
Share on other sites

What's the exact error?

 

And put this after you query in case it contains errors.  This will kill the script and output a "descriptive" error message.

 

mysql_query("UPDATE news SET header='$header', news='$news', date='$date' WHERE ID=$id") or die(mysql_error());

Archived

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

×
×
  • Create New...

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.