mysql_query() expects parameter 2 to be resource

Discutii despre script-uri si coduri PHP-MySQL, precum si lucru cu XML in PHP.
Viruzzz
Mesaje:18

mysql_query() expects parameter 2 to be resource

Salut,
config

Cod: Selectaţi tot

<?php
/*
 * Database Connections
 */
$db_website = mysql_connect('localhost', 'root', 'pass', true) or die(mysql_error());
$db_server = mysql_connect('localhost', 'roor', 'pass', true) or die(mysql_error());

mysql_select_db('website', $db_website) or die(mysql_error());
mysql_select_db('server', $db_server) or die(mysql_error());
?>
function

Cod: Selectaţi tot

function getSettings()
{
	$result = mysql_query("SELECT * FROM `settings`", $db_website); // Linia 7
	while ($myrow = mysql_fetch_array($result)) // Linia 8
	{
		global $contact_email, $ntfm, $title, $keywords, $description, $copyright, $url, $theme, $atheme;
		
		$contact_email = $myrow['contact_email'];
		$ntfm = $myrow['ntfm'];
		$title = $myrow['title'];
		$keywords = $myrow['keywords'];
		$description = $myrow['description'];
		$copyright = $myrow['copyright'];
		$url = $myrow['url'];
		$theme = $myrow['theme'];
		$atheme = $myrow['atheme'];				
	}
}
Pe site imi arata urmatoarele erori:

Cod: Selectaţi tot

Warning: mysql_query() expects parameter 2 to be resource, string given in E:\webpages\includes\functions.php on line 7
si

Cod: Selectaţi tot

Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in E:\webpages\includes\functions.php on line 8
Cum pot sa le rezolv?

MarPlo Mesaje:4343
Salut
Functia mysql_query() e deprecata /anulata in PHP 5.5; recomandarea lor e sa se foloseasca MySQLi sau PDO.
Ca incercare de rezolvare pe codul tau, al doilea paramertru pentru mysql_query(), $db_website , nu e adaugat in functie, incearca asa:

Cod: Selectaţi tot

function getSettings() {
   global $db_website, $contact_email, $ntfm, $title, $keywords, $description, $copyright, $url, $theme, $atheme;
   $result = mysql_query("SELECT * FROM `settings`", $db_website); // Linia 7
   while ($myrow = mysql_fetch_array($result)) {  
      $contact_email = $myrow['contact_email'];
      $ntfm = $myrow['ntfm'];
      $title = $myrow['title'];
      $keywords = $myrow['keywords'];
      $description = $myrow['description'];
      $copyright = $myrow['copyright'];
      $url = $myrow['url'];
      $theme = $myrow['theme'];
      $atheme = $myrow['atheme'];            
   }
}
 

Subiecte similare