TecnobA Posted August 12, 2006 Share Posted August 12, 2006 When i want to store a mysql_query resource id into array i get this error: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 61line 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()); Link to comment https://forums.phpfreaks.com/topic/17300-mysql_query-resource-id-into-array/ Share on other sites More sharing options...
mewhocorrupts Posted August 12, 2006 Share Posted August 12, 2006 I think what you're trying to do is instantiate an object that isn't actually created when you call the connect function. What you're looking for is MySQLI, [url=http://us3.php.net/manual/en/ref.mysqli.php]http://us3.php.net/manual/en/ref.mysqli.php[/url]. Try this out:[code]<?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[1] and $row[2]. MYSQLI_BOTH will give you access to both number// and literal string column references......?>[/code]I think that's what you're looking for. If I just went out on a tangent for no reason, then I apologize. Link to comment https://forums.phpfreaks.com/topic/17300-mysql_query-resource-id-into-array/#findComment-73575 Share on other sites More sharing options...
crazy manzaaa Posted August 12, 2006 Share Posted August 12, 2006 here's my take: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. Link to comment https://forums.phpfreaks.com/topic/17300-mysql_query-resource-id-into-array/#findComment-73599 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.