Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

Syntax Error on Update

Hi,

I am sure that this is very easy.

What I need to do is to assign a variable during a update.

<?
// Make a MySQL Connection
mysql_connect("design", "design", "Pdesign") or die(mysql_error());
mysql_select_db("design") or die(mysql_error());
?>

<?php
if( isset($_POST["AOI"]) ) {
   $set_part = 'SET H_IL_FILM_AOI_STAMP = NOW()';
   $stamp = 'set H_IL_FILM_AOI = yes';
}
else {
   $set_part = 'SET R_IL_FILM_AOI_STAMP = NOW()';
   $stamp = 'set H_IL_FILM_AOI = no';
}
   
mysql_query("UPDATE PROJECT $set_part, $stamp WHERE REC_NO = 62") or die("Upate error : " . mysql_error());
?>


The $ stamp seems to be the problem

Thanks
0
jjcheap1
Asked:
jjcheap1
  • 4
1 Solution
 
BatalfCommented:
if( isset($_POST["AOI"]) ) {
   $set_part = 'SET H_IL_FILM_AOI_STAMP = NOW()';
   $stamp = ', H_IL_FILM_AOI = yes';
}
else {
   $set_part = 'SET R_IL_FILM_AOI_STAMP = NOW()';
   $stamp = ', H_IL_FILM_AOI = no';
}
0
 
BatalfCommented:
You had two "set" keywords in your query.
0
 
BatalfCommented:
Actually, it should be like this:

if( isset($_POST["AOI"]) ) {
   $set_part = 'SET H_IL_FILM_AOI_STAMP = NOW()';
   $stamp = ' H_IL_FILM_AOI = yes';
}
else {
   $set_part = 'SET R_IL_FILM_AOI_STAMP = NOW()';
   $stamp = ' H_IL_FILM_AOI = no';
}

since you have a comma in your query below.
0
 
jjcheap1Author Commented:
Hi



I should have mention that I tried this.

This is the error now.

Upate error : Unknown column 'no' in 'field list'


Thanks
0
 
BatalfCommented:
if( isset($_POST["AOI"]) ) {
   $set_part = 'SET H_IL_FILM_AOI_STAMP = NOW()';
   $stamp = " H_IL_FILM_AOI = 'yes'";
}
else {
   $set_part = 'SET R_IL_FILM_AOI_STAMP = NOW()';
   $stamp = " H_IL_FILM_AOI = 'no'";
}

Quotes were missing around yes and no.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now