Category Archives: Programming
HTML Checkboxes
Occasionally, you discover something that you have been doing wrong for a long time. Sometimes it wasn’t something outright wrong but was just stupid. That is what happened to me. When using an HTML checkbox, it “POSTS” to the form submit page with the value of “on”. I have always converted that on the page… Read More »
PHP and jQuery – Reduce Long String to Preview Length and Reveal Full Text OnClick
Goal: Reduce long string to specified length for end-user preview. Reveal entire string when clicked. Go back to preview when clicked again. Check out the php and jQuery code: https://gitea.rnsworth.com/ben/PublicPosts/src/commit/b4f180878df7edc1b7ab71918d566736d619c87b/PHP%20and%20jQuery%20-%20Reduce%20Long%20String%20to%20Preview%20Length%20and%20Reveal%20Full%20Text%20OnClick.md YHTSZWNS7R6V
JSON Returning NULL When Special Characters Exist in Result Set
Nearly 24 hours of my life lost and I just figured this out. Maybe I can save someone else some precious time. Overview of JSON (skip this if you know what JSON is) When sending information from JavaScript via AJAX to a PHP server, certain things don’t transfer because you are dealing with different programming… Read More »
Finding Duplicate Records In Database
SELECT COL_TO_CHECK, COUNT(COL_TO_CHECK) FROM table1 GROUP BY COL_TO_CHECK HAVING COUNT(*) > 1 ORDER BY COUNT(*) If there is more than 1 column with that value it will show up like: COL_TO_CHECK COUNT(COL_TO_CHECK) ————————————————————- Value 3 Value2 2 Value99 4
C# Database Connections and Queries
Create connection string:SqlConnection conn = new SqlConnection(“Data Source=DATASOURCE\\\\SQLEXPRESS;Initial Catalog=DATABASE_NAME;Integrated Security=True”); try { conn.Open(); SqlCommand sql = new SqlCommand(“SELECT * FROM tableName”, conn); SqlDataReader reader = sql.ExecuteReader(); while (reader.Read()) { this.TARGET_ID.InnerHtml += reader[“column”] ; } } catch (SqlException sqle) { sqle.Message.ToString(); }
Droid ConnectBot – Unix SSH on the go!
Connect Bot I probably don’t need to sell any develpers on the advantages of being able to access your server while on the go. Once in a while you just have to. Programs like Astro, AndroZip, and ES File Explorer are ok for some things but what if you have to copy a gig worth… Read More »
PHP Ternary Operator – The "IF-Else" Shortcut
A ternary operator is a quick shortcut to bypass the multi-line if-else statement. It is sufficient when simple setting a value of a variable based on a condition. It looks like this: That is saying “if $variable equals 10 then set $x equal to true, otherwise set $x equal to false”. In a nutshell, condition?… Read More »
PHP explode and trim the results?
php.net – where I posted this Overview This is something that I used to use on this site before I went to WordPress. If you checked “view source” and looked at the meta keywords, you would notice a comma separated string. When programming, you may want to take a comma separated string and grab the… Read More »
JavaScript stripslashes
Sometimes you have to add slashes to javascript text. PHP has it built in, javascript does not. Here is the code to put into your javascript to get the same functionality: function addslashes(str) { str=str.replace(/\\\\/g,’\\\\\\\\’); str=str.replace(/\\’/g,’\\\\\\”); str=str.replace(/\\”/g,’\\\\”‘); str=str.replace(/\\0/g,’\\\\0’); return str; } function stripslashes(str) { str=str.replace(/\\\\’/g,’\\”); str=str.replace(/\\\\”/g,'”‘); str=str.replace(/\\\\0/g,’\\0’);… Read More »