Posts in 'Coding'
Coding:How to fetch user profile data with SSI.php from a SMF forum database
Posted on 20. Jul, 2009 by Dragos.
Even though SMF offers a way to integrate their forum into any website, they do not provide enough information on how to do some basic tasks, e.g. fetching a member’s profile details from the database. Fortunately, Netbeans has a very helpful feature, the code Navigator which shows an instant preview of all functions available in [...]
Continue Reading
Apache & ModRewrite: How to easily deny access to a folder with htaccess
Posted on 17. Jul, 2009 by Dragos.
Working on a project right now I was looking for a solution to protect a folder containing template php files (includes in larger files). One solution would be to chmod the folder to avoid external meddling of one’s curious eyes. But working with Apache’s features I found out that it is more convenient to use [...]
Continue Reading
PHP Error: Call to a member function fetch_assoc() on a non-object in
Posted on 23. Jun, 2009 by Dragos.
If you get this error: Call to a member function fetch_assoc() on a non-object in … , it means that you have an error in your mysql syntax. Supposing that $mysqli is your database connection object, put echo $mysqli->error; just before the line you’re getting the error on. $mysqli=new mysqli(HOST,USER,PASS,DB); $mQuery=$mysqli->query('select `data` from `this_table` where [...]
Continue Reading
JavaScript: How to get the index (position within a group) of an object with jQuery?
Posted on 20. Jun, 2009 by Dragos.
I’ve spent some time today figuring out how to obtain that index and finally I’ve just puzzled it out. Let’s say we have a group of objects all containing the class=”house”. Now if we are referencing to the first element within the group and we’d like to find out it’s index (well it’s obvious in [...]
Continue Reading
JavaScript: What if jQuery animation doesn’t fire/start?
Posted on 19. Jun, 2009 by Dragos.
I’ve been working on an image gallery (that I will publish here for all to see and use) and I ran into an issue that I’ve never experienced before: jQuery stopped firing the animation of an object. I looked at the expression, everything was fine. However not the expression was the problem, but the variables [...]
Continue Reading
Coding: Don’t make mistakes when resizing objects! Preserve the initial ratio correctly!
Posted on 17. Jun, 2009 by Dragos.
I was tempted many times to do quick adjustments to my code, without taking into consideration some basic mathematical principles. For examples if a box is first of all 100px tall and 60px wide, and then I notice that this box does not fit the place where it was intended to be placed, what I [...]
Continue Reading
PHP: Get all files and folders from a directory (folder)
Posted on 16. Jun, 2009 by Dragos.
To get all files and folders from a directory (folder) I found scandir to be the perfect solution. scandir scans a directory and returns an array containing all files and directories under the parent directory we’re looking in. The code below will try to remove a directory, if the element is a directory or delete [...]
Continue Reading
Coding: How to get code suggestions and function completion in Netbeans?
Posted on 15. Jun, 2009 by Dragos.
I was struggling myself in finding how to get the code suggestions feature work in Netbeans. I knew it was there and sometimes I accidentally triggered it, but I could never figure out what combination of keys I had to hit in order for the suggestions box to appear. So I decided to open a [...]
Continue Reading
Javascript: How to validate email address with JavaScript?
Posted on 13. Jun, 2009 by Dragos.
Here’s a piece of code I found while I was browsing the JQuery UI pages to easily validate email addresses. The code below represents a general validation function, that requires two parameters:1. the string value of an obkect and 2. the regular expression to check the string against function checkRegexp(o,regexp) { if ( !( regexp.test( [...]
Continue Reading
JavaScript: Get anchor from URL
Posted on 10. Jun, 2009 by Dragos.
To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: var url='http://iwebdevel.com/some-post#comment-1'; //if you need to take the current url of the window use: var url=window.location; var anchor=url.hash; //anchor with the # character var anchor2=url.hash.substring(1); //anchor without the # character If you’re [...]


