By pramudya81 on
I did mistake on my production site!
I tried this on add new block
[code]
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";
$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;
$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)<br/>\n";
$get_result = $memcache->get('key');
echo "Data from the cache:<br/>\n";
var_dump($get_result);
[/code]
Now everything is not accessible. Only showing "Could not connect"
How to delete this block?
Regards
Comments
How to manually delete
How to manually delete script on block we created?
Where does the script gone to?
Very urgent..
Regards
pramudya81, I've done
pramudya81, I've done exactly the same thing. and I ended up doing exactly what beautifulmind suggested and it fixed it.
so, go to your drupal database, and scan for a unique phrase in that block. like "$memcache = new Memcache;". look at the results (hopefully there is just one), and make sure this has all the code and is the block you added. Then edit it. maybe just replace all the code with "oops!" or something that won't kill your page.
then save your changes. Then see if you can now use your site.
then.. create a page called test. Then, when you create a new block, define it to only appear on the page "test". That way, if it is a bad block, only the page "test" is dead.
hope that helps.
Lynne
Go to your db and browse the
Go to your db and browse the block table and locate this code in it.
Just delete this code from the "page" field.
I would like to suggest you that if you want to integrate a new feature in your live site, first test it in some test site, like a local site in your laptop, and if it successes, then integrate in your live site.
I would be glad if this helps you,
:)
Beautifulmind
Know more
Regards.
🪷 Beautifulmind
Thanks for your info. I
Thanks for your info. I really need this. But I cant view the pages field? How to see its content? I dont know which one to delete?
It is mysql issue actually. How to see content with "text" type field?
Regards
do you have cpanel?
do you have cpanel? phpadmin?
Lynne
yup I'm using
yup I'm using phpmyadmin
[code]select * from blocks[/code]
but I cant view the content of field pages
cos its type text I guess...
boxes
You can find the block by executing the query:
SELECT * FROM boxes WHERE format = 2;
Simply empty or correct the box containing the offending code.
--
The Manual | Troubleshooting FAQ | Tips for posting | How to report a security issue.
Thanks to beautifulmind,
Thanks to beautifulmind, heine and ikati. Esp for heine for pointing table boxes. And for beautifulmind tips.
I would never try anything on my prod site anymore... huh... scary...like risking my life
Thanks all. Solved
Cripes!
This is an annoying mistake to make.
Here's the code I used to make the correction myself, although I believe it deletes all blocks that are formatted as PHP:
% mysql -u username -p
Enter password: ***********
mysql> use drupal_database_name;
mysql> delete FROM boxes WHERE format = 2;
> This is an annoying mistake
> This is an annoying mistake to make.
I read that the safest way to test php that is intended for blocks was to paste it into the body of a 'create content' page, with the php input format selected, and click preview instead of save. The php script will run harmlessly in the preview area. If it crashes, no harm done, because it isn't in the database yet. A simple browser reload will get rid of the error.
Okay. You can try
Okay. You can try following.
Search for any of the strings which is within your block code you added. i.e. "could not connect". Search in block table only.
I think this way, you can find the record for the block you added. If you can, then do not remove it. Just set its status to 0, then Drupal will take care of everything.
:)
Beautifulmind
Know more
Regards.
🪷 Beautifulmind
Similar problem
I also made the mistake of adding php code and screwed something up. I added php code to a field that is used by forms in three content types. I am getting "The email address appears to be invalid" message at the top of pages in those content types. I tried to go back and delete the code in the field settings, but when I try to submit the changes, I get "The email address appears to be invalid" and the changes do not take place. The code is still in the code box when I go back to it later.
(Beside the point, but I got the code from another forum discussion to try to validate an email field--now I wish I didn't do it.)
Anyway, here is the code:
$mail = $form_values['submitted_tree']['email_address'];
if (!valid_email_address($mail)) {
form_set_error('submitted][email_address', t('The email address appears to be
invalid.'));}
How do I get rid of this? I tried to go into the database via phpMyAdmin and I cannot find the code.
I hope I am explaining this clearly. Thanks in advance for any help you can give.
how to correct something using PHPAdmin
I am relatively new to drupal, so I don't know the exact fields certain information is kept, but feel free to add .. make this more specific.
I do know that I've found the info for blocks in the "boxes" field. :)
hope this helps.
Lynne