dominic600 Posted August 6, 2011 Share Posted August 6, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/244064-where-to-find-phpmyadmin-detailsserver-user-database-etc/ Share on other sites More sharing options...
jcbones Posted August 6, 2011 Share Posted August 6, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/244064-where-to-find-phpmyadmin-detailsserver-user-database-etc/#findComment-1253383 Share on other sites More sharing options...
dominic600 Posted August 6, 2011 Author Share Posted August 6, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/244064-where-to-find-phpmyadmin-detailsserver-user-database-etc/#findComment-1253385 Share on other sites More sharing options...
jcbones Posted August 6, 2011 Share Posted August 6, 2011 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) Quote Link to comment https://forums.phpfreaks.com/topic/244064-where-to-find-phpmyadmin-detailsserver-user-database-etc/#findComment-1253387 Share on other sites More sharing options...
dominic600 Posted August 6, 2011 Author Share Posted August 6, 2011 i put in localhost instead, and its the same error. Im trying to find out where to create a new user in phpmyadmin but i cant seem to find it.. Quote Link to comment https://forums.phpfreaks.com/topic/244064-where-to-find-phpmyadmin-detailsserver-user-database-etc/#findComment-1253390 Share on other sites More sharing options...
jcbones Posted August 6, 2011 Share Posted August 6, 2011 Does your host have cpanel? Who is your host? Quote Link to comment https://forums.phpfreaks.com/topic/244064-where-to-find-phpmyadmin-detailsserver-user-database-etc/#findComment-1253392 Share on other sites More sharing options...
dominic600 Posted August 6, 2011 Author Share Posted August 6, 2011 i think somewhere let me look around the site.. and www.000webhost.com Quote Link to comment https://forums.phpfreaks.com/topic/244064-where-to-find-phpmyadmin-detailsserver-user-database-etc/#findComment-1253393 Share on other sites More sharing options...
jcbones Posted August 6, 2011 Share Posted August 6, 2011 They use cpanel, go to the database wizard and add a user, then bind the user to the database. Quote Link to comment https://forums.phpfreaks.com/topic/244064-where-to-find-phpmyadmin-detailsserver-user-database-etc/#findComment-1253395 Share on other sites More sharing options...
dominic600 Posted August 6, 2011 Author Share Posted August 6, 2011 I got it working 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); Quote Link to comment https://forums.phpfreaks.com/topic/244064-where-to-find-phpmyadmin-detailsserver-user-database-etc/#findComment-1253396 Share on other sites More sharing options...
jcbones Posted August 6, 2011 Share Posted August 6, 2011 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). Quote Link to comment https://forums.phpfreaks.com/topic/244064-where-to-find-phpmyadmin-detailsserver-user-database-etc/#findComment-1253397 Share on other sites More sharing options...
dominic600 Posted August 6, 2011 Author Share Posted August 6, 2011 <?php $server = ""; $dbuser = ""; $dbpass = ""; $database = ""; mysql_connect($server, $dbuser, $dbpass); mysql_select_db($database); ?> Quote Link to comment https://forums.phpfreaks.com/topic/244064-where-to-find-phpmyadmin-detailsserver-user-database-etc/#findComment-1253399 Share on other sites More sharing options...
jcbones Posted August 6, 2011 Share Posted August 6, 2011 There are no queries, nor is the 96 lines in it. Quote Link to comment https://forums.phpfreaks.com/topic/244064-where-to-find-phpmyadmin-detailsserver-user-database-etc/#findComment-1253400 Share on other sites More sharing options...
dominic600 Posted August 6, 2011 Author Share Posted August 6, 2011 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> Quote Link to comment https://forums.phpfreaks.com/topic/244064-where-to-find-phpmyadmin-detailsserver-user-database-etc/#findComment-1253402 Share on other sites More sharing options...
jcbones Posted August 6, 2011 Share Posted August 6, 2011 <?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> Quote Link to comment https://forums.phpfreaks.com/topic/244064-where-to-find-phpmyadmin-detailsserver-user-database-etc/#findComment-1253404 Share on other sites More sharing options...
dominic600 Posted August 6, 2011 Author Share Posted August 6, 2011 i got this error. Parse error: syntax error, unexpected $end in /home/a3888506/public_html/register.php on line 1 Quote Link to comment https://forums.phpfreaks.com/topic/244064-where-to-find-phpmyadmin-detailsserver-user-database-etc/#findComment-1253407 Share on other sites More sharing options...
jcbones Posted August 7, 2011 Share Posted August 7, 2011 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 ({). Quote Link to comment https://forums.phpfreaks.com/topic/244064-where-to-find-phpmyadmin-detailsserver-user-database-etc/#findComment-1253576 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.