RDC Posted May 28, 2007 Share Posted May 28, 2007 Hello, I have just swapped servers and everything is working fine except for one thing. This code is generating errors. <?php session_start(); @ $db = mysql_pconnect("localhost", "username", "password"); mysql_select_db("databasename"); $usernam = $_REQUEST['usernam']; $passwrd = $_REQUEST['passwrd']; $query = "select * from tbllogin where user = '".$usernam."' and pass = '".$passwrd."'"; $result = mysql_query($query); $num_results = mysql_num_rows($result); It is generating the following error when username and password is entered: Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/g/r/sitename/public_html/html/checklogin.php on line 7 Warning: mysql_query() [function.mysql-query]: Access denied for user 'UNKNOWN_USER'@'localhost' (using password: NO) in /home/g/r/sitename/public_html/html/checklogin.php on line 14 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/g/r/sitename/public_html/html/checklogin.php on line 14 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/g/r/sitename/public_html/html/checklogin.php on line 15 I am sure it is something really simple, I can't seem to make any headway on it. Would appreciate some help if anyone can. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/53306-swapping-server-code-problem/ Share on other sites More sharing options...
flappy_warbucks Posted May 28, 2007 Share Posted May 28, 2007 I would have done this: <?php session_start(); @ $db = mysql_pconnect("localhost", "username", "password"); mysql_select_db("databasename",$db); $usernam = $_REQUEST['usernam']; $passwrd = $_REQUEST['passwrd']; $query = "select * from tbllogin where user = '".$usernam."' and pass = '".$passwrd."'"; $result = mysql_query($query); $num_results = mysql_num_rows($result); Quote Link to comment https://forums.phpfreaks.com/topic/53306-swapping-server-code-problem/#findComment-263448 Share on other sites More sharing options...
Wildbug Posted May 28, 2007 Share Posted May 28, 2007 Remove the "@" in the second line of code and see what errors, if any, you get from that. Also consider checking mysql_errno() and mysql_error() after each mysql* function. Quote Link to comment https://forums.phpfreaks.com/topic/53306-swapping-server-code-problem/#findComment-263450 Share on other sites More sharing options...
RDC Posted May 28, 2007 Author Share Posted May 28, 2007 I would have done this: <?php session_start(); @ $db = mysql_pconnect("localhost", "username", "password"); mysql_select_db("databasename",$db); $usernam = $_REQUEST['usernam']; $passwrd = $_REQUEST['passwrd']; $query = "select * from tbllogin where user = '".$usernam."' and pass = '".$passwrd."'"; $result = mysql_query($query); $num_results = mysql_num_rows($result); I tried this and it didn't work. Thank you for the suggestion. I will remove the @ and report back. Quote Link to comment https://forums.phpfreaks.com/topic/53306-swapping-server-code-problem/#findComment-263451 Share on other sites More sharing options...
RDC Posted May 28, 2007 Author Share Posted May 28, 2007 Removing the @ threw up the following: Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for user 'xxxx'@'localhost' (using password: YES) in /home/g/r/sitename/public_html/html/checklogin.php on line 5 Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'UNKNOWN_USER'@'localhost' (using password: NO) in /home/g/r/sitename/public_html/html/checklogin.php on line 7 Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/g/r/sitename/public_html/html/checklogin.php on line 7 Warning: mysql_query() [function.mysql-query]: Access denied for user 'UNKNOWN_USER'@'localhost' (using password: NO) in /home/g/r/sitename/public_html/html/checklogin.php on line 14 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/g/r/sitename/public_html/html/checklogin.php on line 14 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/g/r/sitename/public_html/html/checklogin.php on line 15 Quote Link to comment https://forums.phpfreaks.com/topic/53306-swapping-server-code-problem/#findComment-263456 Share on other sites More sharing options...
MadTechie Posted May 28, 2007 Share Posted May 28, 2007 did you move the database over as well ? are the username and password correct ? what about user name prefixes (if used) was it updated ? Quote Link to comment https://forums.phpfreaks.com/topic/53306-swapping-server-code-problem/#findComment-263467 Share on other sites More sharing options...
RDC Posted May 28, 2007 Author Share Posted May 28, 2007 did you move the database over as well ? are the username and password correct ? what about user name prefixes (if used) was it updated ? Yes. All that is done. Quote Link to comment https://forums.phpfreaks.com/topic/53306-swapping-server-code-problem/#findComment-263487 Share on other sites More sharing options...
AndyB Posted May 28, 2007 Share Posted May 28, 2007 Here's a dumb question. Did you allow that user access privileges to the database? Quote Link to comment https://forums.phpfreaks.com/topic/53306-swapping-server-code-problem/#findComment-263488 Share on other sites More sharing options...
dj-kenpo Posted May 28, 2007 Share Posted May 28, 2007 looks like mysql stuff is off, not php. is the capitalization the same before and now? your previous server may have been more laid back about it due to settings (I've had that situation) but this one might need things to be exact, a capital letter can make all the difference on 2 things that worked previously, but really shouldn't have been working Quote Link to comment https://forums.phpfreaks.com/topic/53306-swapping-server-code-problem/#findComment-263489 Share on other sites More sharing options...
RDC Posted May 28, 2007 Author Share Posted May 28, 2007 I have checked and I cannot see any changes in capitalisation. The user has access privileges too. How annoying. What is the best way to bypass the login as I need this to work? Quote Link to comment https://forums.phpfreaks.com/topic/53306-swapping-server-code-problem/#findComment-263498 Share on other sites More sharing options...
dj-kenpo Posted May 28, 2007 Share Posted May 28, 2007 are your normal connections working? as in, can you make a connection to the database and query for something (anything), it looks like from the error on line7 the login script is not to blame, something is going wrong with the connection, if not capitalization, misspelling, etc then perhaps the new database is not setup yet. are you absolutely sure the new database is on the new server? sometimes it takes a day to fully propagate, but can you log in and view data, etc via phpmyadmin or a similar program? Quote Link to comment https://forums.phpfreaks.com/topic/53306-swapping-server-code-problem/#findComment-263504 Share on other sites More sharing options...
MadTechie Posted May 28, 2007 Share Posted May 28, 2007 server ip set to new server ? Quote Link to comment https://forums.phpfreaks.com/topic/53306-swapping-server-code-problem/#findComment-263519 Share on other sites More sharing options...
chronister Posted May 28, 2007 Share Posted May 28, 2007 My 2 cents Looks like the username or password are incorrect. Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for user 'xxxx'@'localhost' (using password: YES) in /home/g/r/sitename/public_html/html/checklogin.php on line 5 If username or password are not right, then you will not be able to select the db Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'UNKNOWN_USER'@'localhost' (using password: NO) in /home/g/r/sitename/public_html/html/checklogin.php on line 7 My suggestion is to ensure that the database is set up with the same DB name, Username & Password. Try creating a new script in a new page and attempt to make a connection, and select a database. If you can do those items, then try selecting data from the database. If that works, then find what is different. If it don't work, then re-check your host,username,password & permissions. Quote Link to comment https://forums.phpfreaks.com/topic/53306-swapping-server-code-problem/#findComment-263539 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.