wizzkid Posted July 22, 2006 Share Posted July 22, 2006 Hi I create this script to edit an article on my news section.. But I encounter this errorCould 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 DappermySQL: MySQL 5.0.22-Debian_0ubuntu6.06-logPHP: PHP 5.1.2Apache:Apache/2.0.55My Database Structureint_id - intdate - datevc_title - stringvc_article - stringThanks hope you can help! Link to comment https://forums.phpfreaks.com/topic/15320-mysql-version-syntax-error/ Share on other sites More sharing options...
shocker-z Posted July 22, 2006 Share Posted July 22, 2006 try usingint_id='{$_POST['id']}'";see if that works Link to comment https://forums.phpfreaks.com/topic/15320-mysql-version-syntax-error/#findComment-61997 Share on other sites More sharing options...
wizzkid Posted July 22, 2006 Author Share Posted July 22, 2006 Yeah! sorry it was bad.. :) I failed to put the ' ' its working now, Thanks. Link to comment https://forums.phpfreaks.com/topic/15320-mysql-version-syntax-error/#findComment-62009 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.