prepare() vs query() mysqli

Elobbuirius

New Member
I am trying to understand the difference between mysqli's query() and prepare(). I have code like below, and I would like to get the same results from both. However the prepare() does not work as expected. why? \[code\] // this works if ($query = $this->db->query("SELECT html FROM static_pages WHERE page = 'cities'")) { $result = $query->fetch_row(); echo $result[0]; $query->close(); } //this does not work //result is empty $cities = 'cities'; $stmt = $this->db->prepare("SELECT html FROM static_pages WHERE page = ?"); $stmt -> bind_param("s", $cities); $stmt->execute(); $stmt->bind_result($result); $stmt->fetch(); echo $result; $stmt->close(); $this->db->close();\[/code\]these are my server configs as requested:OSVista 64bit / PHP Version 5.2.9mysqliMysqlI Support enabledClient API library version 5.0.51aClient API header version 5.0.51aMYSQLI_SOCKET /tmp/mysql.sockDirective Local Value Master Valuemysqli.default_host no value no valuemysqli.default_port 3306 3306mysqli.default_pw no value no valuemysqli.default_socket no value no valuemysqli.default_user no value no valuemysqli.max_links Unlimited Unlimitedmysqli.reconnect Off Off
 
Back
Top