Jump to content

Some Mysql Warnings


Mikyb92

Recommended Posts

Hi all,

 

I have the following code:  

Class.db.php

<?php
class db{
	
	function __construct(){
		#global $config;
		#mysql_connect($config['db']['88.191.245.223'], $config['db']['sito'], $config['db']['sito123']) or $this->showError(mysql_error());
	}
	
	function showError($error=''){
		die('Error. '.$error);
	}
	
	function escapeString($string){
		#return mysql_real_escape_string($string);
	}
	
	function query($query){
		//echo $query."<br />";
		return mysql_query($query);
	}
	
	function numRows($query){
		return mysql_num_rows($query);
	}
	
	function fetchArray($query){
		return mysql_fetch_array($query);
	}
	
	/*function __destruct(){
		mysql_close();
	}*/
	
	function insert($table, $data){
		$cols=implode(", ", array_keys($data));
		array_walk($data, function(&$value){
			if(!preg_match('/PASSWORD/', $value)){
				$value="'$value'";
			}
		});
		$values=implode(", ", array_values($data));
		$this->query("INSERT INTO $table ($cols) VALUES ($values)");
	}
	
	function select($table, $columns, $attr=''){
		$query=$this->query("SELECT $columns FROM $table $attr");
		if($this->numRows($query)==0){
			return NULL;
		}else{
			while($data=mysql_fetch_array($query)){
				$result[]=$data;
			}
			return $result;
		}
	}
	
}

Config php is:

 


<?php

//error_reporting(0); //hide errors
error_reporting(-1); //show errors


$config=array(
	'name' => 'name',
	'forum' => 'forum',
	'db' => array(
		'host' => 'host',
		'user' => 'user',
		'psw' => 'psw',
		),
	'cache' => array(
		'showCategory' => 7200,
		'charactersRank' => 1800,
		'guildsRank' => 1800,
		'stats' => 120,
		'charactersRankByKills' => 1800,
		),
	'publicPages' => array('playNow', 'serverDescription'),
	'mall' => array(
		'paypalEmail' => 'email',
		'paypalUrl' => 'https://www.paypal.com/cgi-bin/webscr',
		'stonePrice' => 100,
		'bonusPrice' => 100,
		'maxMedi' => 55,
		'minMedi' => -20,
		'maxAbi' => 25,
		'minAbi' => -18,
		'-medi+abi_bonusPrice' => 500,
		'+medi-abi_bonusPrice' => 500,
		),
	'download' => array(
		'Download da Mega' => '#',
		'Download da Google Drive' => '#',
		),
	'ports' => array(
			'Database' => '3306',
			'Channel 1' => '13000',
			'Mark Channel' => '13000',
			'Shared Channel' => '13000',
		),
);

?>

Now if i click on a Button in the website, i get these errors:

 


Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/metinarr/public_html/core/class.db.php on line 23

Warning: Invalid argument supplied for foreach() in /home/metinarr/public_html/index.php on line 39

What i've to do?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/278871-some-mysql-warnings/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.