MySQL Connect Error

  • yomi
  • Graduate
  • Graduate
  • User avatar
  • Posts: 116
  • Loc: Nigeria

Post 3+ Months Ago

Error connecting to databasePHP Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in C:\Inetpub\wwwroot\hr\idea_dcsn.php on line 127

i seem to have correctly fulfilled my part in correctly putting variables. my code works fine testing remotely but on the server, its bonkers. on my local machine i use EASYPHP(php, apache,mysql) but on the server, i am using iis,mysql,php.

please help!!!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • neksus
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 2194
  • Loc: Canada

Post 3+ Months Ago

Are you sure you've
  • Correctly inserted the right variables to your connect statement
  • Are using the right user name - some put the account before (ex account_user)
  • Given privileges to the user in question

If you're not using a password, I highly recommend one.
  • yomi
  • Graduate
  • Graduate
  • User avatar
  • Posts: 116
  • Loc: Nigeria

Post 3+ Months Ago

neksus wrote:
Are you sure you've
  • Correctly inserted the right variables to your connect statement
  • Are using the right user name - some put the account before (ex account_user)
  • Given privileges to the user in question

If you're not using a password, I highly recommend one.

thanks, i forgot to put the right password on my pages, done that yesterday but today, i have this challenge

ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near '' at line

i had to enter the cmd env to test my query cos my php pages were just working like links. i know my php is ok cos i call pages with functions. i can select from my db tables but cant update or insert.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Your user should be changed accordingly. If you are still using 'localhost' change it to the real host, unless you are using something and need to change your host to localhost. Also, make sure your user is correct. On default settings, the user is mainly "root" but it could be changed, so make sure you got the right user as well.
  • cjxxi
  • Expert
  • Expert
  • cjxxi
  • Posts: 565
  • Loc: Fort Worth, TX

Post 3+ Months Ago

Error connecting to databasePHP Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in C:\Inetpub\wwwroot\hr\idea_dcsn.php on line 127

that error looks like the user is there but the table doesnt havet permission for that user.



ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near '' at line

and this one looks like a sintax error in your query
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

than the password is incorrect I assume
  • cjxxi
  • Expert
  • Expert
  • cjxxi
  • Posts: 565
  • Loc: Fort Worth, TX

Post 3+ Months Ago

Bogey wrote:
than the password is incorrect I assume

no, you just need to assign the right privileges to that user. has nothing todo with the password, although onces you have assigned right permission to the user, you can also reset the password, and that seems to fix this kind of conflicts
  • cjxxi
  • Expert
  • Expert
  • cjxxi
  • Posts: 565
  • Loc: Fort Worth, TX

Post 3+ Months Ago

yomi wrote:
neksus wrote:
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near '' at line


also, at the time you get this error, it seems that the user is already connected to the database. so it starts being a minor sintax error and not a database wide problem.
  • neksus
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 2194
  • Loc: Canada

Post 3+ Months Ago

I didn't say that :P lol
  • cjxxi
  • Expert
  • Expert
  • cjxxi
  • Posts: 565
  • Loc: Fort Worth, TX

Post 3+ Months Ago

neksus wrote:
I didn't say that :P lol


you didn't say what now? :( I am a bit confused :lol:
  • neksus
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 2194
  • Loc: Canada

Post 3+ Months Ago

What you quoted me as saying lol
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

cjxxi wrote:
Error connecting to databasePHP Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in C:\Inetpub\wwwroot\hr\idea_dcsn.php on line 127

that error looks like the user is there but the table doesnt havet permission for that user.



ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near '' at line


and this one looks like a sintax error in your query


cjxxi said that not neksus
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

cjxxi wrote:
Bogey wrote:
than the password is incorrect I assume

no, you just need to assign the right privileges to that user. has nothing todo with the password, although onces you have assigned right permission to the user, you can also reset the password, and that seems to fix this kind of conflicts

Quote:
Error connecting to databasePHP Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in C:\Inetpub\wwwroot\hr\idea_dcsn.php on line 127

So, there is no password for the user?
  • cjxxi
  • Expert
  • Expert
  • cjxxi
  • Posts: 565
  • Loc: Fort Worth, TX

Post 3+ Months Ago

Bogey wrote:
So, there is no password for the user?


regardless of weather there is a password or not or even if is correct or not, that specific user must have permissions to access that table. usually if it is root, will have that special permission by default. otherwise it needs to be set manually.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

If there is no password, than that user can't even log in can it? A permissionless user should be able to log in to MySQL database but wouldn't be able to do anything.

The way I see it is if you are a user registered to a forum, but you will never NEVER NEVER see a warning saying you can't access anything as a user if you have forgotten the password.

That's the way I see it though... :lol:
  • neksus
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 2194
  • Loc: Canada

Post 3+ Months Ago

A permissionless user can not log into a database if they haven't been assigned to the database, can they?
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

But what about the syntax error ?
  • cjxxi
  • Expert
  • Expert
  • cjxxi
  • Posts: 565
  • Loc: Fort Worth, TX

Post 3+ Months Ago

neksus wrote:
A permissionless user can not log into a database if they haven't been assigned to the database, can they?



Code: [ Select ]
$answer = ($MAYBE)? YES:NO;

http://www.google.com/search?hl=en&q=pe ... tnG=Search
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

GOD! :lol: I'll find out and give a definite answer to this...

ok... I added a user with 0 permission without assigning a database for it. It came with the following error...
Quote:
Access denied for user 'bogey'@'localhost' (using password: YES)

So yea... :lol: I was wrong but it is good to learn :)

Check your permissions AND check your passwords and check if you need to set one up for the user.
  • neksus
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 2194
  • Loc: Canada

Post 3+ Months Ago

lol
Thanks for clearing up cjxxi's smart ass remark :P
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

:lol: No problem
  • cjxxi
  • Expert
  • Expert
  • cjxxi
  • Posts: 565
  • Loc: Fort Worth, TX

Post 3+ Months Ago

Quote:
Access denied for user 'bogey'@'localhost' (using password: YES)


and means your password is wrong
  • cjxxi
  • Expert
  • Expert
  • cjxxi
  • Posts: 565
  • Loc: Fort Worth, TX

Post 3+ Months Ago

neksus wrote:
lol
Thanks for clearing up cjxxi's smart ass remark :P


Opps I apologyze i didn't mean to be smart ass, it just made more sence to do a search for that question
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

cjxxi wrote:
Quote:
Access denied for user 'bogey'@'localhost' (using password: YES)


and means your password is wrong

That could mean that yes, but I put in the password like the second after I made the permissionless user. I'm sure I put the password in correclty 100%
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Quote:
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near '' at line

i had to enter the cmd env to test my query cos my php pages were just working like links. i know my php is ok cos i call pages with functions. i can select from my db tables but cant update or insert.


Where did you get the queries you tested via command line ?

That error looks to me like PHP is botching something before sending the query to the MySQL server.

What do you get if you echo/print the queries before calling mysql_query or equivalent ?

For instance,
Code: [ Select ]
$sql = $stuff . ' WHERE ' . $other_stuff;
echo $sql;
mysql_query($sql);
  1. $sql = $stuff . ' WHERE ' . $other_stuff;
  2. echo $sql;
  3. mysql_query($sql);
  • yomi
  • Graduate
  • Graduate
  • User avatar
  • Posts: 116
  • Loc: Nigeria

Post 3+ Months Ago

guys........

im using php with mysql, my connection seems fine cos i can connect to and select the database. my die error comes at the stage of inserting or updating my database. someone suggests i recheck mysql configuration. i dint do any configuration , just followed the wizard and i saw the black cmd screen, used and selected the db. i got a documentation on the config so let me just look thru it and get back to y'all.

Meanwhile, does anyone know why my GETHOSTBYNAME() would not work? i am using the server ip but cant capture the usernames on the network?

See y'all in a bit.
  • yomi
  • Graduate
  • Graduate
  • User avatar
  • Posts: 116
  • Loc: Nigeria

Post 3+ Months Ago

sorry dint read the second page. erm..... joebert, i first of all copied out my code from my page, dint work then checked documentation and used the same syntax.
If i echo a string, it shows, if i echo the sql, it shows but i noticed that my values are not enclosed in 'quotes'. it just echoes them as csv.

brb!
  • yomi
  • Graduate
  • Graduate
  • User avatar
  • Posts: 116
  • Loc: Nigeria

Post 3+ Months Ago

all parameters are correctly set.

guess i have to keep troubleshooting.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

I'd like to see what you're using.
  • yomi
  • Graduate
  • Graduate
  • User avatar
  • Posts: 116
  • Loc: Nigeria

Post 3+ Months Ago

see what i'm using? as in mysql code?

$dbconx = mysql_connect('localhost','root','') or die('Error connecting to database');
mysql_select_db('cia_db',$dbconx) or die('Error selecting database');
$sql = "INSERT idea set agent='$user', presntn='$presntn', comment='$comment', detail='$detail',topic='$topic',outcome='$outcome' ";
//echo $sql;
mysql_query($sql,$dbconx) or die(' Error executing query');
mysql_close();
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 34 posts
  • Users browsing this forum: No registered users and 105 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.