Jump to content

[SOLVED] include() and function..


clown[NOR]

Recommended Posts

i have been fighting this problem for a while now, but with no luck.. i just cant see why it wont work... it might be the function... it's the first time i'm working with it... so..

 

this is the error message i get:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in F:\root\oleaa.com\index.php on line 21

Unable to connect to DB

 

this is the code:

<?php
include('config/db.php');
function freshNews() {

	if (!mysql_connect($dbHost, $dbUser, $dbPass)) { die("Unable to connect to DB"); } //This is line 21
	if (!mysql_select_db($dbName)) { die("Unable to select DB"); }

	$query = "SELECT * FROM news";
	$result = mysql_query($query);

	if (!$result) { die("Could not run query from DB"); }

	$dbNumRows = mysql_num_rows($result);

	if ($dbNumRows > 0) {
		echo $dbNumRows . " news found.";
	} else { echo "No news found."; }


}

 

 

Thanks In Advance

- Clown

Link to comment
https://forums.phpfreaks.com/topic/46906-solved-include-and-function/
Share on other sites

hehe... oh well... i tried to add it as include_once() outside the function ... didnt work.. if that's what you ment tho... oh well.. it's jsut the db.php... so it's ok... but if anyone have an solution for this.. please let me know...

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.