runthis
Members-
Posts
42 -
Joined
-
Last visited
Never
Everything posted by runthis
-
No, i solved the answer on my own, and it was involving forms in dynamically created objects. post=function(){ var params="username="+document.getElementById('username').value+"&password="+document.getElementById('password').value+""; new Ajax.Updater('LoadId', 'file.php', { method:'post', parameters:params,evalScripts: true }); }
-
Ok that was a bad answer, i am definitely looking for a better one than (dont use ajax) in a fucking ajax forum... anyone? Edit: actually that was an administrators answer..meh nevermind, ill figure it out myself or try another forum.
-
I don't agree with that. Heres a very good reason, jquery or other frameworks do not offer certain things i need to create, that require bare javascript (like the realtime password cracker for my game), for someone new to javascript this is bad, i will tell you why, when i go to create a project i utilize all the things i have learned in my years of programming, and with that knowledge i can create marvelous things. But when a new person starts learning javascript through jquery ... they will always program in the lines of what jquery can offer and never anything exciting or something never seen before. As a programmer of many years you must understand, of course it is comfortable for people like us to use a framework, because its not limiting our horizons, its speeding up our work.
-
I understand completely how to submit a form with ajax, my question is, how do you get the page its supposed to post to, to appear like an actual form does. Like im posting to 'boobs.php' in ajax i submit to boobs.php, but how do i get boobs.php to also be the resulting outcome, like an original form does? The old school way or with prototype.
-
For future users who will indefinitely find this page on some google search years from now as i always find a do, my program above is now solved thanks to the help of you guys, the finished product of my first leap into OOP is below <?php class Horse { public $strength; public $speed; public $agility; public $total; public function create($name,$age,$odds){ $this->name=$name; $this->odds=$odds; $this->strength=(rand(50,200) * $this->odds - $this->age); $this->speed=(rand(100,400) * $this->odds - $this->age); $this->agility=(rand(150,250) * $this->odds - $this->age); $all=array(0=>"$this->strength",1=>"$this->speed",2=>"$this->agility"); $this->total=($this->strength + $this->speed + $this->agility); echo "<b>$this->name</b> has a strength of <b>$this->strength</b>, a speed of <b>$this->speed</b> and agility at <b>$this->agility</b>. --- <b>".array_sum($all)."</b><br>"; } } $mix=rand(2,6); $a=new Horse; $a->create("Dave", 2, $mix); $b=new Horse; $b->create("Jack", 7, $mix); if($a->total > $b->total){ print "$a->name Won!"; }else{ print "$b->name Won!"; } ?> Easy cheezy
-
yay success, thats what i needed, you guys are great, sorry i was frustrated earlier i had just woke up
-
BIG SIGH Who cares if its the same horse instance, ill change it, HOW CAN I COMPARE THEM TOGETHER, how do i find out what horse 2's variables are, and use them like if horse 2 total > horse 1 total you said Please read my whole post, you literally said EXACTLY what the guy above me said, and didnt answer my reply to him. Should i explain im new to OOP, is getting the variables from a class outside of the class so easy everyone is confused on what i am asking? smaller less confusing for you guys, example class dude{ public $variable; public $variable2 function usethese(){ $this->$variable=25; $this->$variable2=100; } } how do i find the new value, not the null value, i tried things like $fuck= new dude; $fuck->usethese->$this->variable2; $fuck->usethese-->$variable2; $fuck->usethese--->variable2; $fuck--->variable2; $fuck->variable2; $differnt= new dude; $differnt->usethese->$this->variable2; $differnt->usethese-->$variable2; $differnt->usethese--->variable2; $differnt--->variable2; $differnt->variable2; if $fuck->usethese->variable2 IS BIGGER THAN, OR SMALLER THAN, OR USING PHP MAX TO FIND HIGHEST VALUE $dude->usethese->variable2 { do some stuff } I do not know how to get the variable outside of the class
-
No no no, look, even though you are both wrong and it creates BRAND new instances of horses, please read my post, how do i find out which horse one, even though u say im making the same horse with different names, it outputs Dave has a strength of 304, a speed of 796 and agility at 450. --- 1550 Dude has a strength of 238, a speed of 590 and agility at 380. --- 1208 Evan has a strength of 218, a speed of 410 and agility at 428. --- 1056 Jill has a strength of 104, a speed of 330 and agility at 302. --- 736 Flex has a strength of 140, a speed of 582 and agility at 414. --- 1136 So, seeing as dave won, how can i tell that dave won in my code, how can i rewrite it, if your saying im just calling my horse over and over and i need a whole new class per horse than whats the point of Object oriented programming, since that cant be the case, can someone else help besides those two guys above me Tha guy above me almost answered my question Ok great how do i access those properties of any of them, a specific one, all of them, what the code like $a->access-->thatvariable->onhorse->2 , thats literally my question How can i access these instantly created variables if this is too confusing, pretend there is only one horse, after creating him with my class and sending it to the page, how can i access the variable for his strength?
-
Ok, in the url are you actually referencing an id, like www.foobar.com/index.php?id=2 if so change your result variable to $result = mysql_query($query)or die(mysql_error()); and find the error, or reference get id as $query = "SELECT * FROM people WHERE ID ='{$_GET['id']}'"; tested and works for me, but i would suggest getting your $_GET variable out of the database call and make sure its a number only and not a sql injection, this can help as of php5 for the sql injection atleast $id = filter_input(INPUT_GET, ‘id’, FILTER_SANITIZE_STRING); then you would update the same, but replace $_GET[id] with $id
-
What does this syntax mean in PHP?? Do you know ?
runthis replied to aabid's topic in PHP Coding Help
So your saying it looks like class costStrategy{ function cost() { return $this->costStrategy->cost($this); } } ? instead of returning the value, try printing it and see what it says or what it affects -
I am trying something simple, creating some horses and making them race using OOP, creating them is easy, how can i find out which one "won" based on the highest total. Here is what i got so far <?php class Horse { public $strength; public $speed; public $agility; public function create($name,$age,$odds){ $this->name=$name; $this->odds=$odds; $this->strength=(rand(50,200) * $this->odds - $this->age); $this->speed=(rand(100,400) * $this->odds - $this->age); $this->agility=(rand(150,250) * $this->odds - $this->age); $all=array(0=>"$this->strength",1=>"$this->speed",2=>"$this->agility"); echo "<b>$this->name</b> has a strength of <b>$this->strength</b>, a speed of <b>$this->speed</b> and agility at <b>$this->agility</b>. --- <b>".array_sum($all)."</b><br>"; } } $mix=rand(2,6); $a=new Horse; $a->create("Dave", 2, $mix); $a->create("Dude", 3, $mix); $a->create("Evan", 3, $mix); $a->create("Jill", 15, $mix); $a->create("Flex", 10, $mix); ?> I cant figure out a way to find out who had the highest total, i would love to know what i am doing wrong.
-
ok fair enough, im not the best coder but this is how i would something off hand <? $get=$_GET['var']; mysql_query=("UPDATE thing SET field='var' WHERE id='1'"); ?> What would be the proper way sanitize that?
-
What is the best way to santize a user input What covers it all without leaving the text with slashes Do i just need to escape my variables, or no i need to sanitize my queries as well? Whats the whole kitten kaboodle, anyone?
-
Son of a b. i knew it was something utterly retarded, thats why it wouldnt let me use the from field either, right on, topic closed
-
ok im fairly good at php and for an HOUR i cant figure out my typo in this f*ck*ng shortest page ever $get=$_GET['id']; $qd2=mysql_query("SELECT to FROM newgamechat WHERE to='{$get}'"); while($rd2=mysql_fetch_array($qd2)){ print $rd2[to]; } When i change the "to" to anything else at all it works fine SELECT to FROM newgamechat WHERE id='{$get}'"); WTF am i dong wrong? The error is Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
-
Absolutely posted your example exactly
-
Actually tiztag and w3 are your best option right now to start, theyre website would have had your answer php.net can be confusing but helpful
-
Warning: preg_match_all() [function.preg-match-all]: Unknown modifier 't'
-
Couldn't agree more
-
Parse error: syntax error, unexpected '{'
-
okay, what i want is to grab all the link starting with "/stuff" and filter out everything else, thats what i meant sorry.
-
Ok, its all the same page. check it if($degree == 'bachelors'){ print "This is my bachelors degree information"; } if($degree == 'associates'){ print "This is my associates degree information"; } Get it? So the site does this, theres a list of links Home Degrees Contact You click "Degrees" and another link list Bachelors Associates You click "Bachelors" which opens the function page as stated above,m which again would (in its simplest form) look like this if($degree == 'bachelors'){ print "This is my bachelors degree information"; } if($degree== 'associates'){ print "This is my associates degree information"; } All that info can actually just be on one page by passing variables through the script or url.
-
<script type="text/javascript"> function hide(){ document.getElementById('hideme').style.display = 'none'; } function sethide(){ setTimeout("hide()",5000); } </script> <div onload=\"sethide()\" id=hideme>YOUR STUFF TO HIDE</div> will hide it within 5 seconds Should work ....
-
How would i add that to this <a\s[^>]*href=(\"??)(\/stuff[^\" >]*?)\\1[^>]*>(.*)<\/a>
-
<form method="post"> <select name=del> <option value=1>name1 email1</option> <option value=2>name2 email2</option> <option value=3>name3 email3</option> </select> </form> if(isset($_POST['del'])){ mysql_query("DELETE FROM tablename WHERE id='{$_POST['del']}'"); }