dtt27783 2013-06-15 11:20
浏览 68

使用SELECT查询在MySQL上查找UPDATE查询

I'm using a SELECT query to obtain a variable using mysql_fetch_assoc. This then puts the variable into an UPDATE variable to put the returned value back into the database.

If I hard code the value, or use a traditional variable and it goes in just fine, but it doesn't work when using a value previously retrieved from the database. I've tried resetting the array variable to my own text and that works.

$arrgateRetrivalQuery = mysql_query(**Select Query**);
    $arrGate = mysql_fetch_assoc($arrgateRetrivalQuery);
    $arrivalGateTest = $arrGate['gatetype'];
$setGateAirportSQL = "UPDATE pilots SET currentgate = '".$arrivalGateTest."' WHERE pilotid = '".$pilotid."'";
    $setGateAirportQuery = mysql_query($setGateAirportSQL);

    // Close MySQL Connection
    mysql_close($link);

This will just make the field to update have nothing in it, however whenever I remove the variable from the SELECT to one I define, array or not, it will work.

Hope this is clear enough. Thanks in advance.

  • 写回答

2条回答 默认 最新

  • douxiaomang5640 2013-06-15 11:44
    关注

    Is arrivalGateTest a number or a string? How did you try to put another value in the query? If you are sure the previous query returns a value, try to write: $setGateAirportSQL = "UPDATE pilots SET currentgate = '$arrivalGateTest' WHERE pilotid = '$pilotid'";.

    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)