Styles2304 Posted August 16, 2007 Share Posted August 16, 2007 here's the 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 '' at line 1 Here's the actual code: $query = "UPDATE Announcements SET " . "EntryDate = '" . $EntryDate . "', " . "Data = '" . $Announcement . "', " . "OnGoing = '" . $OnGoing . "', " . "DeleteDate = '" . $DelDate . "', " . "PostBy = '" . $_SESSION['user_logged'] . "', " . "PublicAccess = '" . $PAccess . "' WHERE IndexNo = " . $IndexNo; mysql_query($query,$link) or die(mysql_error()); Do you guys see the prolem? Quote Link to comment https://forums.phpfreaks.com/topic/65155-solved-syntax-error-what-am-i-missing/ Share on other sites More sharing options...
AndyB Posted August 16, 2007 Share Posted August 16, 2007 Best guess - the last line of the query string should be "'$IndexNo'"; Better suggestion - change or die(mysql_error()) to or die(mysql_error(). " with query ". $query); // detailed info Quote Link to comment https://forums.phpfreaks.com/topic/65155-solved-syntax-error-what-am-i-missing/#findComment-325302 Share on other sites More sharing options...
Styles2304 Posted August 16, 2007 Author Share Posted August 16, 2007 That SHOULDN'T be it since IndexNo is an interger but I'll try it real quick and let you know. Quote Link to comment https://forums.phpfreaks.com/topic/65155-solved-syntax-error-what-am-i-missing/#findComment-325331 Share on other sites More sharing options...
Styles2304 Posted August 16, 2007 Author Share Posted August 16, 2007 Ok well, that got rid of the error but then it doesn't actually update the database . . . I'm guessing because IndexNo = 4 no '4' . . . know what I mean? Quote Link to comment https://forums.phpfreaks.com/topic/65155-solved-syntax-error-what-am-i-missing/#findComment-325333 Share on other sites More sharing options...
AndyB Posted August 16, 2007 Share Posted August 16, 2007 Next test: add a line to echo the actual query, i.e. echo $query; Post it here. Where do the values come from? I'm wondering if you're assuming register_globals in ON Quote Link to comment https://forums.phpfreaks.com/topic/65155-solved-syntax-error-what-am-i-missing/#findComment-325336 Share on other sites More sharing options...
Styles2304 Posted August 16, 2007 Author Share Posted August 16, 2007 Hmm, part of the problem is that IndexNo isn't transfering I guess UPDATE Announcements SET EntryDate = '0000-00-00', Data = 'This is a test', OnGoing = 'N', DeleteDate = '0000-00-00', PostBy = 'ztrusler', PublicAccess = 'Y' WHERE IndexNo = but in the link to that page I do: <a href="edit_announcements.php?IndexNo=$IndexNo">Edit</a> Am I doing something wrong? $IndexNo is most definitely defined on the page that I link from. Quote Link to comment https://forums.phpfreaks.com/topic/65155-solved-syntax-error-what-am-i-missing/#findComment-325342 Share on other sites More sharing options...
AndyB Posted August 16, 2007 Share Posted August 16, 2007 Well, I don't know where the rest of the values come from, but $IndexNo is passed by URL, so: $IndexNo = $_GET['IndexNo']; // retrieve var from passed parameter Quote Link to comment https://forums.phpfreaks.com/topic/65155-solved-syntax-error-what-am-i-missing/#findComment-325371 Share on other sites More sharing options...
Styles2304 Posted August 16, 2007 Author Share Posted August 16, 2007 here's my entire code except for the include statements which don't matter: //Defines variables $IndexNo = $_GET['IndexNo']; $EntryDate = $_POST['EntryDate']; $DelDate = $_POST['DeleteDate']; $OnGoing = $_POST['OnGoing']; $PAccess = $_POST['PAccess']; $Announcement = $_POST['Announcement']; //Sets up new query to enter variables into database $query = "UPDATE Announcements SET " . "EntryDate = '" . $EntryDate . "', " . "Data = '" . $Announcement . "', " . "OnGoing = '" . $OnGoing . "', " . "DeleteDate = '" . $DelDate . "', " . "PostBy = '" . $_SESSION['user_logged'] . "', " . "PublicAccess = '" . $PAccess . "' WHERE IndexNo = " . $IndexNo . ""; ?> <br> <?php echo $IndexNo; ?> <br> <?php echo $query; ?> With running that, I still get this with the echo statements: UPDATE Announcements SET EntryDate = '0000-00-00', Data = 'This is a test', OnGoing = 'N', DeleteDate = '0000-00-00', PostBy = 'ztrusler', PublicAccess = 'Y' WHERE IndexNo = It doesn't echo anything for IndexNo Quote Link to comment https://forums.phpfreaks.com/topic/65155-solved-syntax-error-what-am-i-missing/#findComment-325380 Share on other sites More sharing options...
Styles2304 Posted August 16, 2007 Author Share Posted August 16, 2007 Ok well, I ended up just posting the IndexNo in a hidden input field on the page before and then just referenced it with a $_POST variable. Seems to do the trick however I'm about to post ANOTHER one of my problems . . . Thanks for the help Andy Quote Link to comment https://forums.phpfreaks.com/topic/65155-solved-syntax-error-what-am-i-missing/#findComment-325634 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.