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
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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.