Jump to content

MySQL version - syntax error?


wizzkid

Recommended Posts

Hi I create this script to edit an article on my news section.. But I encounter this error

Could update the entry because: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1. The query was UPDATE news SET date='2006-06-27', title='', article='' WHERE int_id=.


This is my edit_news.php code
[code]
<?php

ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);

require_once ('../include/LeePH/mysql_connect.php');

if (isset ($_POST['submit'])) {

// Define the query.
$query = "UPDATE news SET date='{$_POST['date']}', title='{$_POST['vc_title']}', article='{$_POST['vc_article']}' WHERE int_id={$_POST['id']}";
$r = mysql_query ($query);

// Report on the result.
if (mysql_affected_rows() == 1) {
print '<p>The blog entry has been updated.</p>';
} else {
print "<p>Could update the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}

} else { // Display the entry in a form.

// Check for a valid entry ID in the URL.
if (is_numeric ($_GET['id']) ) {

// Define the query.
$query = "SELECT * FROM news WHERE int_id={$_GET['id']}";
if ($r = mysql_query ($query)) { // Run the query.

$row = mysql_fetch_array ($r); // Retrieve the information.

// Make the form.
print '<form action="edit_news.php" method="post">
<p>Entry Date: <input type="text" name="date" size="40" maxsize="100" value="' . $row['date'] . '" /></p>
<p>Entry Title: <input type="text" name="title" size="40" maxsize="100" value="' . $row['vc_title'] . '" /></p>
<p>Entry Text: <textarea name="article" columns="40" rows="5">' . $row['vc_article'] . '</textarea></p>
<input type="hidden" name="int_id" value="' . $_GET['id'] . '" />
<input type="submit" name="submit" value="Update this Entry!" />
</form>';

} else { // Couldn't get the information.
print "<p>Could retrieve the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}

} else { // No ID set.
print '<p><b>You must have made a mistake in using this page.</b></p>';
}

} // End of main IF.

mysql_close(); // Close the database connection.

?>
[/code]

I am using these version of software:
OS: Kubuntu 6.06 Dapper
mySQL: MySQL 5.0.22-Debian_0ubuntu6.06-log
PHP: PHP 5.1.2
Apache:Apache/2.0.55

My Database Structure
int_id  - int
date - date
vc_title - string
vc_article - string


Thanks hope you can help!
Link to comment
Share on other sites

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.