Solved

Query Update / Set issue

Posted on 2011-03-15
4
236 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 38

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 38

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

760 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now