FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Access Denied for user ODBC@localhost





coreymanshack
Why is it when I call this function twice, on the second time it says access denied for user ODBC@localhost.
http://pastebin.com/m6fb095c5

It's telling me
http://pastebin.com/m6900f71c

But it has to be defined because I required it!
Marcuzzo
Quote:
Undefined variable: meterid getJSONDataRow1.php on line 26
Undefined variable: dblocation in getJSONDataRow1.php on line 34
Undefined variable: dbuser in getJSONDataRow1.php on line 34
Undefined variable: dbpass in getJSONDataRow1.php on line 34


well, for some reason it doesn't have these 4 variables defined.

Quote:
Why is it when I call this function twice, on the second time it says access denied for user ODBC@localhost.


how/where are these variables stored, defined, whatever...
do you present them via a form? saved as a global variable?
jmraker
The program only needs to connect once, you can either close the connection at the end of the function, open the connection in another function, or test if it's already connected before trying to connect.

If you can't connect, use the sql "GRANT" command, like
GRANT ALL ON *.* TO ODBC@localhost

I'm guessing the 2nd connect fails because require_once only includes the file once and on a 2nd call doesn't do anything because it's only used once.

It's best to move the connect code to the start of the program, like inside the config.php file, and move the require_once to the start of the program before the database is used.
coreymanshack
Yea I figured it out earlier today, my solution checked to see if I required the config.php and if I did, it didn't set it again. I needed to include config.php in the function, so this worked out.
akaichen
coreymanshack wrote:
Why is it when I call this function twice, on the second time it says access denied for user ODBC@localhost.
http://pastebin.com/m6fb095c5

It's telling me
http://pastebin.com/m6900f71c

But it has to be defined because I required it!


i have same problem, who can solve this problem,please show me the way to solve,thanks
coreymanshack
akaichen wrote:
coreymanshack wrote:
Why is it when I call this function twice, on the second time it says access denied for user ODBC@localhost.
http://pastebin.com/m6fb095c5

It's telling me
http://pastebin.com/m6900f71c

But it has to be defined because I required it!


i have same problem, who can solve this problem,please show me the way to solve,thanks


Use this code..
Code:
function config() { static $config; if (!isset($config)) require('../includes/config.php'); return $config; }
$config = config();
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.