doulu1914 2011-06-16 13:44
浏览 25

选择没有结果

I've tried this for hours. I can connect to my data base and insert into it but can't seem to get anything out of it.

// Declarations
    $connection = mysql_connect("xxxxxxx", "xxxxxxx", "xxxxxxxx");
    mysql_select_db("kettle_test1", $connection);
    if (!$connection)
        {
        die ('Cold not connect: ' . mysql_error());
        }
    else
    {
    echo "connected <br> <br>";
    }



// INSERT   

    mysql_query("INSERT INTO bob2 (Danumber)
    VALUES ('32234245')");

// QUERY AND DISPLAY

    $result = mysql_query("SELECT * FROM bob2");

    echo $result;

// if this is commented out I get the 'connected' message above. without it the page is blank,  
    while ($row = mysql_fetch_assoc($result)) {
    echo $row["Danumber"];
   
}
    
*/


    echo "<br> <br> <br>";
  • 写回答

2条回答 默认 最新

  • douxiangui5011 2011-06-16 13:51
    关注

    There are a lot of possibilities here. You could try, for example, the following things:

    • Use mysql_num_rows to check how many rows have been returned
    • Use print_r to print the whole row.
    • Use isset to check that the key "Danumber" actually exists

    Summarizing: use a lot more checks to make sure things you retrieve are actually there.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度