mysql_query resource id into array
Posted 12 August 2006 - 12:30 AM
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /var/www/localhost/htdocs/projekti/blog/libaries/Mysql.class.php on line 61
line 61: $this->query[$field] = mysql_query($query, $this->link) or die( "<b>MySQL error:</b> ".mysql_error());
But if i don't store a resource id into array, everything is ok. Why?
No error: $this->query = mysql_query($query, $this->link) or die( "<b>MySQL error:</b> ".mysql_error());
Posted 12 August 2006 - 05:33 AM
<?php ..... $db = new mysqli("SERVER","DB","PASS","TABLE"); $res = $db->query($sql_query_string); $row = mysqli_fetch_array($res, MYSQLI_ASSOC); $col1 = $row['col1']; $col2 = $row['col2']; // And so on and so forth. You can also MYSQLI_NUM if you want to reference like // $row and $row. MYSQLI_BOTH will give you access to both number // and literal string column references. ..... ?>
I think that's what you're looking for. If I just went out on a tangent for no reason, then I apologize.
Posted 12 August 2006 - 06:48 AM
by using $this->query[$field], you already specify the array's 'key' (=$field). However, the mysql_query(...) returns a result (which is also an array) that has its own 'key' . So, you don't need to specify the key.
I don't know if this will work or not. Try to use $this->query instead. If that doesn't work, nevermind. You already get an array anyway.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users