Jump to content

cyberRobot

Moderators
  • Posts

    3,145
  • Joined

  • Last visited

  • Days Won

    37

Everything posted by cyberRobot

  1. For some reason, you can't run the trim() function inside of empty(). Try something like this: $_POST['formName'] = trim($_POST['formName']); if(empty($_POST['formName'])) {
  2. You could give it a try, but you'll probably need to pass the connection link ($conn) to the function for it to work.
  3. Edit: array_map would process the values one index at a time. Have you tried calling the function directly? $row = function2($row['a'], $row['b'], $row['c']); The second argument for array_map needs to be an array. More information can be found here: http://php.net/manual/en/function.array-map.php You could try passing $row as is: $row = array_map("function2", $row); Of course, you would need to modify function2 to accept a single argument.
  4. In case it helps, a list of reserved words can be found here: http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html You could surround the reserved word with back ticks. $query = "SELECT * FROM student WHERE `group`='$go'";
  5. Try adding an exit statement after the error message. //This page should not be accessed directly. Need to submit the form. echo "error; you need to submit the form!"; exit; The rest of the script seems to be geared toward processing a form submission. So you don't want that code being executed if the page was accessed directly (without submitting a form).
  6. Assuming this is a WordPress website, the_post_thumbnail() displays the content directly to the screen. However, you could use get_the_post_thumbnail(). echo "<a href='" . get_the_post_thumbnail( 'medium' ) . "'><img src='" . get_the_post_thumbnail( 'thumbnail' ) . "'/></a>";
  7. The first argument is surrounded by single quotes. So the single quotes inside the first argument need to be escaped. It should look more like this: $preg_replace = preg_replace('__( \'From a WordPress user\', \'si-contact-form\' ) . \': \' . $current_user->user_login . self::$php_eol;', 'bar', $string); Note, however, that variables will not work inside single-quoted strings. With that said, I'm not sure what you are trying to accomplish with the first argument. The argument should only contain the text you want to replace. If you're looking to replace "WordPress", for example, the code should look more like this: $preg_replace = preg_replace('/WordPress/', 'bar', $string); Note that I added the delimiters for the regular expression in the first argument.
  8. preg_replace() isn't that much different than str_replace(). They both require at least three arguments. You need to tell the functions what you are looking for, what to replace it with, and provide the string(s) to perform the replacement(s) on. More information about preg_replace() can be found here: http://php.net/manual/en/function.preg-replace.php My recommendation would be to experiment with preg_replace() and/or str_replace() in a simpler context. Try to get it to work on a plain string, like in my earlier example. Once you understand how the functions work, you can start figuring out how they can be incorporated into your project.
  9. For what it's worth, you don't need to use regular expressions for this problem. A simple string replace should do the trick. Basically, you would take the string which contains the unwanted text and run it through something like str_replace(). Here's a quick example: <?php $user_info_string = 'From a WordPress user'; $user_info_string = str_replace('WordPress ', '', $user_info_string); echo $user_info_string; ?>
  10. Could you clarify by what you mean by "the url is wrong"? It looks like you're on the right track...assuming that the variables contain what you expect. Note that this is against the forum rules. You could try pasting the code for those interested in looking.
  11. Does your $row["Date"] variable contain the time of day? The two dates are probably less then a day apart based on time. You could try displaying the DateTime objects using something like this: $today = new DateTime("now"); $date2 = new DateTime($row["Date"]); print '<pre>' . print_r($today, true) . '</pre>'; print '<pre>' . print_r($date2, true) . '</pre>';
  12. You could look into using setTimeout() for the timer: https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout Then use submit() to submit the form: https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit
  13. Try adding a width to the "numstyle" div. div.numstyle { position: absolute; top:25%; left:28%;font-size:40px;clear:both; width:640px; }
  14. The bloginfo() function prints the result directly to the screen. So it needs to be called every time you want that value. However, you could assign the value to a variable by using get_bloginfo(). Then just use the variable wherever you want. More information can be found here: http://codex.wordpress.org/Function_Reference/get_bloginfo
  15. You could try something like this:
  16. Are you just wondering how to use the "file" variable? If so, you would use $_GET['file'] on the download page. More information about $_GET can be found here: http://php.net/manual/en/reserved.variables.get.php
  17. No problem, glad to help!
  18. Have you tried adding a WHERE clause? Basically, you only want the query to return a row if the maintenance column is set to 1. Maybe something like this: $pageMaintain = "SELECT maintainance FROM config WHERE maintainance=1";
  19. You could try changing the order: <?php if (isset($_POST['resetNOW'])) { if (isset($_POST['resetNOW'])){ testingMe(); echo "<br>You just entered " . $_POST['user']; echo "<br>You just selected " . $_POST['colourname']; } else{ echo "Nothing to see here"; } } elseif (empty($_POST['colourname'])) { pickacolour(); } elseif (!empty($_POST['colourname'])) { selectUser(); echo "You have selected " . $_POST['colourname']; } ?> Also, you don't need to check if "resetNOW" is set twice. Maybe something like this will work: <?php if (isset($_POST['resetNOW'])) { testingMe(); echo "<br>You just entered " . $_POST['user']; echo "<br>You just selected " . $_POST['colourname']; } elseif (empty($_POST['colourname'])) { pickacolour(); } elseif (!empty($_POST['colourname'])) { selectUser(); echo "You have selected " . $_POST['colourname']; } else { echo "Nothing to see here"; } ?>
  20. It looks like you're not passing the colorname through the second form (under selectUser()). Try adding a hidden field like the following: <input type="hidden" value="<?php echo $_POST['colourname']; ?>" name="colourname"> <td><input type=submit tabindex=1 value="Submit" name="resetNOW"></td></tr> Note that I added quotes around the attribute values. That way color names like "Dark Blue" will work. If you don't use quotes, browsers will only recognize "Dark" as the value...and they won't know what to do with "Blue". Also, note that using the raw value from PHP_SELF as the form's action opens your page up to XSS attacks. More information can be found here: http://seancoates.com/blogs/xss-woes
  21. What does the code look like for your forms? I have a feeling that "colourname" isn't being passed through the second form.
  22. Was that a test... Sorry, I moved the post. Unfortunately, I don't have the access privileges to look into your account.
  23. Yeah for me!
  24. It sure sounds like it As I mentioned earlier, $dbid is not define. So the following line of code creates the SESSION variable, but the value will be an empty string: $_SESSION['userid'] = $dbid; I imagine that you need to define $dbid like you did for $dbuser here: $dbuser = $row['username'];
  25. After the SESSION variables are set here: $_SESSION['userid'] = $dbid; $_SESSION['username'] = $dbuser; ...did you trying displaying them to the screen to make sure they contain the value you expect? You could try something like this: $_SESSION['userid'] = $dbid; $_SESSION['username'] = $dbuser; print '<pre>' . print_r($_SESSION, true) . '</pre>';
×
×
  • 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.