While I am by no means a programmer, I do get in touch with code every once in a while. Be it clumsy attempts in writing my own userscripts to customize dA, be it modding userscripts to further enhance and personalize my experience with websites like dA, be it copying lines of code off tutorial sites to enhance the experience of websites I create, be it HTML and CSS "code" when writing websites in the first place. But this is as far as it goes.
This few lines of code above I wrote while following a tutorial from 3D Buzz some time ago, trying to get into the php stuff a bit. What does it do? Simple, it's a webcounter, telling you how many people visited this page.
Info
Editor: UltraEdit-32 10.10b (with customized colours)
Visual Style: b0se Classic Final by ~b0se
This is a submission for and tribute to ~CodeIsArt
Ever tried using notepad++ rotane? my brother finds it extremely usefull and he's doing a degree in IT Management at the moment so should know exactly how this works more so than me
Very usefull code tho Perhaps adding on how long the page has taken to load might be a nice addon to this?
--
I am Rich aka Tricks found more or less everywhere artistic dA number #465,411 =deviantARTtimes Your weekly dA supplement!
Noo, I haven't even heard about it before, but it sure looks nice -- will check it out, mate, thanks for the hint. Say, is your brother on dA? If so, he might be interested in the ~CodeIsArt project..
And thanks, I'll see what I can do.
-- Paint deviantART green! - a skin for Firefox >:]
Unfort not and he's in his final year at uni so he's pretty busy with coding for fake websites for his course lol well actually real ones now i guess XD but ill pass on the msg for sure. and [link] link to notepad++ if you hadnt already googled it
--
I am Rich aka Tricks found more or less everywhere artistic dA number #465,411 =deviantARTtimes Your weekly dA supplement!
Doesn't look like a lot of code when you glance at it, but yet it creates a web counter which is pretty nifty. PHP is just too much for me and that's why I respect anyone that can get to grips with it - much like yourself.
Nice one hon
-- Zeta B. Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
I'm not personally an expert in PHP. There's a great deal of commands and tricks one can employ for ultimate compactness, but I think this code is lacking in personality. For example:
* Why define $query, when you could just put it into the function call?
* Why use a database, which can be unreliable, when a text file could suffice? Also, running two SQL queries every time the page is viewed puts unnecessary strain on the DB under heavy load.
* You could also use the session to remember a viewer and prevent them from racking up the count just by pressing refresh.
* Why kill the whole PHP page when an SQL error occurs for the page view counter? This seems over-kill when the rest of the page may work fine or not even use the database. I would place the counter in a function, and just exit the function on an error so that people could still use the site, even if the counter was not working.
* You shouldn't do "SELECT *" it's extra load on the server, always select just the fields you need.
* The second query could be built directly off of the first one, like thus:
$views=mysql_fetch_row(mysql_query("SELECT `num_views` FROM `counter`;",$connection))[0]++.";";
mysql_query("UPDATE `counter` SET `num_views`=$views;");
This would replace lines 6-13 with two lines, and I'm certain there's an even more compact way to do that in PHP.
Thanks very much for your time and effort to submit your code, I've enjoyed looking at it
Correction, that should be:
$views=mysql_fetch_row(mysql_query("SELECT `num_views` FROM `counter`;",$connection))[0]++;
mysql_query("UPDATE `counter` SET `num_views`=$views;");
I'll do my best to incorporate these into a possible future version, and then maybe make a direct comparison. Should be interesting. For now I can only say, I'm probably much more of a newb in PHP than you might think. But who knows, I'm always trying to learn.
Again, thanks!
-- Paint deviantART green! - a skin for Firefox >:]
I was thinking about this one, and I came up with an idea, where you could use the write functions to simply append a byte to a file, and then use the file size function to find out how many bytes long it was. As long as you used the session to only rack up the counter once per session, 2 million visits would only be 2MB, and you could add in a counter-reset after, say 10MB.
Daily Literature Deviations is a group that is dedicated to bringing literature to the forefront of the deviantArt community. We attempt to accomplish this by daily featuring Literature artists from around the community that deserve the recognition, but are not getting it.
Each day we will feature 10 deviations from the Literature categories in a News Article. In order to support the artists that we feature, we ask that you the news article as well as check out the individual pieces. We understand that each day you may not be able to check out each and every one of the pieces, everyone has their own things going on. We just ask that you make an attempt to help support the growing Literature community.
Daily Literature Deviations is a group that is dedicated to bringing literature to the forefront of the deviantArt community. We attempt to accomplish this by daily featuring Literature artists from around the community that deserve the recognition, but are not getting it.
Each day we will feature 10 deviations from the Literature categories in a News Article. In order to support the artists that we feature, we ask that you the news article as well as check out the individual pieces. We understand that each day you may not be able to check out each and every one of the pieces, everyone has their own things going on. We just ask that you make an attempt to help support the growing Literature community.
When it comes to community spirit, `Rushy is a shining example. From participating in devmeets, to providing positive encouragement to other artists, `Rushy can always be found demonstrating what it really takes to be a true deviant. It's without any hesitation that we are delighted to award the Deviousness Award for July 2009 to `RushyRead More
Devious Comments
Comments
Very usefull code tho
--
I am Rich aka Tricks found more or less everywhere artistic
dA number #465,411
=deviantARTtimes Your weekly dA supplement!
And thanks, I'll see what I can do.
--
Paint deviantART green! - a skin for Firefox
>:]
--
I am Rich aka Tricks found more or less everywhere artistic
dA number #465,411
=deviantARTtimes Your weekly dA supplement!
Yep, tried it already, looks promising!
--
Paint deviantART green! - a skin for Firefox
>:]
Nice one hon
--
Zeta B.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
* Why define $query, when you could just put it into the function call?
* Why use a database, which can be unreliable, when a text file could suffice? Also, running two SQL queries every time the page is viewed puts unnecessary strain on the DB under heavy load.
* You could also use the session to remember a viewer and prevent them from racking up the count just by pressing refresh.
* Why kill the whole PHP page when an SQL error occurs for the page view counter? This seems over-kill when the rest of the page may work fine or not even use the database. I would place the counter in a function, and just exit the function on an error so that people could still use the site, even if the counter was not working.
* You shouldn't do "SELECT *" it's extra load on the server, always select just the fields you need.
* The second query could be built directly off of the first one, like thus:
$views=mysql_fetch_row(mysql_query("SELECT `num_views` FROM `counter`;",$connection))[0]++.";";
mysql_query("UPDATE `counter` SET `num_views`=$views;");
This would replace lines 6-13 with two lines, and I'm certain there's an even more compact way to do that in PHP.
Thanks very much for your time and effort to submit your code, I've enjoyed looking at it
$views=mysql_fetch_row(mysql_query("SELECT `num_views` FROM `counter`;",$connection))[0]++;
mysql_query("UPDATE `counter` SET `num_views`=$views;");
I'll do my best to incorporate these into a possible future version, and then maybe make a direct comparison. Should be interesting. For now I can only say, I'm probably much more of a newb in PHP than you might think. But who knows, I'm always trying to learn.
Again, thanks!
--
Paint deviantART green! - a skin for Firefox
>:]
Previous Page12Next Page