How to Delete Records in PHP using MySQL

The code in the HTML/PHP markup would look something like:

<?php mysql_query("DELETE FROM yourtable WHERE yourfield='yourvalue' ")
or die(mysql_error()); ?>

This code deletes any record from the table named “yourtable” when that record’s field named “yourfield” is identically equal to “yourvalue”. The names of these objects will, of course, be replaced by the unique names that your set up uses.

Source: tizag.com – excellent tutorials on all kinds of coding, programming, and other technical stuff.

Posted under Freeware, MySQL, WebDev

This post was written by Content Curator on November 16, 2009

Tags: , , , , , , , , , , , , , ,

How to CHMOD on files but not directories (inodes)

From Linuxquestions.org:

“There are probably several methods, but one is to use find to produce a list of all files (not directories) and then execute chmod on each of them. For example

Code:
find /my/directory -type f -exec chmod 644 '{}' +

Change the red parts to fit your needs. If you wonder what that ‘{}’ is..well, you may have guessed that it’s where the filelist is being put when exec’ing the given command on each file.

You can also first try the command without chmod’ing to see that it affects the right files:

Code:
find /my/directory -type f

The above would find all regular files (not directories, for example) from within /my/directory.

If the command happens to throw you an error about the exec part, chances are it’s because of the plus sign (+) that ends the exec part. In this case try replacing the plus (+) with an escaped semicolon (\;) so it becomes

Code:
find /my/directory -type f -exec chmod 644 '{}' \;

On some machines I remember that it worked with semicolon (which needs a backslash in front of it, to protect it from being interpreted by your shell), but on my current installation it’s the plus sign (without a backslash).

Another way would probably be to list all regular files on the directory (using either find or any tool that can just list all files without directories) and then pipe the output to xargs with which the chmod was run.”

and from http://movabletripe.com/archive/recursively-chmod-directories-only/

June 19th, 2006

find . -type d -exec chmod 755 {} \;

This will recursively search your directory tree (starting at dir ‘dot’) and chmod 755 all directories only.

Similarly, the following will chmod all files only (and ignore the directories):

find . -type f -exec chmod 644 {} \;

Posted under Linux

This post was written by Content Curator on October 17, 2009

Tags: , , , , , , , , , , , , , , , ,

How to automatically reload a page when it is finished reloading, using javascript

So, you have a web page (HTML, PHP, etc.) that you want to reload over and over. And at the same time, you want to be sure that the entire page loads before it starts the loop over again. Here is a javascript way to do just that. Simply include this script in yout HTML code, and watch the magic:

<script language="javascript">
window.onload=new Function("window.location.reload();");
</script>

Enjoy!

Posted under WebDev

This post was written by Content Curator on October 3, 2008

Tags: , , , , , , , , , , , , , ,