Quick header file to use include or require with in PHP:
$mysql_user="mysqluser";
$mysql_host="mysql.sample.com";
$mysql_db="mydb";
$mysql_pass = "mysqlpassword";
mysql_connect($mysql_host,$mysql_user,$mysql_pass);
@mysql_select_db($mysql_db) or die("Unable to connect to database...");
foreach ($_REQUEST as $key => $value) {
$_REQUEST[$key] = mysql_real_escape_string($value);
}
Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts
Monday, May 10, 2010
Thursday, May 6, 2010
httpd.conf for mod_auth_mysql
Auth_MySQL_Info MySQL.Server username password
Auth_MySQL_General_DB DB with auth info
Auth_MySQL_General_DB DB with auth info
Getting Mod_Proxy to bounce to Tomcat (FINALLY)
This particular problem has been plaguing me for months. How to make HTTPD proxy to a Tomcat instance. Finally got it figured out. BONUS: Also configured it to authenticate via MySQL before proxying the connection. This is using a self-signed SSL cert.
NameVirtualHost zookeeper.mydomain.com:443
< VirtualHost zookeeper.mydomain.com:443 >
ServerAdmin gene@mydomain.com
SSLEngine On
SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key
ProxyRequests Off
ProxyPreserveHost On
< Proxy * >
Order deny,allow
Allow from all
< /Proxy >
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
< Location >
AuthName "Level 4 Staff Tools Login"
AuthType Basic
AuthUserFile /dev/null
AuthBasicAuthoritative Off
Auth_MySQL On
Auth_MySQL_Password_Table users
Auth_Mysql_Group_Table staffGroups
Auth_MySQL_Username_Field userName
Auth_MySQL_Password_Field password
Auth_MySQL_Group_Field groups
Auth_MySQL_Empty_Passwords Off
Auth_MySQL_Encryption_Types Plaintext Crypt_DES MySQL
require group engineering art
# Order allow,deny
# Allow from all
< /Location >
ErrorLog /var/log/apache2/error.log
NameVirtualHost zookeeper.mydomain.com:443
< VirtualHost zookeeper.mydomain.com:443 >
ServerAdmin gene@mydomain.com
SSLEngine On
SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key
ProxyRequests Off
ProxyPreserveHost On
< Proxy * >
Order deny,allow
Allow from all
< /Proxy >
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
< Location >
AuthName "Level 4 Staff Tools Login"
AuthType Basic
AuthUserFile /dev/null
AuthBasicAuthoritative Off
Auth_MySQL On
Auth_MySQL_Password_Table users
Auth_Mysql_Group_Table staffGroups
Auth_MySQL_Username_Field userName
Auth_MySQL_Password_Field password
Auth_MySQL_Group_Field groups
Auth_MySQL_Empty_Passwords Off
Auth_MySQL_Encryption_Types Plaintext Crypt_DES MySQL
require group engineering art
# Order allow,deny
# Allow from all
< /Location >
ErrorLog /var/log/apache2/error.log
Wednesday, May 5, 2010
Post Vars as an Array
$result_storeList=mysql_query('SELECT * FROM stores');
while($arrayStoreName=mysql_fetch_array($result_storeList)) {
echo "".$arrayStoreName['name']."(put html checkbox here with $arrayStoreName['ID']).(other HTML here)\n";
}
Submit that to:
$getStore = "SELECT * from stores";
$getStoreQuery = mysql_query($getStore);
while($getStoreArray = mysql_fetch_array($getStoreQuery)) {
$totalStoreNum = $getStoreArray['ID'];
if(htmlspecialchars($_POST[$getStoreArray['ID']])) {
$storeChoice = $getStoreArray['ID'];
$sql_Query = "INSERT INTO storeItems (storeID,itemID) VALUES ('".$storeChoice."','".$recordID."')";
mysql_query($sql_Query); }
}
while($arrayStoreName=mysql_fetch_array($result_storeList)) {
echo "".$arrayStoreName['name']."(put html checkbox here with $arrayStoreName['ID']).(other HTML here)\n";
}
Submit that to:
$getStore = "SELECT * from stores";
$getStoreQuery = mysql_query($getStore);
while($getStoreArray = mysql_fetch_array($getStoreQuery)) {
$totalStoreNum = $getStoreArray['ID'];
if(htmlspecialchars($_POST[$getStoreArray['ID']])) {
$storeChoice = $getStoreArray['ID'];
$sql_Query = "INSERT INTO storeItems (storeID,itemID) VALUES ('".$storeChoice."','".$recordID."')";
mysql_query($sql_Query); }
}
Tuesday, April 6, 2010
Just a MySQL statement I need to remember
select count(distinct userName) from userTracking where timeStamp >= '2010-03-30' AND status LIKE '%Logged into $%';
counts unique userNames from userTracking between March 30th 2010 and now and looks for "Logged into $" in the status field.
and even better:
SELECT COUNT(DISTINCT userName) FROM userTracking WHERE timeStamp >= DATE(NOW()) - INTERVAL 11 DAY + INTERVAL 10 HOUR AND timeStamp <= DATE(NOW()) - INTERVAL 0 DAY + INTERVAL 10 HOUR AND status LIKE '%Logged into $%';
between 11 days ago at 10am and today at 10am.
counts unique userNames from userTracking between March 30th 2010 and now and looks for "Logged into $" in the status field.
and even better:
SELECT COUNT(DISTINCT userName) FROM userTracking WHERE timeStamp >= DATE(NOW()) - INTERVAL 11 DAY + INTERVAL 10 HOUR AND timeStamp <= DATE(NOW()) - INTERVAL 0 DAY + INTERVAL 10 HOUR AND status LIKE '%Logged into $%';
between 11 days ago at 10am and today at 10am.
Delete MySQL Records Older Than *BLAH*
DELETE FROM tableName WHERE columnName < DATE_SUB(NOW(), INTERVAL 14 DAY);
DAY
WEEK
MONTH
etc.
Thanks to:
http://benperove.com/
DAY
WEEK
MONTH
etc.
Thanks to:
http://benperove.com/
Subscribe to:
Posts (Atom)