dominic600 Posted August 16, 2011 Share Posted August 16, 2011 so im transfering all my stuff from one hosting provider to my paid host. and well when i got to login it says 'no database selected' and idk why cause that is not in my login.php.. url for site is www.trucksterusa.com login.php code: <?php require("top.php"); ?> <div id='content'> <hr /> <?php $form = "<form action='login.php' method='post'> <center><table> <tr> <td>Username:</td> <td><input type='text' name='username' class='textbox'></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password' class='textbox'></td> </tr> <tr> <td></td> <td><input type ='submit' name='loginbtn' value='Login' class='button'></td> </tr> </table></center> </form> <hr /> If you are not registed, you can do so<a href='register.php'>HERE</a>"; if ($_POST['loginbtn']){ $username = strip_tags($_POST['username']); $password = strip_tags($_POST['password']); if($username && $password){ require("scripts/connect.php"); $pass = md5(md5($password)); $query = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$pass'") or die(mysql_error()); $numrows = mysql_num_rows($query); if ($numrows == 1){ $row = mysql_fetch_assoc($query); $dbid = $row['id']; $dbuser = $row['username']; $active = $row['active']; if($active == 1){ $date = ("F d, Y"); mysql_query("UPDATE users SET last_login='$date' WHERE id='$dbid'"); $_SESSION['username'] = $dbuser; $_SESSION['userid'] = $dbid; echo "<body onLoad=\"setTimeout('redirect();', 1500);\">"; echo "You are now loged in.<a href='http://tprofiletesting.net23.net'> Click here </a>to return Home."; } else echo "You must activate your account to login."; } else echo "Your Username and/or Password are not valid. <br /><br />If you do not have an account, you can register for one <a href='register.php'>here</a>."; } else echo "You did not fill in the correct fields."; } else echo "$form"; ?> <hr /> </div> <div id='footer'></div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/ Share on other sites More sharing options...
gizmola Posted August 16, 2011 Share Posted August 16, 2011 It is possible that on your old host a default database was configured so your code did not need to issue a mysql_select_db(). Take a look at the scripts/connect.php script, which looks like it has the mysql database configuration code. Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1257946 Share on other sites More sharing options...
dominic600 Posted August 16, 2011 Author Share Posted August 16, 2011 oh ok i looked at it and changed all the info from my old server to my new one. but when i import the .sql files is there something the old host could have inserted into them that could be messing this up? Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1257947 Share on other sites More sharing options...
phpSensei Posted August 16, 2011 Share Posted August 16, 2011 The error is simple 'no database selected', your selecting either a non-existant database name or you havn't called the mysql_select_db Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1257966 Share on other sites More sharing options...
chintansshah Posted August 16, 2011 Share Posted August 16, 2011 I think, you should change hostdetails, check your site configuration file and change mysql_connect with new server details. Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1257992 Share on other sites More sharing options...
dominic600 Posted August 16, 2011 Author Share Posted August 16, 2011 i changed all the host details cause at first i was getting errors saying i didnt have permession and all that stuff so when i got everything how it should be in my connect.php then the errors go away and i get that database error Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1258217 Share on other sites More sharing options...
PFMaBiSmAd Posted August 16, 2011 Share Posted August 16, 2011 The error message is coming form the mysql_error() statement when your query fails and it means what it says. You have not (successfully) selected a database. Most likely, as someone already posted, your mysql_select_db statement is failing. What does adding the following two lines of code immediately after your first opening <?php tag show - ini_set("display_errors", "1"); error_reporting(-1); Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1258228 Share on other sites More sharing options...
dominic600 Posted August 16, 2011 Author Share Posted August 16, 2011 it does not show anythign different.but i think what my problem is, in my connect.php is for teh server name i have localhost.. so i have to find the server ip or name for it so maybe it would work. Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1258300 Share on other sites More sharing options...
phpSensei Posted August 16, 2011 Share Posted August 16, 2011 Thats where the problem lies, I know 99% of hosts always give you a specific host to connect to, just like your last host 000webhost Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1258302 Share on other sites More sharing options...
jcbones Posted August 16, 2011 Share Posted August 16, 2011 Does your host have a database prefix, and did you include it in your database connection? Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1258311 Share on other sites More sharing options...
dominic600 Posted August 16, 2011 Author Share Posted August 16, 2011 Thats where the problem lies, I know 99% of hosts always give you a specific host to connect to, just like your last host 000webhost yeah I know. but the problem is i cant find it or anywhere cause where it says "server: Localhost via UNIX socket" and in the 000webhost it had a url for the server. Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1258312 Share on other sites More sharing options...
phpSensei Posted August 16, 2011 Share Posted August 16, 2011 You need to specify the socket in the hostname, find out what the path is to the socket. The MySQL server. It can also include a port number. e.g. "hostname:port" or a path to a local socket e.g. ":/path/to/socket" for the localhost. If the PHP directive mysql.default_host is undefined (default), then the default value is 'localhost:3306'. In SQL safe mode, this parameter is ignored and value 'localhost:3306' is always used. Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1258318 Share on other sites More sharing options...
darkfreaks Posted August 16, 2011 Share Posted August 16, 2011 change localhost to mysql5.000webhost.com Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1258320 Share on other sites More sharing options...
phpSensei Posted August 16, 2011 Share Posted August 16, 2011 change localhost to mysql5.000webhost.com He isn't using 000webhost anymore. Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1258322 Share on other sites More sharing options...
darkfreaks Posted August 17, 2011 Share Posted August 17, 2011 according to host24.com he needs to login to cpanel and use his IP adress as the MYSQL hostname. the IP can be found in the left hand column when you login. Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1258326 Share on other sites More sharing options...
dominic600 Posted August 17, 2011 Author Share Posted August 17, 2011 okay so i used my ip and it worked i guess.. now im getting errors on time setting and its saying my pasword is wrong so im going to try another password Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1258335 Share on other sites More sharing options...
dominic600 Posted August 17, 2011 Author Share Posted August 17, 2011 heres the errors im getting.. and plus my ip for my server did not work. Strict Standards: mysql_connect() [function.mysql-connect]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /home/truckste/public_html/scripts/connect.php on line 8 Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on '97.92.195.84' (4) in /home/truckste/public_html/scripts/connect.php on line 8 Strict Standards: mysql_select_db() [function.mysql-select-db]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /home/truckste/public_html/scripts/connect.php on line 9 Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'truckste'@'localhost' (using password: NO) in /home/truckste/public_html/scripts/connect.php on line 9 Strict Standards: mysql_select_db() [function.mysql-select-db]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /home/truckste/public_html/scripts/connect.php on line 9 Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/truckste/public_html/scripts/connect.php on line 9 Strict Standards: mysql_query() [function.mysql-query]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /home/truckste/public_html/login.php on line 35 Warning: mysql_query() [function.mysql-query]: Access denied for user 'truckste'@'localhost' (using password: NO) in /home/truckste/public_html/login.php on line 35 Strict Standards: mysql_query() [function.mysql-query]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /home/truckste/public_html/login.php on line 35 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/truckste/public_html/login.php on line 35 Access denied for user 'truckste'@'localhost' (using password: NO) Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1258337 Share on other sites More sharing options...
PFMaBiSmAd Posted August 17, 2011 Share Posted August 17, 2011 Can't connect to MySQL server on '97.92.195.84' Nope, it didn't work. Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1258341 Share on other sites More sharing options...
dominic600 Posted August 17, 2011 Author Share Posted August 17, 2011 well shoot. I do not know what to try now.. Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1258344 Share on other sites More sharing options...
xyph Posted August 17, 2011 Share Posted August 17, 2011 Ask your host? Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1258346 Share on other sites More sharing options...
darkfreaks Posted August 17, 2011 Share Posted August 17, 2011 I get 'access denied' errors when trying to connect to MySQL If you cannot connect- Incorrect MySQL username / password or database name. to the MySQL server, this might happen due to several reasons: - Incorrect MySQL hostname. The MySQL hostname on most of our servers is localhost (with the exception on few reseller servers). You can always double check this information in your Members area -> List accounts -> Account details. - Incorrect MySQL username / password or database name. Please navigate to cPanel -> MySQL to check this information. If you cannot remember what password is set on the MySQL user, feel free to delete it and recreate it one more time. - You have not added the MySQL user to the database. This is a very common issue that people forget to do. In order to have a fully operational MySQL database you must also add a MySQL user to the MySQL database and assign full permissions. You can achieve this by clicking on the 'Add' button under 'cPanel' -> 'MySQL Databases' -> 'Add User To Database' section. Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1258358 Share on other sites More sharing options...
dominic600 Posted August 17, 2011 Author Share Posted August 17, 2011 yeah so i got it fixed, turns out when i created a user i didnt set permessions and did not save it.. lol but thanks for all the help! Quote Link to comment https://forums.phpfreaks.com/topic/244884-website-is-showing-stuff-thats-not-in-the-php/#findComment-1258419 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.