Jump to content

Error after dropping table


Recommended Posts

I was needing to change the data type for a field in a table that was the primary key. After researching the solution I came up with was to drop the table and recreate it. I dropped the table and then attempted to recreate it only it wouldn't take the original table name so I modified it and inserted the columns into the table under the correct data types. I believe in doing this I messed something up. When I access the site that the database is tied to I can't view information for the table I recreated or the main table it's connected to. I have tried to go to the affected tables and correct this issue by trying to change it to new table information but I receive an error. Now I am at a standstill and unsure of what needs to be done next. Thanks

Link to post
Share on other sites

on the site it says

500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed.

I think the primary key for the table I dropped was linked to two columns in two other tables. So I assumed I needed to go make the columns in the other tables foreign keys but that didn't work either or I just didn't do it correctly. Also the data type in one of the other tables it needs to be linked to is the old data type.

Link to post
Share on other sites

It's hard to get an idea without seeing your entire database schema, but I would suggest dropping all foreign keys related to those tables first, then drop and recreate the table, then set up the keys again.

Link to post
Share on other sites

I'm not sure, I think so, depending on how the foreign key is defined.

 

If you're doing all of this in PHP code, then you should add code to print error messages from MySQL. The 500 error doesn't help, it only means that there was an error with PHP. It would help to use PHP to print the actual error message from MySQL instead of just having the browser show a 500 response. For what it's worth, when I'm making changes to the database structure like this I do it with phpMyAdmin rather than writing PHP scripts to execute individual SQL statements.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...