• Web Development Questions That Don't Need Their Own Thread v2
    3,079 replies, posted
[QUOTE=kragmars102;33429592]-snip- Solved with: [code]$('input[type=file]').live('change',function() {[/code][/QUOTE] As of [B]jQuery 1.7[/B], the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live().
Oddly I couldn't get delegate to work..
Try [B].on()[/B].
in the <script type="text/javascript"> tag, how can I position it in the page? like by default it goes all the way to the left of the page and it's too high this is like my 4th stupid question, sorry i'm still really new at this
[QUOTE=Anti Christ;33428934]I'm working on a greasemonkey script, and I need to have a function that is only called when the user clicks a link (a link added by the script, not one on the page already). However, since greasemonkey doesn't work that way, what is a good work around? I was told to use window.localStorage, but I can only seem to store variables in it, and not functions. I'm still pretty new to javascript in general, so it's probably something easy, but if anyone can point me in the right direction, I'd really appreciate it.[/QUOTE] maybe if you stored the function in JSON and then put that in window.localStorage, and then parsed the JSON from localStorage when you need it and call the function?
[QUOTE=Dubbed Demon;33435389]how can I make a countdown timer that goes down to milliseconds and lower?[/QUOTE] It's not really possible in a browser.
[QUOTE=Ac!dL3ak;33435981]maybe if you stored the function in JSON and then put that in window.localStorage, and then parsed the JSON from localStorage when you need it and call the function?[/QUOTE] You can't store functions via JSON, any valid parser will reject them.
[QUOTE=TheDecryptor;33439078]You can't store functions via JSON, any valid parser will reject them.[/QUOTE] huh did not know this [editline]25th November 2011[/editline] couldn't you stringify the function and then evaluate the string then?
Yeah, you could store the function as a string and then eval() it when you need to, but that involves injecting the code to run the function (which was the original problem)
[QUOTE=TheDecryptor;33442630]Yeah, you could store the function as a string and then eval() it when you need to, but that involves injecting the code to run the function (which was the original problem)[/QUOTE] can't you put a <script> in the page that will be executed?
That would probably work, since the code would execute in the context of the page.
just a little thing that i'm unsure about if i create my own tags in html, and use css with them is that a bad thing? eg <red>text</red> | red{color:red;font-weight:bold;} am i doing it wrong
[QUOTE=Kwaq;33446354]just a little thing that i'm unsure about if i create my own tags in html, and use css with them is that a bad thing? eg <red>text</red> | red{color:red;font-weight:bold;} am i doing it wrong[/QUOTE] Yes. What you should do is: <div class="red">text</div> .red { color:red ; font-weight: 700; }
so it is best to use a div even for things like making text a different colour
[QUOTE=Kwaq;33446882]so it is best to use a div even for things like making text a different colour[/QUOTE] Yes. Or you could use a span.
No use span or make your divs inline [editline]26th November 2011[/editline] If you wanna use divs do display: inline; This causes divs to act like spans. The difference between divs and spans is that divs use Display:block and spans use display:inline; [editline]26th November 2011[/editline] Block display makes it so no other elements outside of the div be on the same line But that can be altered through positions and float.
looking for a cheap, stable and communicative web hoster for a small site/portfolio, anyone got some names i could check out?
[QUOTE=Haxxer;33450329]looking for a cheap, stable and communicative web hoster for a small site/portfolio, anyone got some names i could check out?[/QUOTE] [url]http://lithiumhosting.com[/url] REFERRAL link [url]http://www.lithiumhosting.com/billing/aff.php?aff=195[/url]
thanks bro, used yer referral
[QUOTE=Dubbed Demon;33435389]in the <script type="text/javascript"> tag, how can I position it in the page? like by default it goes all the way to the left of the page and it's too high this is like my 4th stupid question, sorry i'm still really new at this[/QUOTE] Why isn't this centered? [quote]<center><script type="text/javascript"> // NOTE: the month entered must be one less than current month. ie; 0=January, 11=December // NOTE: the hour is in 24 hour format. 0=12am, 15=3pm etc // format: dateFuture1 = new Date(year,month-1,day,hour,min,sec) // example: dateFuture1 = new Date(2003,03,26,14,15,00) = April 26, 2003 - 2:15:00 pm dateFuture1 = new Date(2011,11,03,15,0,0); // TESTING: comment out the line below to print out the "dateFuture" for testing purposes //document.write(dateFuture +"<br />"); function GetCount(ddate,iid){ dateNow = new Date(); //grab current date amount = ddate.getTime() - dateNow.getTime(); //calc milliseconds between dates delete dateNow; // if time is already past if(amount < 0){ document.getElementById(iid).innerHTML="Now!"; } // else date is still good else{ days=0;hours=0;mins=0;secs=0;out=""; ms = (""+((amount%1000)+1000)).substr(1,3); amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs days=Math.floor(amount/86400);//days amount=amount%86400; hours=Math.floor(amount/3600);//hours amount=amount%3600; minutes=Math.floor(amount/60);//minutes amount=amount%60; secs=Math.floor(amount);//seconds if(days != 0){out += days +" "+((days==1)?"day":"days")+", ";} if(hours != 0){out += hours +" "+((hours==1)?"hour":"hours")+", ";} out += mins +" "+((mins==1)?"min":"mins")+", "; out += secs +("."+ms)+" "+((secs==1)?"sec":"secs")+", "; out = out.substr(0,out.length-2); document.getElementById(iid).innerHTML=out; setTimeout(function(){GetCount(ddate,iid)}, 25); } } window.onload=function(){ GetCount(dateFuture1, 'countbox1'); }; </script></center>[/quote]
I have a problem with my php code. Even though the parameters are correct, it seems that it is not working. Here is the code: [code]<? ob_start(); ?> <? include('functions.php'); include('db.php'); //Revive Cookie. if(isloggedin()){ $sessionkey = $_COOKIE['sessionkey']; if($sessionkey){ setcookie("sessionkey",$sessionkey,time()+7200); $newtime = time()+7200; time = time(); $ip = $_SERVER['REMOTE_ADDR']; $con = qconnect(); mysql_select_db(DATABASE_NAME, $con); mysql_query("UPDATE sk_users SET ses_expire='$newtime' WHERE sessionkey='$sessionkey'", $con) or die(mysql_error()); mysql_query("UPDATE sk_users SET lastactive='$time' WHERE sessionkey='$sessionkey'", $con) or die(mysql_error()); mysql_query("UPDATE sk_users SET lastip='$ip' WHERE sessionkey='$sessionkey'", $con) or die(mysql_error()); } } echo isloggedin(); ?>[/code] The functions are: [code] function isloggedin() { $sessionkey = $_COOKIE['sessionkey']; $con = mysql_connect(DATABASE_ADDRESS, DATABASE_USER, DATABASE_PASSWORD) or die(mysql_error()); if(!$sessionkey) { return false; } elseif($sessionkey) { mysql_select_db(DATABASE_NAME, $con); $getses = mysql_query("SELECT ses_expire FROM sk_users WHERE sessionkey='$sessionkey'", $con); if(mysql_num_rows($getses) == 1) { while($row = mysql_fetch_array($getses)) { $sesex = $row['ses_expire']; if($sesex > time()) { return true; } else { return false; } } } else { return false; } } } [/code] [code] function qconnect() { $con = mysql_connect(DATABASE_ADDRESS, DATABASE_USER, DATABASE_PASSWORD) or die(mysql_error()); return $con; } [/code] It is supposed to renew the cookie and modify the 'session_expire' value for that use in the database, but only if the sessionkey from the cookie is correct.
[QUOTE=Dubbed Demon;33453247]Why isn't this centered?[/QUOTE] How do I cahnge the text size aswell?
dude, that's javascript..... You can't see javascript in a browser. [editline]27th November 2011[/editline] You're doing it wrong, you need to center the div, not the javascript itself. [editline]27th November 2011[/editline] so it would be like this: [code] <div align="center" id="iid">The Time</div> [/code] [editline]27th November 2011[/editline] To change text size: [code] <font size="2"><div align="center" id="iid">The Time</div></font> [/code]
[QUOTE=blackfire88;33453281]I have a problem with my php code. Even though the parameters are correct, it seems that it is not working. Here is the code: [/quote] use <?php not <? to open it that code is somewhat insecure, you should use PHP sessions not regular cookies. And please, format your code correctly: [php] function isloggedin() { $sessionkey = $_COOKIE['sessionkey']; $con = mysql_connect(DATABASE_ADDRESS, DATABASE_USER, DATABASE_PASSWORD) or die(mysql_error()); if(!$sessionkey) { return false; } elseif($sessionkey) { mysql_select_db(DATABASE_NAME, $con); $getses = mysql_query("SELECT ses_expire FROM sk_users WHERE sessionkey='$sessionkey'", $con); if(mysql_num_rows($getses) == 1) { while($row = mysql_fetch_array($getses)) { $sesex = $row['ses_expire']; if($sesex > time()) { return true; } else { return false; } } } else { return false; } } }[/php] edit: Weird, my browser isn't letting me make tabs in the reply box
sql injection
[QUOTE=zzlawlzz;33450426][url]http://lithiumhosting.com[/url] REFERRAL link [url]http://www.lithiumhosting.com/billing/aff.php?aff=195[/url][/QUOTE] Cool. How is their support?
Really good.
insta-reply
Anyone here any good with mysql? I have a task set whereby I need o calculate peoples age in a query using only their DoB, but were not using any proglamming language just pure sql commands and I have no idea how it would be done
[QUOTE=Richy19;33460245]Anyone here any good with mysql? I have a task set whereby I need o calculate peoples age in a query using only their DoB, but were not using any proglamming language just pure sql commands and I have no idea how it would be done[/QUOTE] Not sure but something like: YEARS( NOW() - DateOfBirth )
Sorry, you need to Log In to post a reply to this thread.