To capture the error of a PHP query against a MySQL database, use this syntax: $result=mysql_query($query); if (!$result) { die(‘Invalid query: ‘ . mysql_error()); }
How to Capture Errors With PHP MySQL Queries
Securing phpMyAdmin
phpMyAdmin is a web-based tool for managing MySQL databases. The installation mainly consists of extracting the distribution and editing the database authentication information. In this article we will secure phpMyAdmin using a change of the directory name and a .htaccess file. First off, let’s extract the package: [root@srv-5 webroot]# ls php* phpMyAdmin-2.6.4-pl3.tar.bz2 [root@srv-5 webroot]# tar […]
Listing Available MySQL Databases and Tables
To determine what databases and tables are stored in your MySQL database, log in using the mysql client: [usr-1@srv-1 ~]$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 to server version: 4.1.12 Type ‘help;’ or ‘\h’ for help. Type ‘\c’ […]
SQLite Autoincrement
An autoincrement field is already included with SQLite. Select ROWID from a table to get the unique row identification. Here is some REALBasic code that selects the ROWID along with the other columns in the table and displays it in a ListBox: UtilSet.LBAP.DeleteAllRows db= New REALSQLdatabase dbFile = GetFolderItem(“mcj.rsd”) db.DatabaseFile=dbFile If db.Connect() then rs = […]
Dumping SQLite Table Structure
SQLite is a small, embeddable SQL database engine. Its licensing allows it to be included in commercial products and modified without publishing the source code. REALbasic uses SQLite as its included database engine. REALbasic has a query tool; however, it is nice to have the full-blown sqlite client. Let’s download the tarball and configure, compile, […]
Using MCJ to Practice SQL Commands – Part 1 – Initial Startup
Mountain Climbing Journal (MCJ) is a journal application that includes a SQL Tool to query the database using an embedded SQLite database engine. MCJ is a single executable. In this example we are using the GNU/Linux version, but there are versions for Microsoft Windows and Mac OS X as well: [usr-1@sv-1 sqlart]$ ls mcjl [usr-1@sv-1 […]
Using MCJ to Practice SQL Commands – Part 2 – Creating Some Records
Mountain Climbing Journal (MCJ) is a journal application that includes a SQL Tool to query the database using an embedded SQLite database engine. In Part 1 we created an initial database. Now, let’s add some records. The empty cup-like icon that is yellow, below, is what is used to add a blank record. It turns […]
Using MCJ to Practice SQL Commands – Part 3 – Some Queries
Mountain Climbing Journal (MCJ) is a journal application that includes a SQL Tool to query the database using an embedded SQLite database engine. In Part 2 we created some records. Now, let’s do some queries. Our first query will be to select all fields in all records in the journal table: select * from journal […]
Importing a CSV file to a SQLite Database
SQLite has a build in import command for importing records from text files. We used a tab for a field separator: $ sqlite3 database.db SQLite version 3.1.3 Enter “.help” for instructions sqlite> .separator “\t” Now that we have set our field separator, we can import: sqlite> .import ex.txt tablename sqlite>
Setting MySQL System Variables on the Fly
Many MySQL system variables can be set on the fly at the command line, without restarting the server. This is a great thing at times, like when that new code which was so thoroughly “tested” winds up consuming five times the database connections as the old version. Oops! Well, within the limits of the resources […]
Updating Tables with SQL
As we mentioned in Using MCJ to Practice SQL Commands, the MCJ has the ability to run queries directly. We had a bunch of configuration and compile options that now should run with type for the build tab2. We can change all of the chroot types to prechroot with the SQL command: update journal set […]
UNIX and Outlook Express Interoperability
The MIME on Outlook Express seems to be broken. We have seen several instances where Outlook Express users cannot read Email sent by UNIX Email clients. The message is garbled with lots of question marks and other random characters. We have had this problem here at netadmintools.com, since we use Linux Office Suite 99 for […]
IMAP Installation and Initial Configuration
First, we grab the source from the UW distribution link on here: [root@srv-33 src]# ls imap.tar.Z imap-utils.tar.Z [root@srv-33 src]# tar -xzf imap.tar.Z [root@srv-33 src]# ls imap-2001.BETA.SNAP-0105251616 imap.tar.Z imap-utils.tar.Z [root@srv-33 src]# mkdir imaputils (We will deal with imaputils in a different section.) [root@srv-33 src]# mv *util* imaputils mv: cannot move `imaputils’ to a subdirectory of itself, […]
Sendmail Installation and Initial Configuration
First, we want to remove all the RPM stuff. A general note here. We are removing the RPMs, because we want to write all of the articles from the perspective of a generic Linux distribution as much as possible. True, we rely on the default file structure and general layout of Red Hat; however, by […]
Automated email of attachments
It is quite easy to email security or traffic reports automatically. We will use mpack, sendmail, and cron, but certainly the techniques could be combined with other utilities. The challenge with emailing files is that you have to encode the attachments into the email message using MIME. For the nitty gritty on MIME, see http://www.nacs.uci.edu/indiv/ehood/MIME/MIME.html. […]
Clean up spam with Pine
Outlook is nice and all, particularly when dealing with, oh, 90 percent of the email clients out there. The same thing that makes it nice, also makes it insecure. Some of the email accounts we monitor have been quite public, and receive not only a lot of spam, but also a lot of viruses. If […]
Masquerading with Sendmail
If you have a sendmail server that has a hostname that isn’t resolvable, you may need to masquerade as a different host. This is often the case if you are running sendmail on your internal workstation. We also ran into this while bringing up a Squirrel Mail web based mail system. Simply add these lines […]
Update those Sendmail DNS Blacklists
All of the DNS blacklists we used a couple years ago are defunct. There are, however, a slew of new DNS-based blacklists that can help protect your users from spam. Understand that with any blacklist there is a chance that legitimate email will be blocked. Balancing this against the cost and annoyance of spam is […]
Formmail abuse
Make sure that you are not running an old version of formmail.pl. Check your cgi-bin directory to make sure. Even though the fix for formmail has been out since last August, we are still getting scanned for this on our webservers. Old versions of formmail.pl can be used to send spam. For more info, check […]
Reading winmail.dat Attachments
If you are using an email client besides Outlook (gasp!), you have most likely run into the attachment winmail.dat. Supposedly this can be prevented on the client side by sending mail in plain text; however, this doesn’t appear to work with attachments. We ran across a cool utility at Fentun that will extract attachments out […]