dqxuiq7772 2012-02-23 20:38
浏览 36
已采纳

将$ item = mysql_fetch_assoc($ stmt)更改为预准备语句样式

This code works but I am trying to work out how to change the $rose = mysql_fetch_assoc($stmt); section to 'prepared statement style'. Anyone know?

$rose_id = $_GET['rose_id'];
  //prepare the statement
  $stmt = $conn2->prepare("SELECT * FROM rosename 
            LEFT JOIN rosevariety ON (rosename.variety_name = rosevariety.variety_name) 
            WHERE rose_id = ?");

            //bind the parameters
  $stmt->bind_param("i", $rose_id);

  //$sql = mysql_query($query, $conn);
  $stmt->execute();

  //was there a good response?
  if ($stmt) {

    $rose = mysql_fetch_assoc($stmt);

    //echo out rose information
    echo "<h1>".$rose['latin_name']."</h1>";
    echo "<h2>".$rose['common_name']."</h2>";
  • 写回答

3条回答 默认 最新

查看更多回答(2条)

报告相同问题?