I put the code from the top of this post: http://drupal.org/node/53087 into a custom block and upon saving this new block my entire website was gone with a fatal error.

Fatal error: Call to a member function isError() on a non-object in /.../public_html/drupal/includes/common.inc(1150) : eval()'d code on line 13

I changed the name of the block.module and the site comes back up, without sidebars or blocks. But now with the block.module removed, I can't get to /admin/blocks in order to turn off that new block with the bad code.

How can I fix this?

Can I remove that new website-eating custom block without being able to access the block admin page?
In other words, where does that bad code for the custom block go so that I can try to hunt it down and trim it out?

-I will paypal anyone who can help me get my blocks back $20

Comments

vm’s picture

go into your database and manually shut the buggy block off, setting it to zero

psr’s picture

Is there anyway can i do this through the drupal file directories?

Ive got ssh access and a control panel file browser for my hosting server.
How do I access the database?

Ive also got phpmyadmin running on my local machine is there way to use it to access the remote server where the website is hosted?

http://localhost/phpmyadmin/

vm’s picture

this handbook page, here : http://drupal.org/node/45563 with is in the FAQ's section speaks directly to your issue.

coreyp_1’s picture

Click on "add", then "page"

Give it a dummy title, and past this code into the body:

db_query ('UPDATE {blocks} SET status=0, region="" WHERE module="block"');

Make sure to include the <?php and ?>. Select the PHP filter under "Input Filters".

click on "preview"

This will disable all custom created blocks. You can then replace your block.module.

- Corey

psr’s picture

Corey!!! thanks worked great. let me know what your paypal send to address is and the $20 will be on its way.

did you code that up just now or was that php bit something that you had from a previous experience?
and is this a general trick for changing mysql entries without phpmyadmin and such?

coreyp_1’s picture

I wrote this for this situation, but I've had my share of block issues before. ;o)

I always use a method like this when testing PHP code. I go to "create content" -> "page", and then code away and hit the preview button.

I would suggest that you always test code in this manner, even snippets meant to go into a block. There's no preview option when creating a block, so if you enter code that creates a fatal error (like what happened here), you're sunk. Testing the code in a page with the preview button takes away a lot of the danger.

I do not recommend this method if you are unfamiliar with MySQL or PHP. You can literally destroy your entire database in one command. Always make backups before doing something like this, and never experiment with code on a live site. Always do your preliminary work on a test site.

Now that I've said all that, I do think that this is a useful trick for development. Just the other day I was helping someone out with ordering file attachments in a theme function. To do so, I had to know how files are stored in the node object, and, since I don't claim to have Drupal structure memorized, I wrote a bit of code to load a node object and dump it's contents to the screen. Yes, it's crude, but that way I was sure of variable names, whether I was dealing with objects or arrays, etc. I've never heard of anyone else "cheating" like this, but it has worked for me!

As for the Paypal, can you send me a message using my contact form?

- Corey