Jump to content

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());

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.