admin login issues on Magento 1.9 - magento-1.9

The image is my admin login screen. I have not made any changes in months but now can't log in and the image shows the login screen. I have tried to cleared cache and sessions etc but no change. I have tried on all browsers. I have tried clearing browser cache. I have tried to restore from a few days earlier but same issue. Can anyone give me any other options to try. I have searched but nothing seems similar to this issue.

This worked for me via phpmyadmin:
SET FOREIGN_KEY_CHECKS=0;
UPDATE core_storeSET store_id = 0 WHERE code='admin';
UPDATE core_store_group SET group_id = 0 WHERE name='Default';
UPDATE core_website SET website_id = 0 WHERE code='admin';
UPDATE customer_group SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=1;

Related

Mediawiki: how to update page content from external script?

I would like to update the Main_Page of our wiki from a script run by cron.
Apart from the page content itself, in pagecontent.old_text, what else do I need to update?
If I only update the "old_text" field, the new content is not displayed. I get the previous content, presumably from a cache somewhere. In LocalSettings.php I have $wgMainCacheType = CACHE_NONE;. So I guess that I need to also update something else in the Mediawiki database?
(In case it matters, this is with Mediawiki 1.31.10 on Debian 10 with Apache and PostgreSQL)
Use maintenance/edit.php, the edit API, Pywikibot etc. Trying to do changes via direct DB manipulation is a rather bad idea.
Updating the timestamp in page.page_touched works to have the wiki show the new content.
This example is using a PostgreSQL database, so it might need some adjustments if used with the more common MySQL DB.
To update the text of a page identified by it's name, it is necessary to join the page, revision and pagecontent tables. This example updates a page named "Drafts":
UPDATE pagecontent
SET old_text = 'New page content'
FROM page, revision
WHERE page.page_title='Drafts'
AND pagecontent.old_id=revision.rev_text_id
AND page.page_latest=revision.rev_id;
And to update the page timestamp so that the wiki shows the new content:
UPDATE "page"
SET page_touched = now()
WHERE page_namespace = '0'
AND page_title = 'Drafts';
An alternative which avoids tinkering with the database directly, is to use an extension like External Data. There are examples here to embed a text file in a page, and here to embed the output of a database query.

SQLAlchemy not marking session as dirty for changed attribute

When attempting to change an object loaded in with SQLAlchemy, the session.dirty object is not behaving the way I'd expect:
o = sqla.session.query(sqla.Game).first()
<sqla.Game at 0x7fdcc1f707b8>
o.wiki
<null>
o.wiki = 'test'
o.wiki
'test'
sqla.session.is_modified(o)
False
sqla.session.dirty
IdentitySet([])
inspect(o).attrs['wiki'].history
History(added=(), unchanged=['test'], deleted=())
Committing this to the database does in fact update it, but I'm really unclear on why it's marked as "unchanged". If I modify a relationship on the object, that does properly show in the "new" and "deleted" areas in history. I'm loading the models in via automap, and the session does not have autocommit on.
I have also tried manually calling flag_modified, and specifying the column directly (without automap) to no avail.
Annnd I figured it out. I had autoflush on by default. Turning it to False fixed the issue.

MySQL - Track user activity to display content only the first time

I need to show a modal window the first time the user logs in, after logging in, that modal window should not be displayed.
Questions:
I'm thinking of creating a field in the user table to be called, modal_first_time, and adding the values 0 or 1
0 = Modal not shown
1 = Modal shown
So that when you log in for the first time, perform a logging in that table and change the value from 0 to 1, so you do not show that modal window again.
But is this optimal? What if I have 10 modal windows, do I have to create 10 additional fields?
It is well the way to add a field in the table, or there is some more optimal and simple, the best would be a session variable but these when clearing Cookies or switching computers would show again.
I would suggest making a "Modal accessed" table.
This table would hold 4 columns.
UID, UserID, ModalID, accessed
To find if the current status of a Modal for a user you would run a SELECT in your "onLogin" event.
Below is a very rough example of how this could be utilized to work for 1 or many Modals
SELECT ModalID FROM `SchemaName`.`ModalAccessedTable`
WHERE UserID = "Bob"
AND Accessed = 0
OR another usage
SELECT Accessed FROM `SchemaName`.`ModalAccessedTable`
WHERE UserID = "Bob"
AND ModalID = 'ModalName'
Update access usage
UPDATE `SchemaName`.`ModalAccessedTable`
SET Accessed = 1
WHERE UserID = "Bob"
AND ModalID = 'ModalName'
With a setup like this you can select, and update each individual entry per userID as needed, with relatively efficient lookup efficiency.
Side Note:
Assuming this table will become large, you will benefit greatly from properly build multi-column indexes.

"Operation must use an updateable query" error in MS Access

I am getting an error message: "Operation must use an updateable query" when I try to run my SQL. From my understanding, this happens when joins are used in update/delete queries in MS Access. However, I'm a little confused because I have another query almost identical in my database which works fine.
This is my troublesome query:
UPDATE [GS] INNER JOIN [Views] ON
([Views].Hostname = [GS].Hostname)
AND ([GS].APPID = [Views].APPID)
SET
[GS].APPID = [Views].APPID,
[GS].[Name] = [Views].[Name],
[GS].Hostname = [Views].Hostname,
[GS].[Date] = [Views].[Date],
[GS].[Unit] = [Views].[Unit],
[GS].[Owner] = [Views].[Owner];
As I said before, I am confused because I have another query similar to this, which runs perfectly. This is that query:
UPDATE [Views] INNER JOIN [GS] ON
[Views].APPID = [GS].APPID
SET
[GS].APPID = [Views].APPID,
[GS].[Name] = [Views].[Name],
[GS].[Criticial?] = [Views].[Criticial?],
[GS].[Unit] = [Views].[Unit],
[GS].[Owner] = [Views].[Owner];
What is wrong with my first query? Why does the second query work when the first doesn't?
There is no error in the code, but the error is thrown due to the following:
- Please check whether you have given Read-write permission to MS-Access database file.
- The Database file where it is stored (say in Folder1) is read-only..?
suppose you are stored the database (MS-Access file) in read only folder, while running your application the connection is not force-fully opened. Hence change the file permission / its containing folder permission like in C:\Program files all most all c drive files been set read-only so changing this permission solves this Problem.
Whether this answer is universally true or not, I don't know, but I solved this by altering my query slightly.
Rather than joining a select query to a table and processing it, I changed the select query to create a temporary table. I then used that temporary table to the real table and it all worked perfectly.
I had the same error when was trying to update linked table.
The issue was that linked table had no PRIMARY KEY.
After adding primary key constraint on database side and re linking this table to access problem was solved.
Hope it will help somebody.
I had the same problem exactly, and I can't remember how I fond this solution but simply adding DISTINCTROW solved the problem.
In your code it will look like this:
UPDATE DISTINCTROW [GS] INNER JOIN [Views] ON <- the only change is here
([Views].Hostname = [GS].Hostname)
AND ([GS].APPID = [Views].APPID)
...
I'm not sure why this works, but for me, it did exactly what I needed.
To update records, you need to write changes to .mdb file on disk. If your web/shared application can't write to disk, you can't update existing or add new records. So, enable read/write access in database folder or move database to other folder where your application has write permission....for more detail please check:
http://www.beansoftware.com/ASP.NET-FAQ/Operation-Must-Use-An-Updateable-Query.aspx
set permission on application directory solve this issue with me
To set this permission, right click on the App_Data folder (or whichever other folder you have put the file in) and select Properties. Look for the Security tab. If you can't see it, you need to go to My Computer, then click Tools and choose Folder Options.... then click the View tab. Scroll to the bottom and uncheck "Use simple file sharing (recommended)". Back to the Security tab, you need to add the relevant account to the Group or User Names box. Click Add.... then click Advanced, then Find Now. The appropriate account should be listed. Double click it to add it to the Group or User Names box, then check the Modify option in the permissions. That's it. You are done.
I used a temp table and finally got this to work. Here is the logic that is used once you create the temp table:
UPDATE your_table, temp
SET your_table.value = temp.value
WHERE your_table.id = temp.id
I got this same error and using a primary key did not make a difference. The issue was that the table is a linked Excel table. I know there are settings to change this but my IT department has locked this so we cant change it. Instead, I created a make table from the linked table and used that instead in my Update Query and it worked. Note, any queries in your query that are also linked to the same Excel linked table will cause the same error so you will need to change these as well so they are not directly linked to the Excel linked table. HTH
This is a shot in the dark but try putting the two operands for the AND in parentheses
On ((A = B) And (C = D))
I was accessing the database using UNC path and occasionally this exception was thrown. When I replaced the computer name with IP address, the problem was suddenly resolved.
You have to remove the IMEX=1 if you want to update. ;)
"IMEX=1; tells the driver to always read "intermixed" (numbers, dates, strings etc) data columns as text. Note that this option might affect excel sheet write access negative."
https://www.connectionstrings.com/excel/
UPDATE [GS] INNER JOIN [Views] ON
([Views].Hostname = [GS].Hostname)
AND ([GS].APPID = [Views].APPID) <------------ This is the difference
SET
[GS].APPID = [Views].APPID,
[GS].[Name] = [Views].[Name],
[GS].Hostname = [Views].Hostname,
[GS].[Date] = [Views].[Date],
[GS].[Unit] = [Views].[Unit],
[GS].[Owner] = [Views].[Owner];

Dynamically selecting MySQL updates

This is more of a theory question. I have a page with a bunch of various textfields, dropdown boxes, etc. Each user has his/her "own page" that can be updated via this update page that I am referring to. He updates the fields at his choosing. It passes about 30 variables (if every field is inputted) to a "preview page". If the person likes the preview page, then they click an "update" button at the bottom of the preview page and all the various variables are updated into the appropriate MySQL table and their "own page" that others see is updated dynamically. (let me know if this explanation isn't clear).
Inserting this information for the first time is easy. However, when a user wants to update only a few of the fields for his page later, this is where I am confused. How do I make the MySQL update query dynamic to recognize an update to ONLY the fields on the page that the user wants to update (while he leaves the other fields blank, thus leaving the old information intact for those columns, and they are disregarded in the update query).
Let me know if what I'm asking doesn't make sense and I'll try again.
Thanks for your help.
The easiest way to do this would be
UPDATE MyTable m SET m.f1 = COALESCE(input1,m.f1), m.f2 = COALESCE(input2,m.f2), ....
WHERE m.id = key;
The COALESCE will return the first non-null value (or null if all values are null).
Note that you can insert a default value after the existing field value if you want to force a default.
Like so:
UPDATE MyTable m SET m.f1 = COALESCE(input1,m.f1,default1), m.f2 = COALESCE(input2,m.f2,default2), ....
WHERE m.id = key;
See: MySQL: how to use COALESCE
http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_coalesce