-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
well the only error I see there is you forgot the ; at the end of your fetch_array ...
-
post the code where you're trying to do num_rows because the query string is valid (except for the fact that you said you want just 1, not 10, so it would be "...desc limit 1")
-
Well, I'm not going to rewrite your code for you, but I'll point some stuff out: - Why are you exploding $to, only to turn around and rebuild it into $go (nevermind the fact that you could have just made that into a loop)? - Checking if a variable is empty by using strlen is flawed in that it counts whitespace as a character. Instead, do something like if (isset($go) && (trim($go) != '')) { ... } - On that note, you are error checking each posted var individually. How about instead you put all that in a loop from the getgo, sanitizing and checking if empty etc.. all in one loop. - On top of all that, you do the same exact error checking for your form... there's really no reason why you need to be doing all this individually.
-
[SOLVED] fields sometimes populating from db, but not always.
.josh replied to jaydeesmalls's topic in PHP Coding Help
Not really the issue here, but why do you have: <select name="cm1a"> <option value="Monday"<?php if ($values['p1'] == "Monday") echo $values['p1']; ?>>Monday</option> <option value="Tuesday"<?php if ($values['p1'] == "Tuesday") echo $values['p1']; ?>>Tuesday</option> <option value="Wednesday"<?php if ($values['p1'] == "Wednesday") echo $values['p1']; ?>>Wednesday</option> <option value="Thursday"<?php if ($values['p1'] == "Thursday") echo $values['p1']; ?>>Thursday</option> <option value="Friday"<?php if ($values['p1'] == "Friday") echo $values['p1']; ?>>Friday</option> </select> You echo the vars instead of echoing 'selected="selected" like on your other ones. -
I see at least 4 places where you forgot a ; at the end of your line
-
[SOLVED] Trouble sorting a database query result
.josh replied to jeremyapp's topic in PHP Coding Help
Why are you trying to make php do the sorting? That's the whole point of databases... $query = $this->db->query("SELECT id, FirstName, LastName, City, State, District FROM info order by District"); -
Okay, well, if you really are wanting variables to be named what's in your comma separated list like that: <?php $to = "one,two,three"; // i need to split one,two,three into $list = explode(',',$to); foreach($list as $val) { $$val = $val; } // example: echo $one; // echoes 'one' ?> however... I have a sneaking suspicion that your list is of emails, right? Well that's not going to really work out with emails. So...why can't you use an array?
-
but what I'm telling you is that in your form you only have one thing being submitted...so..I don't really see what you're trying to make a comma separated list out of...in other words..what are you trying to explode? What data/variable/whatever are you working with? Because you haven't provided that...
-
Well I don't really see anything in your posted code to do that to, so...what do we have to work with to begin with?
-
Okay the next question I would ask is, what's wrong with using the cookie? Worried that someone might not allow cookies? You can pass the session id through the url or through hidden fields in a form as an alternative. Failing that, you can setup a temp file or temp db entries using the user's ip address to identify them. Failing that, you can use javascript to keep track of it. The trick here is not really making it cycle through your ads without repeating: it's keeping the user uniquely identified so you can cycle through your ads.
-
By taking half his brain and half your brain and smashing them together, but putting proteins in-between and around so they can work together but at the same time be oblivious of each other so the body doesn't reject the foreign tissue, as done in Man with the Screaming Brain. (I was pretty damn disappointed in that movie...I saw Bruce Campbell's name and thought it was gonna be awesome, but it sucked )
-
<a href = '#blah'>Jump to blah</a> <a name='blah'>blah blah blah</a>
-
well you could start out by showing what's inside your get_filel function...
-
Yes it's possible. You just did it. Pat yourself on the back and have a scooby snack. Hey, that rhymes.
-
How about we merge your brain with Barand's instead?
-
So..who else peed their pants? http://www.blizzard.com/diablo3/
-
Why do people always think they will receive better help by going some place other than the script/company's site? I mean seriously, if you honestly felt that way, then maybe you need to reevaluate using that script in the first place...
-
I think the first question I would ask is, are these ads supposed to be uniquely rotated to random visitors, or are they uniquely rotated to 'members' who are 'logged in' ?
-
Okay first off, Blade is right, the actual table name needs to be there instead of TABLE. But 2nd, you don't need 2 separate queries to do that. You just need the update query. I mean think about it. You're selecting totalhoursused where username = '$user' and assigning it to a variable (which btw you did wrong: you just assigned a result source to $current_hours). Then you turn around and take that current number and update the row, adding 1 to that variable where username still equals $user. So take out the select query, you don't need it. <?php mysql_connect('fdb1.runhosting.com', '126745_cdog', 'sports') or die(mysql_error ()); mysql_select_db('126745_cdog') or die(mysql_error()); $user = $_GET['user']; $hours = $_GET['hours']; if($user != null and $hours != null){ echo $user; mysql_query("UPDATE FlaxerAuthAndSig SET TotalHoursUsed = TotalHoursUsed+1 WHERE username = '$user'"); echo "/n added time"; } ?>
-
Hey yeah I been seeing that crop up a lot in people's posts recently. I wondered if that was some kind of forum glitch or if people were somehow being retarded and coding like that... edit: and yes, when I first quoted and posted this, it showed correctly, but when I edit/saved (didn't touch anything except the buttons) it's now bugged. edit edit: okay it doesn't seem to bug on the full modify button. It seems to only modify on the quick edit button on the bottom right of the post. If it's bugged, I can hit the full modify button and save (not pressing anything else) and it will fix it. But if I turn around and hit the quick edit and then save, it breaks again. So the moral of the story is that the quick edit button is bugged.
-
Assuming that your previous die(..) statements didn't echo any errors: - Add a die to your mysql_query see if it is returning an error for some reason. - Make sure table and column names are spelled right. - Echo out $user make sure it has what you expect it to have. - Make sure that there is indeed a username in the table called $user - Check your table in phpmyadmin or command line or w/e to see if it's updated there (because I don't see any code there that displays anything relevant)
-
Typing in caps, horrible misspelling and horrible grammar.. yeah that's a winning combination for a future coder...
-
okay well that's not entirely accurate: the foreach wouldn't return it that way. <?php $sql = "SELECT name, id FROM articles"; $run = mysql_query($sql); while($data = mysql_fetch_array($run)) { $list[] = $data; } foreach($list as $key => $val) { echo "key: $key val: $val <br />"; } $list would be a 2d array. each element on the first level would coincide with the row returned from your query. On the 2nd level, you will have a 2 element array: first element will be the numerical index, 2nd element will be the associative index. Both of them will hold the same value. so if you did a nested foreach loop: foreach ($list as $l) { foreach ($l as $key => $val) { echo "key: $key val: $val <br/>"; } } output would be: key: 0 val: John key: name val: John key: 0 val: James key: name val: James key: 0 val: Joe key: name val: Joe Hope that clears it up.
-
fetch_array returns both a numerical and associative array, so for example in his code he has a column named 'name'. So if we were to do this: <?php $sql = "SELECT name, id FROM articles"; $run = mysql_query($sql); while($data = mysql_fetch_array($run)) { $list[] = $data; } foreach($list as $key => $val) { echo "key: $key val: $val <br />"; } The output would look like this: key: 0 val: John key: name val: John key: 1 val: James key: name val: James key: 2 val: Joe key: name val: Joe // etc... As you can see, using fetch_array will return a merged numerical and associative array. fetch_row returns just a numerical array (0,1,2...) fetch_assoc returns just an associative array ('name' ...) And now for a bit of overkill: fetch_array accepts an optional 2nd argument to specify that you want just a numerical or associative array returned, making it in essence, just like fetch_row or fetch_assoc