Echo results from mysqli_Query

前端 未结 3 803
离开以前
离开以前 2020-12-18 11:54

I\'m making a personal script for my own use, and I need to know how to echo the results from a mysqli_query. My code is as follows:

$conn = mysqli_connect($         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-18 12:44

    First of all as @fred-ii said, escape your post, there is also an error in your $_POST access, you are missing quotes around article key, and lastly use mysqli_fetch_assoc to acces your results:

    ...
    if (isset($_POST['0'])) {
        $article = mysqli_real_escape_string($conn, $_POST['article']);
        $sql = "SELECT email FROM CommercialEmails WHERE articleid = '$article' AND dripid = 1 AND sent='a'";
        if ($resultsd1 = mysqli_query($conn, $sql)) {
            if ($row = mysqli_fetch_assoc($resultsd1)) {
                echo $row['email'];
            }
        }
    }
    ...   
    

提交回复
热议问题