Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > Putting it Together > Databases

Reply
 
LinkBack Thread Tools
Old September 13th, 2009, 07:11 AM   #1
WebForumz Member
 

Join Date: Apr 2008
Location: USA
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 galahad3 is on a distinguished road
mySQL syntax error but can't see how

Hi, getting an annoying mySQL syntax error when I run a query to a db, but the syntax looks fine as far as I can tell:

Error is: ERROR: 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 'index = '2'' at line 1

The PHP code is:

<?php
include ('inc/dbconnect.php');
if($_POST['specialoffers_updatetable'])
{
// Get the search variable from URL
$title1 =@$_POST['_Index'];

$title2 =@$_POST['_Category'];
$title3 =@$_POST['_CompanyHotel'];
$title4 =@$_POST['_Location'];
$title5 =@$_POST['_Offer'];
$title6 =@$_POST['_Price'];
$title7 =@$_POST['_OfferEnds'];
$title8 =@$_POST['_Mobile'];
$trimmed2 = trim($title2);
$trimmed3 = trim($title3);
$trimmed4 = trim($title4);
$trimmed5 = trim($title5);
$trimmed6 = trim($title6);
$trimmed7 = trim($title7);
$trimmed8 = trim($title8);

// Build SQL Query
$query = "UPDATE specialofferstable SET category = '$trimmed2', company_hotel = '$trimmed3', location = '$trimmed4', offer = '$trimmed5', price = '$trimmed6', offerends = '$trimmed7', mobile = '$trimmed8' WHERE index = '$title1'"; // specify the table and field names for the SQL query
}
if($result = mysql_query($query))
{
//go to the new member confirmation page
header('location: admin_confirmed.php');
exit;
}
else
{
echo "ERROR: ".mysql_error();
}
?>

So the code runs but it seems to have a problem with that query. It's getting the data okay from the form on the previous page but just doesn't seem to want to make the edit of the db.
Any ideas?
galahad3 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: syntax error Root Access PHP 1 April 6th, 2009 10:09 AM
SQL syntax error new2java PHP 8 July 30th, 2008 05:29 PM
syntax error... ktsirig Databases 2 February 4th, 2007 10:48 AM
Annoying little syntax error adeking HTML, XHTML and CSS 4 August 9th, 2006 09:50 AM
error in SQL syntax Drgreenfingers Databases 10 January 29th, 2006 10:00 PM


Search Engine Optimization by vBSEO 3.2.0 RC8