Jump to content
JcMagpie

I broke my EdgeBS website, yes I know stupid!

Recommended Posts

I broke my EdgeBS website, yes I know stupid!

I installed several addons and then removed one. However I forgot to uninsall it first!! Yes my bad I know but it happens.

Website is EdgeBS 2.3.4.1 upto date as of end April running PHP 7.0

Was working fine in as much as had not spotted any issues. But then I had not edited the site either! Remove the addon and then went to edit store name and It will not accept any changes at all. If I make a change and save, nothing is saved and bank space is left and it brakes website. Nothing show at all just blank space on store front and admin.

Checking errors I see,

[17-May-2018 17:26:30 Europe/London] PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /home/website/public_html/includes/functions/database.php:167
Stack trace:
#0 /home/website/public_html/includes/functions/database.php(20): mysqli_connect('www.website....', 'username', 'password', 'web_db...')
#1 /home/website/public_html/includes/application_top.php(91): tep_db_connect()
#2 /home/website/public_html/index.php(13): require('/home/website/...')
#3 {main}
thrown in /home/website/public_html/includes/functions/database.php on line 167

line 167 is,

$link = mysql_connect($server, $username, $password);

on checking PHP 7.0 I find that mysql_* functions have been removed in PHP 7

Droping to PHP 5.6 gets website back and visable but editing in admin still not working. Have to reinstal database to get missing info back. Still not abe to edit after restore of db.

However after db restore site works with PHP 7.0 again. But edit still not posiable.

Even with all addons uninstalled and removed still not working!

Clearly something got messed up in deleating addon files without uninstalling first.

Errors on admin side,

[17-May-2018 17:26:36 Europe/London] PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /home/website/public_html/someadmin/includes/functions/database.php:181
Stack trace:
#0 /home/website/public_html/someadmin/includes/functions/database.php(20): mysqli_connect('www.website....', 'username', 'password, 'trythenb_freest...')
#1 /home/website/public_html/someadmin/includes/application_top.php(67): tep_db_connect()
#2 /home/website/public_html/someadmin/index.php(13): require('/home/trythenb/...')
#3 {main}
thrown in /home/website/public_html/someadmin/includes/functions/database.php on line 181
[17-May-2018 18:09:28 Europe/London] PHP Warning: Invalid argument supplied for foreach() in /home/website/public_html/someadmin/modules.php on line 35

Any feed back / solution welcome.

Oh and yes dont remove addon files untill you uninstall the addon:unsure:

Edited by justcatering
error

 

Share this post


Link to post
Share on other sites

@justcatering

1) Do you have a full backup of your site from when it was working?

2) What was the add-on you deleted without un-installing it? Have you tried re-adding that add-on?

 


Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites
22 minutes ago, ArtcoInc said:

@justcatering

1) Do you have a full backup of your site from when it was working?

2) What was the add-on you deleted without un-installing it? Have you tried re-adding that add-on?

 

Yes thankfully I have a full backup just trying to avoid doing it if it can be helped.

I did not want to mention the addon as its not its fault I'm stupid, but yes reinstalling it did not help. From what I can work out any atempt to write to the database is beeing prevented. However not geting any error mesages at all now.

Any edit now just blanks that bit of data and thats it. If I dont sort it out will just do a full restore tomorow.


 

Share this post


Link to post
Share on other sites

There is something different going on here. You don't have proper access to mysql. 

The bits of code that are reporting errors are only accessed when the function mysqli_connect doesn't exist and then the assumption is that you must be on an old server that has mysql_connect instead - but it hasn't.

Edited by BrockleyJohn

For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (2.3.4.1 CE).

here: https://github.com/gburton/Responsive-osCommerce/releases

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites
7 minutes ago, BrockleyJohn said:

There is something different going on here. You don't have proper access to mysql. 

The bits of code that are reporting errors are only accessed when the function mysqli_connect doesn't exist and then the assumption is that you must be on an old server that has mysql_connect instead - but it hasn't.

Hi John,

Yes its definetly not able to access the db when i edit. Odd that it gave the mysql_ error on PHP7.0 found 2 places in code that still used mysql_ so droping to PHP5.6 got front store back.

I have done a local restore of the home directory and restored the db from local back up but all i got is the front end backup and running edit is still not working. I'm just wondering if something on the server has broken which the host can fix in the morning when they do a full restore from there end. It could be that my admin rights have broken? i can login to admin but clerly not acess the db to make changes! just odd that deleating 4 files by mistake can cause such a problem! Plus why did it sudenly start giving PHP 7.0 errors when it broke! dont fully understand why it happend but suspect that the addon had put somthing into the db when instaled which when i deleted the files caused problems.

Will just have to be very carfull to uninstall addons first in future.


 

Share this post


Link to post
Share on other sites
7 minutes ago, wHiTeHaT said:

download" beyond compare".
Take a clean edge version....
Start comparing the core files against yours one by one.
So good start is begin with application_top.php
Then start with the template_top and bottom
Then start with the functions general.php and html.php
(thats for fixing not be able to edit)
Then it seems there is still a module activated that breaks your front end.
You tell... if you edit the store name in admin .... even the front-end stops working.... did i read that correct?
So... editing a category or product or manufacturer also not possible to edit these?
Does it do the same?

What happens if you do a install on your localhost?
You can use any lamp/wamp stack available to trace down the error.
Sometimes it gives more comfort and works faster then directly on the live site.

Hi wHiTeHaT,

No front end is now stable, just back end is not working. I can log into admin and is I say edit store name and save it just makes it blank and shows no error in error file at all. Same is true for any edit in admin store info or product. It looks like it is clearing config but not writing anything back to db. As John said may be permisions so I removed .htaccess to admin and checked db password was corect but made no diference.

I removed all addons and checked db manualy to make sure they were gone but still same. I will ask host to restore from there backup in morning.

Thanks.


 

Share this post


Link to post
Share on other sites

So I checked using phpMyadmin i can edit db no problem so I edit storename and save, go to store/admin and refresh page and new store name is shown so admin can read db change no problem. But when i edit in admin new name is in the edit box if I make no change and press save ,  it is erased and gone form admin but still in db in phpmyadmin . If I edit and change in admin it is erased in admin and db.

My head is hurting now so I am going to let the host do his restore in the morning. I will have to learn not to deleate addon files untill I have uninstalled the addon.


 

Share this post


Link to post
Share on other sites

I think what is happening is the string of installed modules needs to be updated to not include the module you deleted. If you uninstall a module through the admin it updates the configuration table for you but not you may need to do it manually.

Login to phpmyadmin and find the configuration table. Search for the rows containing the module keys and delete them. You will also need to update the key that contains the installed modules string. For instance the order totals modules is MODULE_ORDER_TOTAL_INSTALLED and the data in mine is:

 ot_subtotal.php;ot_discount_coupon.php;ot_redemptions.php;ot_cs_discount.php;ot_shipping.php;ot_rush_order.php;ot_total.php;ot_cs_cash_tendered.php;ot_tax.php.

You would need to delete the offending module from that list. 

I'm not sure what the module is so it might not be in the order total area. It could be in the payment modules etc....

OR

maybe just put the files back in place and uninstall it properly from your admin.


Matt

Share this post


Link to post
Share on other sites

justcatering The errors are saying MySQL can't be found. Hosts have the option of including MySQL but more and more are skipping that, assuming sites are using mysqli, I guess. You can ask your host to install mysqli or change the code of the addons you are using to not call it directly, which seems to be the case.

Share this post


Link to post
Share on other sites

This feels more like an environment problem than the code breaking the shop, but there are ways you can break the environment yourself eg with htaccess files and php directives in the code.

Maybe all this database error stuff you have introduced yourself with the way you are choosing php version - it doesn't seem to be pulling in mysql properly. Check that with fresh eyes.

If it started before you changed version then look at htaccess in admin and any ini_set in the code.

The original error can probably be resolved as Matt says, though in most cases if a module code is completely missing the installed modules setting is just ignored. My guess is you've partially deleted a module or otherwise caused it to throw a catastrophic error and it stops the front end working - but that shouldn't break admin.


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (2.3.4.1 CE).

here: https://github.com/gburton/Responsive-osCommerce/releases

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

Hi John,

Yes clear eyes definetly needed. The host restored over night and front end is fine but still issue with back end, its the same as when I restored from my localhost, I just can not get it to write to db. I know its my silly fault for not uninstaling properly, putting the addon on back did not help. I will manualy remove the addons from db and as recomended by matt and see if that helps.

"The errors are saying MySQL can't be found" not knowing the db that well I was confused by database.php line 167,

$link = mysql_connect($server, $username, $password); I take it that is fine as is?

The PHP is a bit confusing and I'm not sure if its involved, but no everything was working fine on PHP7.0 since first install, it was only when I made the silly error and site went blank that I checked error log and found

[17-May-2018 17:26:30 Europe/London] PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /home/website/public_html/includes/functions/database.php:167

A quick check of pfp errors showed me that mysql_  was nolonger used in PHP 7.0  so I droped from 7.0 to 5.6 on cPanel as I have the option to set any PHP for each site. That at first looked good as it made both front end and admin visable again? But as I found still had issues writing to db.

I will ask host about MySQL but they did say they have made no changes.

If all else fails I will just rebuild from scratch, after all I have the db back up so should not take long.


 

Share this post


Link to post
Share on other sites

assuming you can get into it, in admin Server Info, what php and mysql versions are reported?

...and is there a section for mysqli?

Edited by BrockleyJohn
more questions

For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (2.3.4.1 CE).

here: https://github.com/gburton/Responsive-osCommerce/releases

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

So you're not using mysql at all but MariaDB - and quite a high version

Probably there are incompatibilites there. I have seen people saying they have it working but I don't remember the version; search the forum for Maria...


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (2.3.4.1 CE).

here: https://github.com/gburton/Responsive-osCommerce/releases

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites
9 minutes ago, BrockleyJohn said:

So you're not using mysql at all but MariaDB - and quite a high version

Probably there are incompatibilites there. I have seen people saying they have it working but I don't remember the version; search the forum for Maria...

:unsure: Its the same on all my sites as they are all hosted on same servers, All the others work fine and can be edited with no problem. I might just rebuild this one and just accept I must have done something stupid to brake it.


 

Share this post


Link to post
Share on other sites

Well it just goes to show how stupid one can be :blush: , John you were right was down to a .htacces beeing bad! restoring did not fix as its either bad on both my back up and the server side backup or just geting messed up when being restored not sure. I simply removed .htacces in root and replaced with blank and it all work! can edit db from admin without any issues.  The only Addon I use of that adds to .htacces is Seo Urls 5 , its the one addon I did not remove!

So a question of just adding back each line of the old .htacces one at a time to find what brakes the site.

Thanks for all your help. :thumbsup:

Zahid

 


 

Share this post


Link to post
Share on other sites

Got to bottom of the issue possibly. So this was what broke the site.

#new redirect
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
</IfModule>

replaced it with this and everythig works?

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}[R=301,L]

Not sure why the first code was in the .htacces as its not in any other I have.

Still no clue as to why it would break site?


 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×