MySQL database Question

Nytshade

Well-known member
Registered
Joined
Jan 22, 2015
Messages
503
Points
0
Hey guys, hope I'm posting this in the right section. I bought a script and now there's a new update which involves going to the phpMyadmin to make some changes. Now every time I try to run a query in the SQL tab, I get this error:

Error
SQL query:

ALTER TABLE `users` ADD `ip` VARCHAR( 45 ) NOT NULL AFTER `offline` ;

MySQL said:

#1060 - Duplicate column name 'ip'


And now I'm stuck and don't know what to do. My hosting company can't even help they send me to resources I don't even understand as my knowledge is limited in this type of stuff.
 

webdesign

Well-known member
Joined
Jul 5, 2012
Messages
120
Points
0
Of course, your web hosting supporters couldn't help you on this, it's not in their industry.

As it said, you have already got a field IP in your table

Error
SQL query:

ALTER TABLE `users` ADD `ip` VARCHAR( 45 ) NOT NULL AFTER `offline` ;

MySQL said:

#1060 - Duplicate column name 'ip'
You need to go your database > table users, delete or empty information this filed and run query again.

If it still show error, drop IP field, and insert a new field with name ip after offline field and run your query again.

Don't forget to backup your database before making these changes
 

Nytshade

Well-known member
Registered
Joined
Jan 22, 2015
Messages
503
Points
0
When I go to the users table, I can only find the names of members who registered to my site and if I empty it won't I be deleting the users? Or am I missing something?
 

elcidofaguy

Well-known member
Registered
Joined
Jan 13, 2015
Messages
866
Points
0
elcidofaguy
Quick replies from others whilst posting mine ;-)... So just to add....

Yes indeed... Dont drop any columns as you could be deleting data.... You need to check the column "IP" matches that of the script e.g. "datatype varchar with a size of 45 chars together with not null setting set to true"... and amend it manually if necessary....

Once done I would remove that line of code "ALTER TABLE `users` ADD `ip` VARCHAR( 45 ) NOT NULL AFTER `offline` ;" from your script as mentioned previously as you do not need it...
 

elcidofaguy

Well-known member
Registered
Joined
Jan 13, 2015
Messages
866
Points
0
Yo buddy! I mess around with mysql and php alot of the time... So no worries this is easy to fix... The script is trying to add a new column called "IP" to a table called "users"... However the column already exists... Here is what I would do:

1) Go into Mysql via myphpadmin on your webhost... Open up the database and access the table "users"... View the table in structure mode... That way you can check to make sure that the field "IP" is set to datatype varchar with a size of 45 chars together with not null setting set to true. If you need to change it click on the pencil icon/change... Chances are that it will be fine and no changes are required....

2) Once you've checked and it looks okay then I would remove the line: "ALTER TABLE `users` ADD `ip` VARCHAR( 45 ) NOT NULL AFTER `offline` ;" from your script as it is not needed.... and run it again....

Hope that works... Let me know ...

Cheers,

Sid
 

Nytshade

Well-known member
Registered
Joined
Jan 22, 2015
Messages
503
Points
0
WOW this is rocket science :DD:

Thnx guys, I tried your solution Sid my friend but it's rocket science because I can't find the string on my script so I decided to drop the "ip" column since it didn't have any data on it and it worked without returning the error.

Help much appreciated :salute:
 
Older Threads
Newer Threads
Latest Threads
Replies
1
Views
40
Replies
0
Views
35
Replies
0
Views
55
Recommended Threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top