Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 07-04-2004, 05:14 PM   #1 (permalink)
hailvarg
Registered User
 
Join Date: Jul 2004
Posts: 1
hailvarg is on a distinguished road
signup form

Could not select database because Access denied for user: 'user@localhost' to database 'dbname'

i get that error, i dont know why, my code looks ok to me. any ideas?

PHP Code:
<?php 
if ($_POST["user"] <>""$l $l +1; else echo "Enter UserName"
if (
$_POST["pass"] <>""$l $l +1; else echo "Enter Password"
if (
$_POST["pass2"] <>""$l $l +1; else echo "verfiy password"
if (
$_POST["email"] <>""$l $l +1; else echo "Enter an email"
if (
$_POST["email2"] <>""$l $l +1; else echo "verify email"
if (
$_POST["pass"] == $_POST["pass2"]) $l $l +1; else echo "Password does not match"
if (
$_POST["email"] == $_POST["email2"]) $l $l +1; else echo "Email does not match"
$IP $_SERVER['REMOTE_ADDR']; 
$cdate date("y-m-d"); 
$level admin

if (
$l==7) { 
$conn mysql_connect("localhost","","") or die ("Could not connect to mysql because ".mysql_error()); 
$db mysql_select_db("klhgye") or die ("Could not select database because ".mysql_error()); 

$check "select * from tdb where tws = '".$_POST['user']."';"
$qry mysql_query($check) or die ("Could not match data because ".mysql_error()); 
$num_rows mysql_num_rows($qry); 
if (
$num_rows != 0) { 
echo 
"Sorry, that username is already taken.<br>"
exit; 
} else { 

$insert mysql_query("INSERT INTO tdb (tus, tpw, email, ip, dt, lvl) VALUES ('".$_POST['user']."','".$_POST['pass']."','".$_POST['email']."',' $IP ',' $cdate ',' $level ')") or die (mysql_error()); 

echo 
"Signed up, Login to edit profile</a>"

} else { 
echo 
" $conn; $level; $db; $insert; $IP; $cdate; "

?>
hailvarg is offline   Reply With Quote
Old 07-04-2004, 07:23 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,706
sde is on a distinguished road
that is a mysql error. you probably need a valid username and password.

is the site you're developing and testing this on your local computer? or is it a web hosting company?

it's here:
PHP Code:
$conn mysql_connect("localhost","username","password") or die ("Could not connect to mysql because ".mysql_error());
$db mysql_select_db("klhgye") or die ("Could not select database because ".mysql_error()); 
notice where i entered 'username' and 'password' replace that with your valid login information.
__________________
Mike
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML form preview then INSERT using PHP & MySQL SteveSoler PHP 16 09-22-2008 12:59 AM
EMERGENCY: Dynamic form processing DavH27 PHP 8 10-27-2004 08:52 PM
javascript riddle: why won't my form submit from this text link? sde HTML, XML, Javascript, AJAX 6 09-29-2004 06:56 AM
populate form field virtualGeorge PHP 4 08-23-2004 09:05 AM
Passing form data to PHP with Javascript bdl PHP 5 07-03-2002 11:18 AM


All times are GMT -8. The time now is 12:39 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting