简体   繁体   中英

MySQL Update 2 tables using 2 mysql_query() in single php script

for(some loop condition):
mysql_query("UPDATE `details` SET
    `url_battlelog`                     = '".$stats[$out]['url_battlelog']."',
    `url_bf3stats`                      = '".$stats[$out]['url_bf3stats']."',
    `rank_img_medium`                   = '".$stats[$out]['rank_img_medium']."',
    `country_name`                      = '".$stats[$out]['country_name']."',
    `country`                           = '".$stats[$out]['country']."',
    `country_flag`                      = '".$stats[$out]['country_flag']."',
    `rank_number`                       = '".$stats[$out]['rank_number']."',
    `score_total`                       = '".$stats[$out]['score_total']."',
    `time_total`                        = '".$stats[$out]['time_total']."',
    `dogtag_basic_img`                  = '".$stats[$out]['dogtag_basic_img']."',
    `dogtag_basic`                      = '".$stats[$out]['dogtag_basic']."',
    `dogtag_advance_img`                = '".$stats[$out]['dogtag_advance_img']."',
    `dogtag_advance`                    = '".$stats[$out]['dogtag_advance']."'
WHERE `name_player` = '".$stats[$out]['name_player']."'
")
or die(mysql_error());

for(2nd loop condition):
mysql_query("UPDATE `weapons` SET
    `img`                                   = '".$gun_img."',
    `name`                                  = '".$gun_name."',
    `kit`                                   = '".$gun_kit."',
    `time`                                  = '".$gun_time."',
    `kills`                                 = '".$gun_kills."',
    `headshots`                             = '".$gun_hs."',
    `shots`                                 = '".$gun_shots."',
    `hits`                                  = '".$gun_hits."',
    `star_total`                            = '".$gun_star_c."',
    `star_img`                              = '".$gun_star_i."',
    `star_need`                             = '".$gun_star_n."',
    `rank_curr`                             = '".$gun_rank_c."',
    `rank_all`                              = '".$gun_rank_w."',
    `desc`                                  = '".$gun_desc."',
    `category`                              = '".$gun_cat."',
    `range`                                 = '".$gun_range."',
    `fire_rate`                             = '".$gun_fire_rate."',
    `ammo`                                  = '".$gun_ammo."',
    `auto_fire`                             = '".$gun_fire_auto."',
    `burst_fire`                            = '".$gun_fire_burst."',
    `single_fire`                           = '".$gun_fire_single."',
    `unlock_total`                          = '".$unlock_total."',
    `unlock_done`                           = '".$unlock_done."',
    `unlock_p`                              = '".round($unlock_p)."'
WHERE `name_player` = '".$stats[$out]['name_player']."'
")
or die(mysql_error());

the problem is that only 2nd table (weapons) is updating, 1st table (details) is not showing any changes. Doesn't show any error.

I have same type of script for inserting data into both tables and its working fine.

I'm new to MySQL and PHP. sorry for bad English....

did you test by writing your SQL ? I think your [WHERE] condition is not fully filled

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM