Jump to content

Recommended Posts

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>

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.

 

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

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);

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.

 

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.

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)

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.