Jump to content

cyberRobot

Moderators
  • Posts

    3,145
  • Joined

  • Last visited

  • Days Won

    37

Everything posted by cyberRobot

  1. If the function is needed for multiple pages on your website, then it would be a good idea to save the definition in an external file and import it as needed. Note that you would want to use require instead of include since the function is critical to the operation of the page. More information about require can be found here: http://php.net/manual/en/function.require.php
  2. The problem is caused by the function definition being made inside a loop. The code should work if you move the definition as mentioned by mac_gyver. You could try something like the following: <?php ini_set('display_errors', 1); error_reporting(E_ALL); include "include/session.php"; include('config.php'); $email = $_SESSION['mem_id']; function genQtyList($item_sold, $qtyMax = '$qty', $qtyMin = 1) { $html = "\n<select name=\"$item_sold\">\n"; for($i = $qtyMin; $i <= $qtyMax; $i++) $html .= "\t<option>$i</option>\n"; $html .= "</select>\n"; return $html; } ?>
  3. You shouldn't need to re-declare the function... Could you post the code which shows all the calls / decorations of genQtyList()?
  4. Which index is it referring to? The one for $_REQUEST...or the one for $sortOptions? To avoid this type of error, you could use isset(): $sort = (isset($_REQUEST['sort']) && isset($sortOptions[strtolower($_REQUEST['sort'])])) ? strtolower($_REQUEST['sort']) : 'name';
  5. Thinking about the problem some more, I have a feeling that there is some JavaScript attached to the form that's adding the action and method attributes for you. Did you make any changes to the open <form> tag after downloading script? When you submit the form, where does it go? Does it go back to the page where your form code is hosted? Or does it go to contact_me.php in the mail folder?
  6. The extra attributes would go in the following <form> tag: <form name="sentMessage" id="contactForm" novalidate> Note that the attribute order doesn't matter.
  7. Have you checked to see of $post->ID contains a value? How about get_the_ID(); does it return a value? Note that get_the_ID() needs to be called within The Loop. More information can be found here: https://codex.wordpress.org/Function_Reference/get_the_ID
  8. Congrats!
  9. Is it possible that one of the rules being triggered has the "stop processing more rules" option checked? Perhaps the user created their own rule...
  10. Ah...that would explain why it wan't in the PHP manual.
  11. Did you try running the error code suggested above? I have a feeling that the query is failing because the hashed password isn't surround by single quotes. Also, I'm fairly certain you can't run a PHP function inside a string. Try changing this $sql="SELECT * FROM login_admin WHERE user_name='$myusername' and user_pass=SHA('$mypassword')"; To this $sql="SELECT * FROM login_admin WHERE user_name='$myusername' and user_pass='" . SHA($mypassword) . "'";
  12. For what it's worth, the following page talks about the SHA functions not being suitable for passwords: http://php.net/manual/en/faq.passwords.php#faq.passwords.fasthash
  13. As ginerjm implied, $stmt->fetchAll() returns an array containing the result set...if there are any results. Otherwise, it returns false. More information can be found here: http://php.net/manual/en/pdostatement.fetchall.php
  14. Have you tried using mysql_error() to see if MySQL is throwing errors? More more information can be found here: http://php.net/manual/en/function.mysql-error.php
  15. For what it's worth, PHP has a built-in email validator. See Example 1 here: http://php.net/manual/en/filter.examples.validation.php
  16. Now you mentioned that the table is set to UTF-8. Are the columns where you're trying to save Russian characters set to utf8_general_ci also?
  17. Hmm...perhaps the characters were lost when the information was saved to the database. Note that PHP, HTML, and the MySQL connection object all need to be set to UTF-8. Perhaps the following will help: http://forums.phpfreaks.com/topic/296667-strange-character-when-insert/?do=findComment&comment=1513303
  18. Where are you trying to display the database contents? Are you using a PHP script to read the information from the database and display it to the screen?
  19. The following code works for me: <?php $link_add = "<a href='http://www.yahoo.com'>here</a>"; $message = "If you want to continue this transaction, please click " . $link_add; print $message; ?> Are you using a function like htmlentities() on $message before it's displayed? What does your echo statement for $message look like? Note: please surround your code with tags. It makes your post and code easier to follow.
  20. In addition to what fastsol said, the following line is only going to give you the number of records retrieved from your query: $total_records = mysqli_num_rows($rdata); //count number of records Since the query uses the LIMIT clause, $total_records is never going to be more than 8. To set $total_records, you could create a separate query that counts all the records in the "images" table.
  21. The htmlspecialchars() function is not meant to protect you from SQL injections. You'll want to use mysqli_real_escape_string() or prepared statements as suggested by Ch0cu3r. Note that the trim() function should be incorporated into the first option and stripslashes() isn't needed since PHP no longer automatically escapes things like POST and GET variables.
  22. Just to clarify, did you move the var_dump() function before the call to number_format()? Or did you just remove var_dump() altogether?
  23. Hmm...so var_dump() doesn't output anything? But the number_format() function appears to be working with something since your last attempt with var_dump() displayed string(6) "120.00" Could you copy and paste the exact code you used?
  24. Since the error seems to come from number_format(), you'll want to dump the variable before that function. Try this var_dump($prix); $prix = number_format ($prix, 2, '.', ' ');
  25. var_dump($prix); More information about the function (including examples) can be found in the manual: http://php.net/manual/en/function.var-dump.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.