THAT DOES THE TRICK. Now on to studying, store_results(). Thanks a lot.
I am new to the mysqli, trying to wrap my head around it. – Mike Aug 24 '10 at 18:48 Check for more details: us3.php. Net/manual/en/mysqli-stmt.
Store-result. Php . Btw, if it helps, I would be happy to get a '+' – a1ex07 Aug 24 '10 at 18:54 On a side note, it does make you wonder why bind_result was not suffice.
– Mike Aug 24 '10 at 18:56 @Mike: It should suffice. It's "only" the difference between buffered and unbuffered queries. Us3.php.Net/manual/en/mysqli-stmt.
Store-result. Php says: "You must call mysqli_stmt_store_result() for every query that successfully produces a result set (SELECT, SHOW, DESCRIBE, EXPLAIN), and only if you want to buffer the complete result set by the client, so that the subsequent mysqli_stmt_fetch() call returns buffered data." – VolkerK Aug 24 '10 at 19:00 Very nice. And to continue the lesson here is a nice post on buffered vs unbuffered sitepoint.
Com/forums/showthread. Php? T=471650 PS.
I would provide a + but I need 15 reps for that. – Mike Aug 24 '10 at 19:10.
Any of the mysqli_* functions can fail. In this case the return value is false and the error/errno properties of the mysqli or mysqli_stmt object contains more information about the error. The script has to test each and every return value and react appropriately on error condition (e.g.It doesn't make sense to prepare the statement if the connection failed).
Init(); $foo->bar(); class Foo { public function bar() { $cities = 'cities'; $stmt = $this->db->prepare("SELECT html FROM soTest WHERE page =? "); if (!$stmt ) { echo "prepare failed\n"; echo "error: ", $this->db->error, "\n"; return; } $rc = $stmt->bind_param("s", $cities); if (!$rc ) { echo "bind_param failed\n"; echo "error: ", $stmt->error, "\n"; return; } $rc=$stmt->execute(); if (!$rc ) { echo "execute failed\n"; echo "error: ", $stmt->error, "\n"; return; } $rc = $stmt->bind_result($result); if (!$rc ) { echo "bind_result failed\n"; echo "error: ", $stmt->error, "\n"; return; } $rc = $stmt->fetch(); if (!$rc ) { echo "no such record\n"; } else { echo 'result: ', $result, "\n"; } $stmt->close(); } public function init() { $this->db = new mysqli('localhost', 'localonly', 'localonly', 'test'); if ($this->db->connect_error) { die('connection failed: ' . $this->db->connect_error); } $rc = $this->db->query('CREATE TEMPORARY TABLE soTest (id int auto_increment, html varchar(16), page varchar(16),primary key(id))' ); if (!$rc ) { die('error: '.
$this->db->error); } $rc = $this->db->query("INSERT INTO soTest (html,page) VALUES ('htmlFoo','foo'),('htmlCities','cities')"); if (!$rc ) { die('error: '. $this->db->error); } } } Keep CWE-209: Information Exposure Through an Error Message in mind. Printing the actual error message in my example script is only for testing.
And you might use a slightly more sophisticated error handling than just die().
Whoops, that is an error, but not the reason why this does not work. I just fixed it in the live code and it still returns empty. – Mike Aug 24 '10 at 18:39 @Mike for the reason you have to ask your program, not people who have no idea what's going on.
I don't have a PHP interpreter in my head to run your code and see the result. You have to do it yourself. No offence - it's just the only way.
– Col. Shrapnel Aug 24 '10 at 18:42 well the fact that query() works and prepare() does not, despite the fact that they have the same exact data should tell you something. Are those two functions not interchangeable, in the sense of the code I have above.
– Mike Aug 24 '10 at 18:45 @Mike they ARE interchangeable. Just two different ways of passing data to the query. Both just querying a database.
– Col. Shrapnel Aug 24 '10 at 18:48 Thats what I thought, as @a1ex07 said, the key to the prepare() appears to be store_results(); – Mike Aug 24 '10 at 18:50.
It doesn't make sense to prepare the statement if the connection failed). Keep CWE-209: Information Exposure Through an Error Message in mind. Printing the actual error message in my example script is only for testing.
Any of the mysqli_* functions can fail. In this case the return value is false and the error/errno properties of the mysqli or mysqli_stmt object contains more information about the error. The script has to test each and every return value and react appropriately on error condition (e.g. It doesn't make sense to prepare the statement if the connection failed).
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.