简体   繁体   中英

Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'rowid' in 'where clause'

I'm trying to pass a href through an ID. It keeps giving me this weird error even though I've done this many times before. The error is:

Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'rowid' in 'where clause'

This is the line I use for the id in href:

<?php
    $link = mysql_connect("localhost", "root", "");
    mysql_select_db("meubelfabriek");
    $result = mysql_query("SELECT * FROM inbox") or 
    die(mysql_error());

    while($rowz = mysql_fetch_array($result)) {
        $id = $rowz['id'];

?>
<td>
<li class="list-group-item text-right"><a class="pull-left" href="login/email.php?id=rowid=<?= $rowz['id'] ?>">  <?php echo '<h7>' . $rowz['email'] . '</a> 2.13.2014</li>
</td>

email.php

<?php
echo "<table style='border: solid 1px black;'>";
echo "<tr><th>Id</th><th>Firstname</th><th>Lastname</th></tr>";

class TableRows extends RecursiveIteratorIterator {
    function __construct($it) {
        parent::__construct($it, self::LEAVES_ONLY);
    }

    function current() {
        return "<td style='width:150px;border:1px solid black;'>" . parent::current(). "</td>";
    }

    function beginChildren() {
        echo "<tr>";
    }

    function endChildren() {
        echo "</tr>" . "\n";
    }
}


$servername = "localhost";
$username = "root";
$password = "";
$dbname = "meubelfabriek";

try {
    $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    $id = $_GET['id'];

    $stmt = $conn->prepare("SELECT id, voornaam, achternaam, email, nummer, bericht FROM inbox WHERE id = $id");
    $stmt->execute();



    // set the resulting array to associative
    $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
    foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
        echo $v;
    }
}
catch(PDOException $e) {
    echo "Error: " . $e->getMessage();
}
$conn = null;
echo "</table>";
?>

In my database ID is just defined by ID. All the prepare statement is all written right. Does anyone know why I can't get this to work? In the past it seems to work just fine. Anyway I hope anyone could help me.

I think this line is wrong.

<li class="list-group-item text-right"><a class="pull-left" href="login/email.php?id=rowid=<?= $rowz['id'] ?>">  <?php echo '<h7>' . $rowz['email'] . '</a> 2.13.2014</li>

please change href

login/email.php?id=rowid=<?= $rowz['id'] ?>

to

login/email.php?id=<?= $rowz['id'] ?>
 <li class="list-group-item text-right"><a class="pull-left" href="login/email.php?id=<?= $rowz['id'] ?>">  <?php echo '<h7>' . $rowz['email'] . '</a> 2.13.2014</li>

Replace this line with your code. You have written rowid instead of $rowz['id']

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