Hi everyone,
Anyone cold you help me?
I get this error in this PHP script;🙁
"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in home/htdocs/users/username/username/mydomain/directory/function/mysql.php on line 41
<?php
class DB_Sql {
var $Connect = false;
var $ReValue = false;
var $ReSelect = false;
var $Host;
var $Database;
var $User;
var $Password;
var $Value;
var $numrow = false;
function DB_Sql($host,$user,$pass,$dbname) {
$this->Host = $host;
$this->User = $user;
$this->Password = $pass;
$this->Database = $dbname;
}
function DBconnect() {
if (!$this->Connect) {
$this->Connect = @mysql_connect($this->Host, $this->User, $this->Password);
$this->ReSelect = @mysql_select_db($this->Database, $this->Connect);
}
}
function query($sql) {
$this->free();
$this->DBconnect();
if ($this->ReValue = mysql_query($sql, $this->Connect)) {
$this->numrow = @mysql_num_rows($this->ReValue);
}
}
function nrecord() {
$this->Value = mysql_fetch_array($this->ReValue);
return $this->Value;
}
function datadump ($table) {
$result .= "# Dump of $table table \n";
$result .= "# Created by CODELIB LINKER \n";
$result .= "# Dump DATE : " . date("Y-m-d") ."\n\n";
$this->query("select * from $table");
$num_fields = @mysql_num_fields($this->ReValue);
$numrow = $this->numrow;
for ($i =0; $i<$numrow; $i++) {
//if (!mysql_data_seek ($this->ReValue, $i)) continue;
if (!($row = $this->nrecord())) continue;
$result .= "INSERT INTO ".$table." VALUES(";
for($j=0; $j<$num_fields; $j++) {
$row[$j] = addslashes($row[$j]);
if (isset($row[$j])) $result .= "\"$row[$j]\"" ; else $result .= "\"\"";
if ($j<($num_fields-1)) $result .= ",";
}
$result .= ");\n";
}
return $result."\n\n\n";
}
function free() {
if ($this->ReValue) {
@mysql_free_result($this->ReValue);
$this->ReValue = false;
$this->numrow = false;
}
}
}
?>
Thanks a lot,
James.