Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/65155-solved-syntax-error-what-am-i-missing/
Share on other sites

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.

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

 

 

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

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.