?
Solved

Syntax Error on Update

Posted on 2005-02-28
5
Medium Priority
?
241 Views
Last Modified: 2011-04-14
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
Comment
Question by:jjcheap1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 32

Expert Comment

by:Batalf
ID: 13422546
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
 
LVL 32

Expert Comment

by:Batalf
ID: 13422548
You had two "set" keywords in your query.
0
 
LVL 32

Expert Comment

by:Batalf
ID: 13422559
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
 

Author Comment

by:jjcheap1
ID: 13422887
Hi



I should have mention that I tried this.

This is the error now.

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


Thanks
0
 
LVL 32

Accepted Solution

by:
Batalf earned 2000 total points
ID: 13422900
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

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question