Jump to content

Philip

Staff Alumni
  • Posts

    4,665
  • Joined

  • Last visited

  • Days Won

    20

Everything posted by Philip

  1. Yes but session variables are being used for the overall login process. Someone who ha failed the authenication attempt could simply visit http://www.nwsim.com/index.php?action=logout and completly delete there session data. I need something that stores there IP in a database and stuff... Then if $Current_time >= 5 minutes deletes it. Or you could check to make sure a correct session (like user id) is in place before destroying the session, otherwise forward them back to the main page. DB would work too, to add onto what thorpe is saying, I would add in username, and have it lock that account, so you can't try to access that account on any computer for X minutes after X tries.
  2. Our of curiosity, what did you end up going with?
  3. Well, you're setting display_block to be the return value of require_once - which means it will return 1 on successful , 0 on a failure. I'd suggest you look a little more into how require/include works.
  4. You read my mind, with limitations of course. I admit that I have several version specific books - which do come in handy at times (better examples), but not as often as the online manual. As suggested, get programming design books to start off with, and look online for beginning tutorials and use the online manuals for any help regarding syntax.
  5. or..... on our site http://www.phpfreaks.com/tutorial/basic-pagination/
  6. Try running a different query there, like just "SELECT * FROM `forum_topics` LIMIT 5" and see if it returns anything.
  7. I'll try to think of one, I'm thinking in the WHERE clause to use IN... UPDATE `products` SET `price`= CASE WHEN `itemnumber`='PL1222' THEN `price` + 3.00 WHEN `itemnumber`='YX1222' THEN `price` * 4 END WHERE `itemnumber` IN ('PL1222' , 'YX1222') Try that, I'm pretty sure that's correct.
  8. Yes you can. Now, I will warn you, with the code I posted and the code you posted above, it will run for every row in the table (if it does not match the case's, it will just set the price to what it was) UPDATE `products` SET `price`= CASE WHEN `itemnumber`='PL1222' THEN `price` + 3.00 WHEN `itemnumber`='YX1222' THEN `price` * 4 ELSE THEN `price` END WHERE `itemnumber`IS NOT NULL (remember backticks ` instead of single quotes ' on col names)
  9. When you run it in something like PHPMyAdmin, what does it do?
  10. Change: $sql2 = "SELECT * FROM `forum_topics` WHERE `cid`='" . $row['id'] . "'"; echo $sql2; // Let's echo and see what it shows. $res2 = mysql_query($sql2) or die('Uh-oh, mysql error: '.mysql_error()); to $res2 = mysql_query("SELECT * FROM `forum_topics` WHERE `cid`='" . $row['id'] . "'") or die('Uh-oh, mysql error: '.mysql_error());
  11. Well, you also changed your code after I posted. However, the forum shouldn't be strip slashes from your posts. Nonetheless, make sure they are in there. Next step - what does the query echo out to? Can you run it in something like PHPMyAdmin? $sql2 = "SELECT * FROM `forum_topics` WHERE `cid`='" . $row['id'] . "'"; echo $sql2; Try replacing the code you posted with: } else { $sql2 = "SELECT * FROM `forum_topics` WHERE `cid`='" . $row['id'] . "'"; echo $sql2; // Let's echo and see what it shows. $res2 = mysql_query($sql2) or die('Uh-oh, mysql error: '.mysql_error()); if (mysql_num_rows($res2) == 0) { echo 'There no topics to display in this forum. <a href="./index.php?act=create&id='.$row['id'].'">Click Here</a> to create one. '; } else { echo '<table border="0" cellspacing="3" cellpadding"3"> '; echo '<tr align="center"><td>Title</td><td>User</td><td>Date</td><td>Replies</td></tr> '; while ($row2 = mysql_fetch_assoc($res2)) { #$sql3 = "count(*) AS `num_replies` FROM `forum_replies WHERE `tid`='".$row2['id']."'"; #$res3 = mysql_query($sql3) or die(mysql_error()); #$row3 = mysql_fetch_assoc($res3); echo '<tr><td><a href="index.php?act=topic&id='.$row2['id'].'">'.s($row2['title']).'</a></td><td>'.uid($row2['uid']).'</td><td>'.$row2['date'].'</td><td>'.$row3['num_replies'] . '</td></tr> '; } echo '</table> '; } } } else { echo 'Please supply a catergory ID.'; }
  12. Well, one problem I do see with your code, as seen with syntax highlighting... Things like: echo "There no topics to display in this forum. <a href="./index.php?act=create&id=".$row['id']."">Click Here</a> to create one. "; You need to either use single quotes (I recommend) or escape the quotes echo 'There no topics to display in this forum. <a href="./index.php?act=create&id='.$row['id'].'">Click Here</a> to create one. '; See the difference above? You have that all over the place.
  13. I believe your code would work but you need to add the end in. Here's another way... explained below: UPDATE `products` SET `price`= CASE WHEN `itemnumber`='PL1222' THEN '$5.00' WHEN `itemnumber`='YX1222' THEN '$6.00' ELSE THEN `price` END WHERE `itemnumber`IS NOT NULL Your code will just update the ones you need update (a select few.) Lets say you want to raise the price on everything, change ELSE THEN `price` to something like ELSE THEN `price`+1 (however, you'd have to & I strongly recommend changing your datatype and have PHP or whatever output add the $ on the numbers)*, or set it to a default value (like $2.00): ELSE THEN `price`='$2.00' Untested, but I believe it is correct. * - Changing the datatype from a varchar to something like decimal, would allow you to do math in your queries as well as in PHP. You can easily echo a dollar sign (like, echo '$'.$row['price']; ) In your case, I'd highly recommend looking into switching it [edit: added some formatting to text for easier reading]
  14. If you were updating the values to the same, it would be possible, using OR in the WHERE clause. However, since you're using multiple update values, I am 95% sure that you can't update multiple rows with different update values without using a CASE.
  15. A few things... I never saw that part, just the code. Why not just use COUNT()? Mind showing what $query="select * from groups where $q "; $query2 ="select * from groups where $q "; outputs? (echo both of those variables) I think count will take care of what you're trying to accomplish, but maybe I'm still unsure of what you're wanting to do
  16. Yup Limit is pretty handy
  17. Try using the LIMIT clause, SELECT `username` FROM `users` ORDER BY `registation_time` desc LIMIT 0,3 It'll grab the 4 most recent signups, depending on what type registation_time (timestamp, etc)
  18. Do you have access to PHPMyAdmin, or the like? I'd suggest running that query in there until you find what you're looking for. I'm not really sure what you're parameters of your search are, and how your DB is setup.... but I'm going to guess you meant (and as suggested above): select * from `groups` where `name`='$search_text' OR `name`='$q'
  19. What's this in your query? and $q I think you forgot the first part of and `col`='$q' ?
  20. So, does your query look like the following? UPDATE `listings` SET `expiration` = 0 , `expiration_sent` = 0 WHERE `id` = '$Ad_Number' AND `live` = '$Reset_By_Live'
  21. Why not just have the following on the included page: <?php $query = mysql_query("SELECT * FROM cms"); while($row = mysql_fetch_array($query)) //... ?> As stated, it's very bad practice including files inside a loop. Especially considering each new row you go through, you'll overwrite the variables.
  22. Try: mysql_num_rows instead of mysql_numrows and $result = mysql_query('SELECT * FROM images') or die(mysql_error()); instead of $result = mysql_query('SELECT * FROM images');
  23. Okay, I added in some comments. This is tested code... so, <html> <head> <title>Checkboxes</title> </head> <body> <?php // if it is submitted if(isset($_POST['Submit1'])) { // for loop, through each of the checkboxes for($i=1; $i<=15; $i++) { // get the variable name ready (ch#) $ch = 'ch'.$i; // if the checkbox is checked if(isset($_POST['ch'.$i]) && $_POST['ch'.$i]) $$ch = 'checked'; else $$ch = 'unchecked'; // tell us what it is! echo $$ch.'<br />'; } } ?> <FORM NAME ="form1" METHOD ="POST" ACTION =""> <Input type = 'Checkbox' Name ='ch1' value ="Question" <?PHP print $ch1; ?> >Has there ever been a period of time when you were not your usual self and... <P> <Input type = 'Checkbox' Name ='ch2' value="Question" <?PHP print $ch2; ?> >...you felt so good or so hyper tat other people thought you were not your normal self or you were so hyper that you got into trouble? <P> <Input type = 'Checkbox' Name ='ch3' value="Question" <?PHP print $ch3; ?> >...you were so irritable that you shouted at people or started fights or arguments? <P> <Input type = 'Checkbox' Name ='ch4' value="Question 4" <?PHP print $ch4; ?> >...you got much less sleep than usual and found you didnÕt really miss it? <P> <Input type = 'Checkbox' Name ='ch5' value="Question 5" <?PHP print $ch5; ?> >...you were much more talkative or spoke faster than usual? <P> <P> <Input type = 'Checkbox' Name ='ch6' value="Question 6" <?PHP print $ch6; ?> >...thoughts raced through your head or you couldnÕt slow your mind down? <P> <P> <Input type = 'Checkbox' Name ='ch7' value="Question 7" <?PHP print $ch7; ?> >...you were so easily distracted by things around you that you had trouble concentrating or staying on track? <P> <P> <Input type = 'Checkbox' Name ='ch8' value="Question 8" <?PHP print $ch8; ?> >...you had much more energy than usual? <P> <P> <Input type = 'Checkbox' Name ='ch9' value="Question 9" <?PHP print $ch9; ?> >...you were much more active or did many more things than usual? <P> <P> <Input type = 'Checkbox' Name ='ch10' value="Question 10" <?PHP print $ch10; ?> >...you were much more active or did many more things than usual? <P>...you were much more social or outgoing than usual, for example, you telephoned friends in the middle of the night? <P> <Input type = 'Checkbox' Name ='ch11' value="Question 11" <?PHP print $ch11; ?> >...you were much more interested in sex than usual? <P> <P> <Input type = 'Checkbox' Name ='ch12' value="Question 12" <?PHP print $ch12; ?> >...you did things that were unusual for you or that other people might have thought were excessive, foolish, or risky? <P> <P> <Input type = 'Checkbox' Name ='ch13' value="Question 13" <?PHP print $ch13; ?> >...spending money got you or your family into trouble? <P> <P> <Input type = 'Checkbox' Name ='ch14' value="Question 14" <?PHP print $ch14; ?> >If you checked more than one checkbox above, have several of these ever happened during the same period of time? <P> <P> <Input type = 'Checkbox' Name ='ch15' value="Question 15" <?PHP print $ch15; ?> >If you checked more than one checkbox above, have several of these ever happened during the same period of time? <P> <INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Press to Submit"> </FORM> </body> </html>
  24. Try this for your PHP: <?php if(isset($_POST['Submit1'])) { for($i=1; $i<=15; $i++) { $ch = 'ch'.$i; if(isset($_POST['ch'.$i]) && $_POST['ch'.$i]) $$ch = 'checked'; else $$ch = 'unchecked'; echo $$ch.'<br />'; } } ?>
  25. run <?php phpinfo(); ?> P.S. - it's phpversion(); Also, I am able to run the while loop on a 4.4.8 version. I think there is something else involved.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.