dongtang7347 2014-08-23 03:38
浏览 124


I have what I thought would be a simple process updating old "mysql" code to "mysqli." In a number of places there was code that iterated through a multi-dimensional array to get the values. I'm trying to make a similar loop and use either mysqli_fetch_array or mysqli_fetch_all and am just banging my head against a wall. Either the process fails (hang) or else it doesn't return any values. I have looked all over the web and found various examples, none of which have quite worked...often they're not for procedural method (

I currently have:

$query2 = "SELECT * FROM mp WHERE email='$email'";

//connect to database    
$con = mysqli_connect($host,$username,$password,$database);                 

$result2=@mysqli_query($con, $query2);
$array = mysqli_fetch_array($result2, MYSQLI_BOTH);
@mysqli_close($con);  //question...does this need to come later, after num_rows?


while ($a < $num2)
//cycle through to get info...this comes up blank, when it should have 3 sets of values.
            echo "Column: ".$var1." and ID: ".$var2;

I've seen a lot of answers that essentially say "Use PDO" or "why use procedural? Object oriented is the way to go" but I'm really not looking to do a different style. It would be great to just know what's causing the above to fail. I can't be too far off, right? Thank you in advance for the help!

  • 写回答

1条回答 默认 最新


      相关推荐 更多相似问题


      • ¥15 关于用matlab进行光束整形的问题
      • ¥15 vs code编译器 C语言刚学,想的有点复杂
      • ¥15 航班订票系统函数无法运行
      • ¥20 VS2022无法启动程序,如何解决?(语言-c++|开发工具-visual studio)
      • ¥15 c语言可以做出完整的吗有人看看吗
      • ¥15 电脑流氓插件处理方法
      • ¥15 问一下这个可调恒流源电路用哪个电源接口比较好,想用tapec接口仅作为电源接口这个引脚怎么连啊
      • ¥30 Abaqus做建模的时候网格没办法收敛是为什么?
      • ¥15 车牌识别摄像镜头,httppost,nodejs
      • ¥20 腾讯云托管与本地测试 GET请求获取返回值 完全不同