Solved

Query Update / Set issue

Posted on 2011-03-15
4
255 Views
Last Modified: 2012-05-11
I have a piece of code that check a value against an value that is stored in a database.  My update script works if the information compared does not match.  However, it does not update if the row in the database is empty.  Do you have any clues?

[code}
$q = "UPDATE exp_weblog_data SET field_id_29='$new_bridge', field_id_30='$new_brand', field_id_31='$new_bridgePickup', field_id_32='$new_buyCodeUSA', field_id_33='$new_prod_color', field_id_34='$new_prod_displayName', field_id_35='$new_prod_msrp', field_id_36='$new_prod_part_number', field_id_37='$new_prod_upc', field_id_38='$new_casegigbag', field_id_39='$new_controlKnobs', field_id_40='$new_controls'  WHERE field_id_104='$prodNo' LIMIT 1";
[/code}
0
Comment
Question by:rgranlund
[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
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
Rik-Legger earned 250 total points
ID: 35142754
Which row in de database is empty? If 'field_id_104' is empty and $prodNo has as a value than it will never update.
Maybe you can give some more details on your problem?
0
 
LVL 39

Expert Comment

by:Aaron Tomosky
ID: 35142780
Do you mean it doesn't insert a row if it doesn't find prodno in fieldid104?
0
 
LVL 7

Author Comment

by:rgranlund
ID: 35142849
I mean if field_id_29='$new_bridge',   if Field_id_29 is empty and $new_bridge ='Wood'  it will not update.

ifield_id_29='$new_bridge',   if Field_id_29=' Metal' and $new_bridge ='Wood' it will update.
0
 
LVL 39

Assisted Solution

by:Aaron Tomosky
Aaron Tomosky earned 250 total points
ID: 35142938
But you are sure that the rest of the fields including the where 104 are there?
Because I see nothing wrong with your query unless the whole row is missing
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

752 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