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
Solved

Query Update / Set issue

Posted on 2011-03-15
4
250 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
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Split wordpress loop 35 56
Number of reviews not counting correctly 2 22
Need to remove %20 from url in get 17 36
AJAX Wordpress Not Reading Variable 2 27
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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.

809 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