-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
okay let's say you have a form with 5 checkboxes. If you want to know which check boxes were checked, make the checkbox names an array like blah[] but explicitly specify which element to use for each checkbox. example: [code] <form action = 'somewhere.php' method = 'post'> <input type = 'checkbox' name = 'blah[1]' value = 'value1'> something </br> <input type = 'checkbox' name = 'blah[2]' value = 'value1'> something </br> <input type = 'checkbox' name = 'blah[3]' value = 'value1'> something </br> <input type = 'checkbox' name = 'blah[4]' value = 'value1'> something </br> <input type = 'checkbox' name = 'blah[5]' value = 'value1'> something </br> <input type = 'submit' value = 'submit'> </form> [/code] You can even make a loop to generate $x amount of checkboxes with values; just add the loop counter inside the [] brackets so that it specifies an array element for each one. If you do it this way, if you for example only check box 4 and 5, you will get the following posted: $_POST['blah'][4] and $_POST['blah'][5] now you know which ones [i]were[/i] checked, by virtue of what array positions exist. ['blah'][1], ['blah'][2], and ['blah'][3] do not exist, but you know that the 4th and 5th check boxes were checked, because ['blah'][4] and ['blah'][5] do exist. Here is a little example script where you can see this in action to hopefully understand better: [code] <?php $someNumber = 6; if ($_POST['blah']) { foreach ($_POST['blah'] as $key => $val) { echo "checkbox # <b>$key</b> with value <b>$val</b> was checked.</br>"; } } echo "<form action = '{$_SERVER['PHP_SELF']}' method = 'post'>"; for($x = 1; $x < $someNumber; $x++) { echo "<input type = 'checkbox' name = 'blah[$x]' value = 'value$x'> value$x </br>"; } echo "<input type = 'submit' value = 'submit'>"; ?> [/code]
-
well then you are just going to have to go through and add a \ to all of your quotes then. And next time I suggest you be more consistent with your coding, instead of randomly using single or double quotes.
-
[code] $sql = "SELECT * FROM imageHeadlines WHERE userID = '{$_SESSION['id']}' AND id = '$imgID'"; [/code] p.s. - moving to sql forum.
-
you are treating regular variables as objects when they are not. You keep using $check as if it were an object of (I assume) some class inside db.php, when you didn't make it an object at all. You assigned a sql query result source to it. Then later on you use $db_object as (again, I assume) an object of some class inside db.php, but I don't see anywhere where you instantiated that either. Post the contents of db.php and we can help you out on what you should be using. p.s.- sylesia: it doesn't matter that he has the $_POST seperated from the string like that. That is okay. Kinda sloppy for my tastes, but whatever floats his boat. However, your suggested alternative is almost right. In order for php not to get confused with the single quotes, you need to throw some { } around $_POST['uname'] like so: [code] "SELECT * FROM users WHERE username = '{$_POST['uname']}'" [/code]
-
yes. if you do $blah = 'moreblah'; // with single quotes and try to throw in a quote in there, php will think you are closing the string. the backslash tells php to treat it as a regular character instead of a special character (something it looks for to do something...like close the string. if you do $blah = "moreblah"; // with double quotes you can use the single quote inside there, because php will not be looking for the single quote to close out the string.
-
Give the forms some color!!!!!!!!!
.josh replied to linkoovi's topic in PHPFreaks.com Website Feedback
<raises hand> well actually, i guess i was being rather sarcastic. So if by "attack" you mean answering a dumb question with sarcasm, then sure, I "attacked" you. It's nothing personal man. Put yourself in our shoes. That's like calling up your phone company and asking them to make the ring tones a lower pitch, to match barry white's voice more, just cuz you're into barry white. It's a silly question to ask. -
really? then what?
-
Give the forms some color!!!!!!!!!
.josh replied to linkoovi's topic in PHPFreaks.com Website Feedback
yes. let's cater to your windows tastes. Anyways... Don't you know using dark bg colors with light fonts hurts your eyes more? -
well if you have or can (easier) get gps coords for your cities (i guess you're talking about cities), you can use Pythagorean theorem to find the distance (a^2 + b^2 = c^2). dunno if that somehow helps you any, but i thought i'd throw that out there just in case...
-
Okay I have an off the wall question. Okay go to www.thesaurus.com okay now that you've been there you get the idea: enter in a word and it spits out a list of synonyms and antonyms, part of speech, and a short definition. Now what I am looking for is some kind of sql dump for thesaurus.com. I'm not so much interested in the definition or even the part of speech (though the part of speech might come in handy) as in the words themselves along with other words they point to. Does anybody happen to have one? Know where to get one? Not necessarily thesaurus.com's sql dump; just one for a thesaurus in general. I mean, I can work out the db structure myself just fine. And I can spend all day entering in the data manually just fine. I was just wondering if someone happened to have or know where to find that, offhand. Reason? One of my interests in life is patterns in language; the "art" of language, if you will. And I feel that having something like this to play with might be especially interesting. I suppose I could just pick up my thesaurus off my shelf and start entering stuff in manually..but that would really suck, lol.
-
::) you're back? geez, I thought we finally got rid of you permanently. j/k :P
-
Help with stupid error (mysql_num_rows)!!!!!!!
.josh replied to robcrozier's topic in PHP Coding Help
that sounds more like a bandaid than a cure. oh well good luck. -
Help with stupid error (mysql_num_rows)!!!!!!!
.josh replied to robcrozier's topic in PHP Coding Help
$result = mysql_query($query) or die(mysql_error() . " query: " . $query); post message. -
Alternating rows WITH hover color change? Is it possible?
.josh replied to alexcmm's topic in PHP Coding Help
you cannot make row colors change on hover with php. php is a server side language. everything is parsed on the server and then sent to the client (your browser). You can use php to alternate the colors, but you need to use javascript to make it change colors when you hover. -
example: [code] <?php class someClass { var content; function doSomething() { $lines = preg_split('/\r?\n/', $this->content); } // end function doSomething } // end class someClass $someThing = new someClass; //these 2 content variables are 2 different variables with 2 different scopes $someThing->content = "anything"; $content = "blah"; ?> [/code] $this->content specifies the $content variable in the class someClass. Your function doSomething is inside that class, so it's like saying "okay I need the variable $content. Which one? [i]this[/i] one, right here next to me. Oh okay, the one that holds 'anything' not that other one that holds 'blah' " when you are outside of the class, you can refer to it as the object->property, like where i had $someThing->content. When you are working inside the class, you can use $this->property, and it knows to refer to the property inside that class.
-
your not allowed to add your own script to check if someone is spam clicking ads or potentially spam clicking ads? That's just dumb. At the very least I would grab an IP address and a timestamp and keep a record of times in a certain period the IP address has accessed your page and if it is excessive, not show the ad or alter the code to break the link or something. Or even redirect the user to a custom page saying stop it. Even if that was against their policy, so what. If they are gonna take away your account over something you had no control over, then fair's fair. There's no way they can see your code or what you did unless they themselves decided to go spam click your google ads..in which case you'd be able to expose them for their shadiness.
-
actually, the problem is that you cannot use a WHERE clause at all in an INSERT query like that. The INSERT query inserts a new row into your table. End of story. If you are trying to add a new row to your table, then take off the where clause and you're done. If you are trying to edit a row, then you need to use UPDATE not INSERT like mysql_query("UPDATE paypal_sales SET viewed_online='$datename', viewed_online_by_ip='$ip' WHERE ....") or die(mysql_error()); now normally you would add ... WHERE $txn_id = $txn_id at the end there..but I don't think you've done that right ether. If you were to add that to the end, it would update every single row, because that condition would return true every time because you are comparing a variable to itself. I think what you probably wanted to do was ... WHERE txn_id_column_name_here = $txn_id
-
what you should have done is since you were #5 in line, you should have already setup or had someone set up an auction several days ago and had it running already.
-
How to develope my communication skill ???
.josh replied to sivanath.nagendran's topic in Miscellaneous
being on a computer doesn't help... -
..yeah barand.. i guess i see now what zanus means when he says i've got it backwards. oops. hahahhaa I did a play on words :) <is stupid 2.0>
-
then how come I can't do like... $crayonBot->uIecho(); or $crayonBot->userInteraction::uIecho(); i'm not getting it.. :(
-
Pass value from database field to PHP parameter
.josh replied to lucerias's topic in PHP Coding Help
[code] $someweight = 10; $sql = "select * from table where weight < $someweight"; $result = mysql_query($sql) or die(mysql_error()); while ($list = mysql_fetch_array($result)) { $rate = $list['rate']; $misc = $list['misc']; $other = $list['other']; } [/code] please note that if the query returns more than one result, the variables will be overwritten each time until the last pass of the while loop, resulting in only the last row being grabbed. If you are expecting only 1 row returned, then that's fine. If you are expecting more than one row to be returned, you should meke $rate, $misc, $other arrays like so: [code] $someweight = 10; $sql = "select * from table where weight < $someweight"; $result = mysql_query($sql) or die(mysql_error()); while ($list = mysql_fetch_array($result)) { $rate[] = $list['rate']; $misc[] = $list['misc']; $other[] = $list['other']; } [/code] or better yet just make one multi-dim array like so: [code] $someweight = 10; $sql = "select * from table where weight < $someweight"; $result = mysql_query($sql) or die(mysql_error()); while ($list = mysql_fetch_array($result)) { $info[] = $list; } [/code] -
*bump* anyone?
-
okay i'm (still) an oop noob. I'm just messing around trying to figure out how this whole class thing works. I guess I'm asking for a few pointers here, on how would I access the methods etc.. here's what my structure looks like so far: [code] <?php class ircBot { } // end class ircBot class serverInteraction extends ircBot { } // end class serverInteraction class userInteraction extends ircBot { function uIecho() { echo "this is an echo from userInteraction class!"; } // end function uIecho } // end class userInteraction class chatUserControls extends userInteraction { function cUecho () { echo "this is an echo from chatUserControls class!"; } // end function cUecho } // end class chatUserControls class adminControls extends userInteraction { } // end class adminControls class botAdminControls extends adminControls { function bAecho () { echo "this is an echo from botAdminControls class!"; } // end function bAecho } // end class botAdminControls class chatOperControls extends adminControls { } // end class chatOpercontrols $crayonBot = new ircBot; // okay now how would i echo each of those strings? ?> [/code]