Jump to content

cyberRobot

Moderators
  • Posts

    3,145
  • Joined

  • Last visited

  • Days Won

    37

Everything posted by cyberRobot

  1. Does your real code have a query? As the code stands, $result is undefined. Have you tried turning on all PHP errors? To do that, you could add the following to your PHP script: <?php //REPORT ALL PHP ERRORS error_reporting(E_ALL); ini_set('display_errors', 1); ?>
  2. Try changing this date('h:ia', strtotime($row['date_played'])) To this: date('g:ia', strtotime($row['date_played'])) Note that I changed the "h" to "g". More information about the date() function can be found here: http://php.net/manual/en/function.date.php
  3. You could use strpos() to see if the string contains "abc" or "123": http://www.php.net/strpos
  4. You're using an assignment operator (=) instead of the comparison operator for equals (==). More information can be found here: http://www.php.net/manual/en/language.operators.comparison.php
  5. It looks like they are using the CSS "animation" property. More information can be found here: http://css-tricks.com/snippets/css/keyframe-animation-syntax/ To see the code used by Pinterest, you can right-click the background image in Chrome or Firefox and click "Inspect element". There should be a reference to "animation" or "webkit-animation" under the Styles/Rules panel.
  6. It might help if you provide a little more information. What do you mean by "it's not working"? Are you getting errors? If so, what are they? What have you tried to debug the issue? For example, have you checked if the database query returned anything? Have you enabled errors? Note that you can add the following snippet to the top of your script to show all PHP errors and warnings: <?php error_reporting(E_ALL); ini_set('display_errors', 1); ?>
  7. When the var_dump() code was added, did you check the box and submit the form? Something should have been displayed. Is there a reason you have two form fields with the same name? Have you tried removing the hidden field to see if that's what's causing the issue? If you're trying to make sure that "møtt" always has a value, you could employ Barand's suggestion. $møtt = isset($_POST['møtt'] ? $_POST['møtt'] : 0;
  8. Have you looked to see what the checkbox value contains? Try using var_dump() after you read in the POST variable for "møtt": $møtt=$_POST['møtt']; var_dump($møtt); You might also need to check the source code (when viewing the page in your browser) for the form to see if the checkbox is being assigned the proper value.
  9. Since your form hasn't been submitted, the POST variables for "registrerMottKnapp" doesn't exist yet. To fix the error, you need to change this: $registrerMottKnapp=$_POST ["registrerMottKnapp"]; To something like this: $registrerMottKnapp = (isset($_POST['registrerMottKnapp'])) ? $_POST['registrerMottKnapp'] : false; Personally, I would eliminate the extra variable ($registrerMottKnapp) and just do this: /* include("valider-mott.php");*/ if (isset($_POST['registrerMottKnapp'])) {
  10. Have you tried modifying your PHP script to show all errors and warnings? To do that, you could add the following lines of code to the top of your script: <?php error_reporting(E_ALL); ini_set('display_errors', 1); ?> You could also see if MySQL is throwing errors by using mysql_error() after each query. http://www.php.net/manual/en/function.mysql-error.php
  11. It looks like the first paragraph tag within the "entry" div tag on your page contains an image. If this paragraph tag contained text, the effect should work.
  12. Your checkbox name has a lower case "m": print("<input type='checkbox' name='møtt' value='$møtt'>"); But the code which processes the form submission uses and upper case "M": $møtt=$_POST["Møtt"];
  13. It looks like you're mixing up PHP and JavaScript. Here are a couple things that I noticed: JavaScript variables don't use the dollar sign. More information can be found here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Values,_variables,_and_literals The concatenation character for JavaScript is "+". More information can be found here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#String_operators
  14. Have you considered modifying you database? The script could keep saving the category ID to the database. You could then modify the scripts which utilize the "requisition" database table so they use a JOIN query to get the category name based on the ID. http://www.techonthenet.com/mysql/joins.php
  15. In the code which processes the form submission, you could add another query to get the category name based on the passed ID. Note that you'll want to make sure the ID is a number before running the query to prevent SQL injections. You could use ctype_digit() to check for numbers: http://www.php.net/manual/en/function.ctype-digit.php Alternatively, the form could be modified to pass the category name: <option value="<?php echo $cat_name;?>"><?php echo $cat_name; ?></option> Side note: perhaps you're already aware of this, but form information can be tampered with by the user. To prevent SQL injections, you can utilize mysql_real_escape_string(): http://www.php.net/mysql_real_escape_string
  16. I've been using a service called amCharts (http://www.amcharts.com/) which works fairly well. Note that I haven't spent much time with any other chart solution, so I can't speak to the pros/cons of the various services. If you want to avoid using third-party services and you're looking to create a bar graph, I wrote a post a while back which talks about a solution I've used in the past here: http://www.cyberscorpion.com/2012-08/simple-bar-graphs-made-dynamic-with-php/
  17. Strings can have either single or double quotes around them. However, double quotes are needed if the string contains something PHP needs to expand like a variable. More information about strings can be found here: http://www.php.net/manual/en/language.types.string.php I may have missed it, but I don't see where the OP (merpati) is using MySQLi. They all look to be regular MySQL functions. Of course, the OP should consider using something other than mysql_* functions since they are deprecated (http://www.php.net/manual/en/mysqlinfo.api.choosing.php). He/she may already be looking into that though. That's a good point. I would imagine that's supposed to be $run. @merpati - have you tried using mysql_error() to see if there are any SQL errors being reported? More information can be found here: http://www.php.net/manual/en/function.mysql-error.php
  18. Note that is_numeric() will consider the follow as numbers: 0x539 1337e0 9.1 To make sure the values only contain numbers, you can use ctype_digit(). http://www.php.net/manual/en/function.ctype-digit.php Also, it's worth pointing out that richei added a call to mysql_error() to the following line: $ins = mysql_query("INSERT INTO CodigoF (NOMBRE,PW) VALUES ($nombre, $pw)") or die(mysql_error()); This function should help determine if there's anything wrong with the query. More information about the function can be found here: http://www.php.net/manual/en/function.mysql-error.php
  19. I've been there. I tend to go straight to PHP for solutions. I've been learning, however, that MySQL has a lot to offer.
  20. No problem, the comment was more directed at gordonp. It kind of sounds like he/she is just starting out with database programming and it's easier to make the switch now vs down the road.
  21. Just in case you're not aware, the mysql_* functions have been deprecated. You'll be better off switching to MySQLi or PDO. More information can be found here: http://www.php.net/manual/en/mysqlinfo.api.choosing.php
  22. Are you able to adjust the query so it only fetches one result? You could do this with the LIMIT clause. https://www.google.com/search?q=sql+limit
  23. Assuming that visitors can check more than one "interest" box, you could process the selected values like this: if(isset($_POST['interest']) && is_array($_POST['interest'])) { foreach($_POST['interest'] as $currInterest) { echo "<div>$currInterest</div>"; } } Of course, you'll need to adapt the code to fit your needs. Note that I added an is_array() test to make sure the "interest" variable is an array before using the foreach loop. That way you don't get errors if the user decides to tamper with the data submitted.
  24. Note that the above code will give an undefined variable notice if you show all errors. Instead, you could use something like this: if(isset($_POST['interest'])) { //process the "interest" values here } When the POST variable is set, it should be an array as long as the corresponding checkboxes are named appropriately.
  25. You could store the image information in an array and then use array_rand() to get a random selection: http://www.php.net/manual/en/function.array-rand.php
×
×
  • 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.