473,499 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[SOLVED] Error code 1050: Table 'registration' already exists

37 New Member
Trying to create a table and insert records from a webform and I keep getting this message:

"Successfully created the registration table.

Unable to execute the query.

Error code 1050: Table 'registration' already exists"

Then after the table is created I re-run the query/webform and I don't receive the error message, but it doesn't update my table?
When I go to mySQL it shows the table 'registration' but has no updated records.
I'm 99.9% positive my code is correct, but I've also been working on this for the past 4hrs, so I could be a little out of it
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $DiverID = $_GET['diverID'];
  3. if (empty($DiverID))
  4.     exit("<p>You must enter a diver ID!  Click your browser's Back button to return to     
  5.  
  6. the previous page.</p>");
  7.  
  8. $DBConnect = mysqli_connect("localhost", "root", "password")
  9.     Or die("Unable to connect to the database server.</p>"
  10.     ."<p>Error code " . mysqli_connect_errno()
  11.     . ": " . mysqli_connect_error()) . "</p>";
  12. $DBName = "scuba_school";
  13. @mysqli_select_db($DBConnect, $DBName)
  14.     Or die("<p>Unable to select the database.</p>"
  15.     . "<p>Error code " . mysqli_errno($DBConnect)
  16.     . ": " . mysqli_error($DBConnect)) . "</p>";
  17.  
  18.  
  19. $TableName = "registration";
  20. $SQLstring = "SELECT * FROM $TableName";
  21. $QueryResult = @mysqli_query($DBConnect, $SQLstring);
  22. if (!$QueryResult) {
  23.     $SQLstring = "CREATE TABLE registration (diverID SMALLINT, class VARCHAR(40), days VARCHAR(40), time VARCHAR(40))";
  24.     $QueryResult = @mysqli_query($DBConnect, $SQLstring)
  25.         Or die("<p>Unable to create the registration table.</p>"
  26.         . "<p>Error code " . mysqli_errno($DBConnect)
  27.         . ": " .mysqli_error($DBConnect)) . "</p>";
  28.     echo "<p>Successfully created the registration table.</p>";
  29.            }
  30.  
  31. $Class = $_GET['class'];
  32. $Days = $_GET['days'];
  33. $Time = $_GET['time'];
  34. $SQlstring = "INSERT INTO $TableName VALUES('$DiverID', '$Class', '$Days', '$Time')";
  35. $QueryResult = @mysqli_query($DBConnect, $SQLstring)
  36.     Or die("<p>Unable to execute the query.</p>"
  37.     . "<p>Error code " . mysqli_errno($DBConnect)
  38.     . ": " .mysqli_error($DBConnect)) . "</p>";
  39.  
  40. mysqli_close($DBConnect);
Oct 7 '06 #1
1 10102
delusion7
37 New Member
Ok, well sometimes i guess a little sleep is needed to solve a problem. My variables were not the same in two sections of my script. User error, please ignore.. : )
Oct 9 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6164
by: Neo | last post by:
Hi, I have dumped a database into the file named dbase.sql when I am trying to recreate the database its giving the following error. can any one help me in this regard? # vim dbase.sql # mysql...
2
13902
by: Alicia | last post by:
Does anyone know why I am getting a "Syntax error in Create Table statement". I am using Microsoft Access SQL View to enter it. Any other problems I may run into? CREATE TABLE weeks (...
3
2870
by: Irfan | last post by:
hi, All I have a table in Access and I am using a storedProcedure (Make-Table query) to overwrite this table. It gives an error that 'Table Already Exists', which is true. But i want it to...
10
21398
by: ineedahelp | last post by:
Can anyone help me figure out why I continue to get a runtime error '3010' "TABLE qryMultiSelect ALREADY EXISTS'? Here is my code. thank you in advance for any help!!! Private Sub...
6
19141
by: deejow | last post by:
Hi, I want Access to return an error message that says an identical entry already exists. I do not want to set the field to 'no duplicates' because it is a name field and it is possible to have...
15
16141
by: OfficeDummy | last post by:
Hello all! I searched the Internet and this forum for a similar problem, but I found no help... Also, I'm a complete newbie to the fascinating world of programming, VBA and Access, so my question...
1
4563
by: Brucels | last post by:
I am receiving this error message when I attempt to open an Access 2000 .mdb file. I also receive it when I try to import from that file into a new .mdb file. I opened the file with no problem two...
7
5396
by: sasimca007 | last post by:
Hello friends, What my doubt is, a page is already designed in that page a table exists, and i am doing a script like a radio button exixts and when click that radio button...
0
2588
by: Jason Hamilton | last post by:
Hey all, I have one of those strange issues where I swear I haven't run this code in two weeks and it was working perfectly when I ran it last but now I get an exception that I have not only...
0
7012
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7225
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
3105
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
307
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.