Jump to content

trq

Staff Alumni
  • Posts

    30,999
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by trq

  1. Have you got a mail server installed on localhost?
  2. No it's not. It actually makes more sense because you know where the variables are coming from. Using globals, you have some variable magically appearing within your function.
  3. Using globals in a function is never a good idea and you wouldn't want to pickup a bad habit. Functions have there own scope for a reason.
  4. Have you tested that your script actually executes? Have it write a file or write to a log or something so you can check. Godaddy might not even support the .forward file depending on there setup.
  5. This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=353212.0
  6. Why: Because currently your functions relie on the variable $yhteys existing outside of the function. This means you cannot reliably reuse these functions in some other project. How: function fetchRow($pdo, $id) { $kysely = $pdo->prepare("SELECT * FROM kampanjat WHERE id = ? LIMIT 1"); $kysely->execute(array($id)); return $kysely->fetch(); } Looking closer at your functions they aren't reusable anyway because they also relie on a specific table existing in the database.
  7. Your already using them. For instance, to pass an $id into your fetchRow function.
  8. Just pass $yhteys in as an argument. And while your there, name it something like $pdo, it is more meaningful than $yhteys.
  9. Functions accept arguments. If you need something from outside a function within a function you should pass it in. You completely break reusability otherwise.
  10. trq

    Option

    You should read this.
  11. Three things. Indent your code properly, don't use the global keyword and name your variables something more descriptive.
  12. What? You haven't told us what the issue is.
  13. ps: Your script is not a "cron". While it might be executed by cron, it has nothing to do with cron.
  14. No they wouldn't. In a method maybe, but not a class.
  15. This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=353182.0
  16. One of the main advantages of Ajax is that you don't need to refresh an entire page to change the data on the page. What exactly are you trying to do?
  17. You would access the value by it's index. There are examples of this in my previous reply.
  18. You will need to store your quantities of pizzas made in a database or something and then use simple math to add and subtract. There are literally thousands of examples of how to insert and select data from a database using php already on the web. I suggest you find one and have a go. As far as the math is concerned, if you don't yet understand how to add and subtract, I suggest you forget about learning php for a while and start school over again.
  19. Array keys are just strings. You can put pretty much whatever you like in there. $a = array('^$r%9)k!!~`}+0h*' => 'foo'); is perfectly valid.
  20. $_POST['pay'] is obviously not an array. Is that the name of your submit button or something? Use a for loop. for ($i = 0; $i <= count($_POST['product']); $i++) { $product = mysql_real_escape_string($_POST['product'][$i]); $price = mysql_real_escape_string($_POST['price'][$i]); $qty = mysql_real_escape_string($_POST['qty'][$i]); $id = mysql_real_escape_string($_POST['id'][$i]); $total = mysql_real_escape_string($_POST['total'][$i]); }
  21. What's the problem exactly?
  22. Obviously not very well. foreach is a simple construct. foreach ($_POST['products'] as $product) { // do something with $product }
  23. *What* do you want displayed in a foreach loop? And *what* array do you wish to loop through? Seriously, your question makes little sense.
×
×
  • 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.