Solved

Query Update / Set issue

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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 dynamically set the form action using jQuery.

786 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