thinakaran Posted August 14, 2007 Share Posted August 14, 2007 i am using php 4.4.7 and mysql 5 in a suse 10.2 mechine. i am having error while running a php script. " warning mysql_data_seek() supplied argument is not valid MYSQL on line 494" "warning mysql_fetch_assoc() supplied argument is not valid MYSQL on line 498" this is the part of my script: if($this->dbType == "mysql"){ if($this->getRowCount($result) > $rowNum){ mysql_data_seek($result, $rowNum);--------------line 494 } $this->lastmysqlrow = $rowNum; $row = mysql_fetch_assoc($result); if($encode && $this->encode && is_array($row))return array_map('to_html', $row); return $row; anyone please help me. Quote Link to comment https://forums.phpfreaks.com/topic/64797-php-not-supporting-mysql-query/ Share on other sites More sharing options...
NArc0t1c Posted August 14, 2007 Share Posted August 14, 2007 A bit more of the script please, maybe the whole class. Quote Link to comment https://forums.phpfreaks.com/topic/64797-php-not-supporting-mysql-query/#findComment-323236 Share on other sites More sharing options...
btherl Posted August 14, 2007 Share Posted August 14, 2007 It's saying that $result is not a mysql result. Check back through your code to where $result comes from. You may need to test it after calling mysql_query(), as the query may have failed. Quote Link to comment https://forums.phpfreaks.com/topic/64797-php-not-supporting-mysql-query/#findComment-323245 Share on other sites More sharing options...
thinakaran Posted August 14, 2007 Author Share Posted August 14, 2007 this is my class function fetchByAssoc(&$result, $rowNum = -1, $encode=true){ if(isset($result) && $result && $rowNum < 0){ if($this->dbType == "mysql"){ $row = mysql_fetch_assoc($result); if($encode && $this->encode&& is_array($row))return array_map('to_html', $row); return $row; } else if ($this->dbType == 'oci8') { } return $row; //$row = $result->fetchRow(DB_FETCHMODE_ASSOC); } if($this->dbType == "mysql"){ if($this->getRowCount($result) > $rowNum){ mysql_data_seek($result, $rowNum); } $this->lastmysqlrow = $rowNum; $row = mysql_fetch_assoc($result); if($encode && $this->encode && is_array($row))return array_map('to_html', $row); return $row; } else if($this->dbType == "oci8"){ Quote Link to comment https://forums.phpfreaks.com/topic/64797-php-not-supporting-mysql-query/#findComment-323260 Share on other sites More sharing options...
btherl Posted August 14, 2007 Share Posted August 14, 2007 Before fetching data from a result with mysql_fetch_assoc(), you must first do a query with mysql_query(). Otherwise you will get the error in your original post. Quote Link to comment https://forums.phpfreaks.com/topic/64797-php-not-supporting-mysql-query/#findComment-323265 Share on other sites More sharing options...
thinakaran Posted August 14, 2007 Author Share Posted August 14, 2007 i am very new to php and mysql, can you please tel me how to do a query with mysql_query() before mysql_fetch_assoc() Quote Link to comment https://forums.phpfreaks.com/topic/64797-php-not-supporting-mysql-query/#findComment-323294 Share on other sites More sharing options...
PhaZZed Posted August 14, 2007 Share Posted August 14, 2007 $sql = @mysql_query("SELECT id, name FROM table WHERE..."); while ($row = mysql_fetch_assoc($sql)) { echo $row['name']; } That is the simple format using mysql_query and mysql_fetch_assoc Quote Link to comment https://forums.phpfreaks.com/topic/64797-php-not-supporting-mysql-query/#findComment-323313 Share on other sites More sharing options...
thinakaran Posted August 14, 2007 Author Share Posted August 14, 2007 A bit more of the script please, maybe the whole class. this is my class function fetchByAssoc(&$result, $rowNum = -1, $encode=true){ if(isset($result) && $result && $rowNum < 0){ if($this->dbType == "mysql"){ $row = mysql_fetch_assoc($result); if($encode && $this->encode&& is_array($row))return array_map('to_html', $row); return $row; } else if ($this->dbType == 'oci8') { } return $row; //$row = $result->fetchRow(DB_FETCHMODE_ASSOC); } if($this->dbType == "mysql"){ if($this->getRowCount($result) > $rowNum){ mysql_data_seek($result, $rowNum); } $this->lastmysqlrow = $rowNum; $row = mysql_fetch_assoc($result); if($encode && $this->encode && is_array($row))return array_map('to_html', $row); return $row; } else if($this->dbType == "oci8"){ Quote Link to comment https://forums.phpfreaks.com/topic/64797-php-not-supporting-mysql-query/#findComment-323328 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.