Jump to content

MatthewJ

Members
  • Posts

    803
  • Joined

  • Last visited

    Never

Everything posted by MatthewJ

  1. <?php session_start(); mysql_connect("*************", "*****************", "***************"); mysql_select_db("***********************"); $time = time(); //this checks to see if the $_SESSION variable has been not set //or if the $_SESSION variable has been not set to true //and if one or the other is not set then the user gets //sent to the login page if (!isset($_SESSION['username'])) { header('Location: http://***************.com/login.php'); } $query = "INSERT INTO messages VALUES( NULL, '". mysql_real_escape_string($_POST['message']) ."', '". $_SESSION['username']) ."', '$time' )";if( $result = mysql_query($query) ) { if(mysql_affected_rows() > 0 ) { echo "Message Posted.<br><a href='messageboard.php'>Return</a>"; } else { echo 'There was an error posting your message. Please try again later.'; } } else { echo "There was a database error."; // comment out next line for live site. echo "<br>Query string: $query<br>Returned error: " . mysql_error() . '<br>'; } ; Just take out the for field for username so they don't have to enter it, and that should do it.
  2. you're wanting to get the timezone from the client pc. In that case, you would need to use something like javascript. Obviously that would rely on users having javascript enabled.. not much of an issue these days.
  3. Well, now that I read the title a little closer I am even more confused. Echo the day from the db? You have no code for database access at all. Maybe I'm missing the point
  4. Wouldn't it be <select name="date_of_birth" id="date_of_birth"> <option value="">Day</option> <?php $isset = isset($_POST['date_of_birth']); for($day = 1; $day <= 31; ++$day) { echo '<option'; if ($isset && $_POST['date_of_birth'] === $day) { echo ' selected="selected"'; } echo ">{$day}</option>\n\t\t\t\t\t\t"; // Your dollar sign was outside the braces } ?> </select>
  5. Checkbox data should be in an array within post. <input type='checkbox' name='checkboxes[]' value='value1' /> <input type='checkbox' name='checkboxes[]' value='value2' /> <input type='checkbox' name='checkboxes[]' value='value3' /> Then you can just loop through the $_POST['checkboxes'] array From a usability standpoint... I'm not sure I would want to fill out a form with 1300 checkboxes
  6. Like snowman said... I would do something like that, but then use a scheduled task to run the script on an interval to check for and delete expired files.
  7. What if those same people disable javascript?
  8. I think the only problem with the original code was var js_var = "<?php =$php_var; ?>"; should be var js_var = "<?=$php_var; ?>"; The quick tag syntax was incorrect... not sure it needed the whole script echo'd, but if it works
  9. Hi all, I am trying to download a .zip file that is in a protected folder on an external server. If I put the URL directly to the .zip in the address bar and hit go, I am presented a basic http authentication popup for username and password (which I obv have). Could someone point me in the right direction on this one? I have tested and can download .zip files that are not protected with no problem, I guess I just need to figure out how to authenticate, then save the file in one process. Thanks for any and all help, Matt
  10. Why not just use something like Google Analytics?
  11. <?php $host="localhost"; $username="****"; $password="******"; $db_name="db"; $tbl_name="comment"; mysql_connect($host, $username, $password)or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $linkid=filter_input(INPUT_GET,'link'); $sql="SELECT * FROM $tbl_name WHERE linkid='$linkid'"; $result=mysql_query($sql); $row = mysql_fetch_assoc($result); $grejs=null; do { $grejs.="$row[0]"; } while(mysql_fetch_row($result)); echo $grejs; ?> Give that a try
  12. A php tag is not an html tag... IE: PHP tags <?php ?> Not <?php> <?>
  13. remove the header call and just echo $cid to make sure it has the variable to use in the header. Also, I don't know if it should matter, but I always concat the get var back on to the header url like header("Location: page.php?cid=".$cid) I know the var should be parsed since it's within double quotes, but with headers I've just always done it this way.
  14. So is your theory for the best way to get help to be a jerk? You're here looking for a solution to what is frankly a simple problem, and though you didn't have enough programming acumen to solve the issue yourself, you're bright enough to critique the code? Classic
  15. echo "<font color='000000'>No Service Found At<br /></font><font color='000000'>" . long2ip($ip) . "</font>";
  16. Do you have an item with an id of "2" in the database? Not just "there should be" but if you list all of the table contents, do you have an id=2?
  17. actually, the code highlighting threw me off, I thought you had closed out the string... it should work how you intend if the vars hold the right data, what does the output look like if you just echo it to the page (removing the dot of course)?
  18. $http.$ids . (dot) concatenates strings in php
  19. Maybe I'm just lost, but there seem to be any number of issues here... First: $common_words = array(" the ", " is "); There you are creating an array of two "common words" to replace... except you have spaces before and after them... but, when you explode the string to work on, you explode it on the space which effectively removes them. " the " and "the" are not the same string, so your replace is not going to find any matches. Not to mention you have a space at the beginning and end of the test string... so the first element of the exploded array is blank and useless. Then, your loop is going to run each word in the test string, and attempt to replace the matched words (again, they won't match.. so it won't replace anything and you will end up with an array of the same $title strings over and over with no change). Next, I'm not positive... but I think strtok() requires a token, it looks like you're trying to pass a set of three tokes, I'm not sure it works that way... so strtok is probably looking for .?! and is not finding it as that combination neverappears in the $text var. Last, you check the values (which need to be fixed first anyway I do believe) against $text... but you never do strtolower() on the $test var so "The" does not match "the" and so on as again, they are different strings. But again, it's early and I may be confusing myself
  20. MatthewJ

    num_rows

    $rCheckFirstLog = mysql_query($qCheckFirstLog) or die (mysql_error()); Try that, most obvious thing would be that the query is failing.
  21. Not really much of a question there Also, just an fyi... your sticky footer does not look right in Chrome (sits half out of the bottom of the page and forces a scrollbar for no reason). At least on the homepage... the other pages it seems to load okay.
  22. Sounds like you "need" a book on PHP...
  23. ..and don't get cocky with me. Nobody is under threat here. Well, you might be under threat of having a breakdown or having your ego put in check. Sometimes it is better to steer the asker in a better direction regarding something they didn't ask about, like the structure. You know why? Because a lot of people are sick to death of sloppy code and sloppy developers who haven't been told any better. Again, I guess I don't see the benefit in confusing the poster and still not correcting the original issue, but maybe that's just me
×
×
  • 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.