ninedoors Posted June 12, 2007 Share Posted June 12, 2007 I have written a script to insert data I get from a form on my website that users fill out. The script works fine the first time and then when I go to submit a second form I get an error. Is there some kind of function that I have turned on that limits the space in each database? I have created a couple databases under the same user name and the work fine. This database has 10 fields and checks to make 2 of them are unique. I am lost as I have been killing myself over this for two days. Can anyone please help me? Nick Link to comment https://forums.phpfreaks.com/topic/55325-phpmyadminmysql-problems-newbie/ Share on other sites More sharing options...
Wildbug Posted June 12, 2007 Share Posted June 12, 2007 Is there some kind of function that I have turned on that limits the space in each database? Unlikely. Can you post a DESCRIBE TABLE and the relevant parts of the script? What error do you get when you get an error? Link to comment https://forums.phpfreaks.com/topic/55325-phpmyadminmysql-problems-newbie/#findComment-273486 Share on other sites More sharing options...
ninedoors Posted June 12, 2007 Author Share Posted June 12, 2007 Wildbug, I get an error message that I created in the script. This tells me that it connected to the database but was unable to load in the data. Here is the code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $host="localhost"; // Host name $username="*********";MySQL username $password="*********"; MySQL password $db_name="********info"; // Database name $tbl_name="reg"; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Get values from form $name=$_POST['fullname']; $email=$_POST['email']; $address=$_POST['address']; $city=$_POST['city']; $postalcode=$_POST['postalcode']; $phone=$_POST['phonenum']; $signup=$_POST['signup']; $position=$_POST['position']; $hockeylevel=$_POST['hockeylevel']; //Check to see if values already exist in the database $check= mysql_query("SELECT FullName FROM $tbl_name WHERE FullName = '$name'"); $returned = mysql_fetch_array($check); if(!empty($returned)) { header("Location: error-nameexists.php"); mysql_close(); Die(); } else { //Check to see if email exists in the database $check = mysql_query("SELECT Email FROM $tbl_name WHERE Email = '$email'"); $returned = mysql_fetch_array($check); if(!empty($returned)) { header("Location: error-emailexists.php"); mysql_close(); Die(); } else { // Insert data into mysql $sql="INSERT INTO $tbl_name(FullName, Email, Address, City, PhoneNum, PostalCode, SignUp, Position, HockeyLevel)VALUES('$name', '$email', '$address', '$city', '$phone', '$postalcode', '$signup', '$position', '$hockeylevel')"; $result=mysql_query($sql); // if successfully insert data into database, displays message. if($result) { header("Location: reg-submit.php"); mysql_close(); Die(); } else { echo "ERROR"; } } } // close connection mysql_close(); ?> </body> </html> The error I get is the one you see at the bottom (echo "ERROR" Like I said it works perfect this first time. I am using phpmyAdmin for the DB management and am new to that as well. Anything you can think of why it does this. I have also tested it to see if it is connecting to the DB and it does because if I enter a name or email that is already in the DB(the only there) then I am sent to my error-nameexists.php page. Hope this gives you a little more info. Nick Link to comment https://forums.phpfreaks.com/topic/55325-phpmyadminmysql-problems-newbie/#findComment-273497 Share on other sites More sharing options...
fenway Posted June 17, 2007 Share Posted June 17, 2007 in the else block, echo mysql_error() and $sql. Link to comment https://forums.phpfreaks.com/topic/55325-phpmyadminmysql-problems-newbie/#findComment-276325 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.