Old 22-08-2004, 01:18   #1 (permalink)
barbeq
Registered User
 
Join Date: Aug 2004
Location: Montreal
Posts: 10
PHP & mySQL Help

Hello guys, I've never written in PHP before. After reading a few tutorials on the Internet, I decided to play around a bit and see if things I've learn work. I just made this really simple page that has a form where the user types in the info, and upon submission, it is supposed to connect to the mySQL server and input the data into a specific table.

Here goes the source of the page with the form:

Quote:
<form action="insert.php" method="post">
User Name: <input type="text" name="username"><br>
Password: <input type="text" name="password"><br>
E-mail: <input type="text" name="email"><br>
First Name: <input type="text" name="firstname"><br>
Last Name: <input type="text" name="lastname"><br>
Address: <input type="text" name="address"><br>
City: <input type="text" name="city"><br>
Province/State: <input type="text" name="province"><br>
Zip/Postal Code: <input type="text" name="zipcode"><br>
Country: <input type="text" name="country"><br>
Home Phone: <input type="text" name="homephone"><br>
Work Phone: <input type="text" name="workphone"><br>
PayPal Address: <input type="text" name="paypal"><br>
<input type="Submit">
</form>

Here goes the source of insert.php:

Quote:
<?
$username="some_username";
$password="some_password";
$database="db1";
$hostname="localhost";
$un=$_POST['username'];
$pw=$_POST['password'];
$email=$_POST['email'];
$fn=$_POST['firstname'];
$ln=$_POST['lastname'];
$addy=$_POST['address'];
$city=$_POST['city'];
$province=$_POST['province'];
$zip=$_POST['zipcode'];
$state=$_POST['state'];
$country=$_POST['country'];
$home=$_POST['homephone'];
$work=$_POST['workphone'];
$paypal=$_POST['paypal'];
$link=mysql_connect($hostname,$username,$password) ;
mysql_select_db($database,$link) or die( "Unable to select database ".mysql_error());
$query = "INSERT INTO cusinfo VALUES ('$un','$pw','$email','$fn','$ln','$addy','$city', '$province','$zip','$province','$country,$home','$ work','$paypal')";
mysql_query($query);
mysql_close($link);
?>

The database and table named "cusinfo" is already created. Everything seems to be fine but I'm getting the follow message when I test the file:

Quote:
Warning: mysql_connect(): Too many connections in /home/uckc/public_html/insert.php on line 6
Unable to connect to database.

Can anyone help me out please? I don't think I've reached the maximum number of connections since no one knows about the site I'm working with right now, besides I've read about mysql_connect and mysql_pconnect, I didn't use any persistent connections. There's no way I've maxed out the number of connections.

Thanks in advance!
  Reply With Quote
Old 22-08-2004, 05:21   #2 (permalink)
cam
vague™
 
cam's Avatar
 
Join Date: Mar 2004
Location: Glasgow
Posts: 5,337
Get in touch with whoever provides the mysql databse server and inform them of the problem - it's upto them to fix it, it's not your code

for reference, here's the Mysql manual page for the error
__________________
Random goodness at The Blog

  Reply With Quote
Old 23-08-2004, 08:35   #3 (permalink)
barbeq
Registered User
 
Join Date: Aug 2004
Location: Montreal
Posts: 10
Thanks. I sent e-mail to my webhost and they said they were moving my site to another server, although I think they are probably bullshieting. I was planning to change web host anyways.
  Reply With Quote
Old 25-08-2004, 18:04   #4 (permalink)
barbeq
Registered User
 
Join Date: Aug 2004
Location: Montreal
Posts: 10
Ok, now I don't get the "too many connections" problem anymore, but I still can't connect. It now says access denied, I checked at least 25 times before I post this. My username, password and hostname are all fine. I also double checked if my code is flawless. I still can't help. Can anyone of you go through my code and see if I forgot a little something?
  Reply With Quote
Old 26-08-2004, 04:05   #5 (permalink)
stickmus
hmmm...
 
stickmus's Avatar
 
Join Date: Jan 2004
Location: Yorkuk
Posts: 2,130
What exactly is the error code you're getting?

The code seems correct, do you definitely have a db1
  Reply With Quote
Old 26-08-2004, 12:34   #6 (permalink)
barbeq
Registered User
 
Join Date: Aug 2004
Location: Montreal
Posts: 10
Here's the error message:

Unable to select database Access denied for user: 'uckc_dbadmin@localhost' to database 'uckc_db1'

As for the code, I just replaced uckc_db1 by db1 in my previous post, but on my php file, I'm still using uckc_db1 as my database name.
  Reply With Quote
Old 27-08-2004, 05:18   #7 (permalink)
stickmus
hmmm...
 
stickmus's Avatar
 
Join Date: Jan 2004
Location: Yorkuk
Posts: 2,130
The problem's with your mysql server setup. Your code is fine.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8