Jump to content

Where to find phpmyadmin details(server, user, database, etc....)


dominic600

Recommended Posts

Okay, so im setting up my "connect.php" file. When i go to test my sites registration form and hit submit it takes me to this page of errors saying it cant connect to "localhost" and thats just what im using as the server since thats what i tthought it would be..

 

but i have the database name, username, and password, but i just cant seem to find the server name. im using phpMyAdmin on a freehosing server right now, so its not being hosted on my own person machine.

Link to comment
Share on other sites

The error should say more than "can't connect to 'localhost'".  What is the full error (copy/paste).  Most of the time database's do reside on localhost (the same web server as the site). The most common cause of this, is that you got the username, password, or database name incorrect.

 

There are some services that have remote hosting, GoDaddy uses it I know.  But, that should have been in the documentation when you set up the database.

Link to comment
Share on other sites

not that you say that i think i do have the user and or password wrong. im going to go make a new user on there and try all new dbuser and password.

 

Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /home/a3888506/public_html/scripts/connect.php on line 8

 

 

Link to comment
Share on other sites

This error is usually overcome by using 'localhost' instead of the IP. 

 

This is because the IP address of your host is set to /deny in the .htaccess file that resides in etc/

 

You may need to change the bind-address var from 127.0.0.1 to your desired hostname(/etc/mysql/my.cnf)

Link to comment
Share on other sites

I got it working :D haha

 

but now everything works but i get a warning:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/a3888506/public_html/register.php on line 96

 

and line 96 reads:

$numrows = mysql_num_rows($query);

Link to comment
Share on other sites

This is an error that arises from an invalid query.  As invalid queries does not return a resource that can be used in mysql_num_rows().

 

Does your database have tables?  Do the table names match your script? 

 

Post your script, and I will add some de-bugging info in it to help you. (take out your DB connection details).

Link to comment
Share on other sites

Sorry, i thought you ment that one.. here the actuall one

 

<?php require("styles/top.php"); ?>
<div id='content'>
<div id='full'>

<?php

$form = "<form action='register.php' method='post'>
<table>
	<tr>
	<td></td>
	<td>Fields indicating <font color='red'>*</font> are require.</td>
</tr>
<tr>
	<td>First Name:</td>
	<td><input type='text' name='firstname'><font color='red'>*</font></td>
</tr>

	<tr>
	<td>Last Name:</td>
	<td><input type='text' name='lastname'><font color='red'>*</font></td>
</tr>

	<tr>
	<td>Username:</td>
	<td><input type='text' name='username'><font color='red'>*</font></td>
</tr>

	<tr>
	<td>E-mail:</td>
	<td><input type='text' name='email'><font color='red'>*</font></td>
</tr>

	<tr>
	<td>Password:</td>
	<td><input type='password' name='password'><font color='red'>*</font></td>
</tr>

	<tr>
	<td>Confirm Password:</td>
	<td><input type='password' name='repassword'><font color='red'>*</font></td>
</tr>

	<tr>
	<td>Avatar:</td>
	<td><input type='file' name='avatar'></td>
</tr>

	<tr>
	<td>Website:</td>
	<td><input type='text' name='website'></td>
</tr>

	<tr>
	<td>Youtube User Name:</td>
	<td><input type='text' name='youtube'></td>
</tr>

	<tr>
	<td>Bio:</td>
	<td><textarea name='bio' cols='35' rows='5'></textarea></td>
</tr>

	<tr>
	<td></td>
	<td><input type='submit' name='submitbtn' value='Register'></td>
</tr>
</table>

</form>";

if ($_POST['submitbtn']){


$firstname = strip_tags($_POST['firstname']);
$lastname = strip_tags($_POST['lastname']);
$username = strip_tags($_POST['username']);
$email = strip_tags($_POST['email']);
$password = strip_tags($_POST['password']);
$repassword = strip_tags($_POST['repassword']);
$website = strip_tags($_POST['website']);
$youtube = strip_tags($_POST['youtube']);
$bio = strip_tags($_POST['bio']);

$name = $_FILES['avatar'] ['name'];
$type = $_FILES['avatar'] ['type'];
$size = $_FILES['avatar'] ['size'];
$tmpname = $_FILES['avatar']['tmpname'];
$ext = substr($name, strrpos($name, '.'));

if ($firstname && $lastname && $username && $email && $password && $repassword){
	if ($password == $repassword){
		if (strstr($email, "@") && strstr($email, ".") && strlen($email) >= 6){

			require("scripts/connect.php");
			$query = mysql_query("SELECT * FROM users WHERE username='$username'");
			$numrows = mysql_num_rows($query);
			if ($numrows == 0){

				$query = mysql_query("SELECT * FROM users WHERE email='$email'");
				$numrows = mysql_num_rows($query);
				if ($numrows == 0){

				$pass = md5(md5($password));
				$date = date("F d, Y");

				if($name){
					move_uploaded_file($tmpname, "avatars/$username.$ext");
					$avatar = "$username.$ext";
				}
				else
					$avatar = "default_avatar.png";

				$code = substr (md5(rand(11111111111, 999999999999999)), 2,  25);

				mysql_query("INSERT INTO users VALUES ('', '$firstname', '$lastname', '$username', '$email', 'pass', '$avatar', '$bio', '$website', '$youtube', '', '0', '$code', '0', '$date')");

						$webmaster = "Admin@trucksite.com";
						$subject = "Activate Your Account!";
						$headers = "From: Admin <$webmaster>";
						$message = "Hello $firstname.\n\nWelcome to trucksite below is a link for you to activate your account!.\n http://tprofiletesting.net23.net/activate.php?code=$code";

						mail($email, $subject, $message, $headers);
						echo "Your activation email has been sent to <b>$email</b>.";
				}
				else
					echo "That email is currently in use.";

			}
			else
				echo "That username is currently in use.";
		}
		else
			echo "You did not enter a vaild email.";
	}
	else
		echo "Your passwords did not match.";
}
else
	echo"You did not fill in all the required fields.";
}
echo "$form";


?>
</div>
<div id='footer'><a href='#'>Link</a><a href='#'>Link</a><a href='#'>Link</a><a href='#'>Link</a><a href='#'>Link</a><a href='#'>Link</a></div>




<body>
</body>
</html>

Link to comment
Share on other sites

<?php //de-bugging remove this after script works as desired>
error_reporting(E_ALL);
ini_set("display_errors", 1); 
//end de-bugging//
require("styles/top.php");
?>

<div id='content'>
<div id='full'>

<?php

$form = "<form action='register.php' method='post'>
<table>
	<tr>
	<td></td>
	<td>Fields indicating <font color='red'>*</font> are require.</td>
</tr>
<tr>
	<td>First Name:</td>
	<td><input type='text' name='firstname'><font color='red'>*</font></td>
</tr>

	<tr>
	<td>Last Name:</td>
	<td><input type='text' name='lastname'><font color='red'>*</font></td>
</tr>

	<tr>
	<td>Username:</td>
	<td><input type='text' name='username'><font color='red'>*</font></td>
</tr>

	<tr>
	<td>E-mail:</td>
	<td><input type='text' name='email'><font color='red'>*</font></td>
</tr>

	<tr>
	<td>Password:</td>
	<td><input type='password' name='password'><font color='red'>*</font></td>
</tr>

	<tr>
	<td>Confirm Password:</td>
	<td><input type='password' name='repassword'><font color='red'>*</font></td>
</tr>

	<tr>
	<td>Avatar:</td>
	<td><input type='file' name='avatar'></td>
</tr>

	<tr>
	<td>Website:</td>
	<td><input type='text' name='website'></td>
</tr>

	<tr>
	<td>Youtube User Name:</td>
	<td><input type='text' name='youtube'></td>
</tr>

	<tr>
	<td>Bio:</td>
	<td><textarea name='bio' cols='35' rows='5'></textarea></td>
</tr>

	<tr>
	<td></td>
	<td><input type='submit' name='submitbtn' value='Register'></td>
</tr>
</table>

</form>";

if ($_POST['submitbtn']){


$firstname = strip_tags($_POST['firstname']);
$lastname = strip_tags($_POST['lastname']);
$username = strip_tags($_POST['username']);
$email = strip_tags($_POST['email']);
$password = strip_tags($_POST['password']);
$repassword = strip_tags($_POST['repassword']);
$website = strip_tags($_POST['website']);
$youtube = strip_tags($_POST['youtube']);
$bio = strip_tags($_POST['bio']);

$name = $_FILES['avatar'] ['name'];
$type = $_FILES['avatar'] ['type'];
$size = $_FILES['avatar'] ['size'];
$tmpname = $_FILES['avatar']['tmpname'];
$ext = substr($name, strrpos($name, '.'));

if ($firstname && $lastname && $username && $email && $password && $repassword){
	if ($password == $repassword){
		if (strstr($email, "@") && strstr($email, ".") && strlen($email) >= 6){

			require("scripts/connect.php");
				$sql = "SELECT * FROM users WHERE username='$username'";
			$query = mysql_query($sql) or trigger_error($sql . ' has an error!<br />' . mysql_error()); //added de-bugging No need to remove.
			$numrows = mysql_num_rows($query);
			if ($numrows == 0){
				$sql = "SELECT * FROM users WHERE email='$email'";
				$query = mysql_query($sql) or trigger_error($sql . ' has an error!<br />' . mysql_error()); //added de-bugging No need to remove.
				$numrows = mysql_num_rows($query);
				if ($numrows == 0){

				$pass = md5(md5($password));
				$date = date("F d, Y");

				if($name){
					move_uploaded_file($tmpname, "avatars/$username.$ext");
					$avatar = "$username.$ext";
				}
				else
					$avatar = "default_avatar.png";

				$code = substr (md5(rand(11111111111, 999999999999999)), 2,  25);
				$sql = "INSERT INTO users VALUES ('', '$firstname', '$lastname', '$username', '$email', 'pass', '$avatar', '$bio', '$website', '$youtube', '', '0', '$code', '0', '$date')";
				mysql_query($sql) or trigger_error($sql . ' has an error!<br />' . mysql_error()); //added de-bugging no need to remvoe.

						$webmaster = "Admin@trucksite.com";
						$subject = "Activate Your Account!";
						$headers = "From: Admin <$webmaster>";
						$message = "Hello $firstname.\n\nWelcome to trucksite below is a link for you to activate your account!.\n http://tprofiletesting.net23.net/activate.php?code=$code";

						if(mail($email, $subject, $message, $headers)) { //added de-bugging.
						echo "Your activation email has been sent to <b>$email</b>.";
						} else {
							echo 'Your activation email failed! Please try again!';
						}
				}
				else
					echo "That email is currently in use.";

			}
			else
				echo "That username is currently in use.";
		}
		else
			echo "You did not enter a vaild email.";
	}
	else
		echo "Your passwords did not match.";
}
else
	echo"You did not fill in all the required fields.";
}
echo "$form";


?>
</div>
<div id='footer'><a href='#'>Link</a><a href='#'>Link</a><a href='#'>Link</a><a href='#'>Link</a><a href='#'>Link</a><a href='#'>Link</a></div>




<body>
</body>
</html>

Link to comment
Share on other sites

You must have missed some script during copy/paste, because I get no parse errors with the posted script.  I also didn't change anything that would give you that error, as that error usually is caused by missing brackets ({). 

Link to comment
Share on other sites

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.