ninjacoder
ninjacoder

Reputation: 1484

mysql_real_escape string errors

I'm trying to set up a codeigniter web app I just recently finished on a server. I wrote it locally on my own computer. However when I try to login I get these two errors.

A PHP Error was encountered

Severity: Warning

Message: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO)

Filename: mysql/mysql_driver.php

Line Number: 319



A PHP Error was encountered

Severity: Warning

Message: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established

Filename: mysql/mysql_driver.php

Line Number: 319

Anyone know what the problem is?

Upvotes: 0

Views: 5239

Answers (4)

ninjacoder
ninjacoder

Reputation: 1484

I finally found what was causing the problem. It was this line in the database config folder:

$db['mydb']['autoinit'] = FALSE;

When I changed it to :

$db['mydb']['autoinit'] = TRUE;

It worked! Thanks guys for all your advice, wouldn't have done it without you!

Upvotes: 2

Grumpy
Grumpy

Reputation: 2243

First make sure you are connect to your db

you can modify the settings in application/config/database.php

for codeigniter you should use

$this->db->escape() 

Details and samples can be found here http://ellislab.com/codeigniter/user-guide/database/queries.html

Upvotes: 4

bipen
bipen

Reputation: 36531

check your db settings inside..

application>config>database.php

Upvotes: 0

Sébastien Renauld
Sébastien Renauld

Reputation: 19662

The answer is simple: mysql_real_escape_string() (the hint is in the name) escapes a string based on the receiving character set used by the DB connection. In order to use this, you first need to be connected to a MySQL server!

Auto-load the DB class and have it auto-connect. It'll solve your problem.

Upvotes: 1

Related Questions