using mysql NOW() function to update row in database not working in PHP query

Kohl

I am trying to use the NOW() mysql function to update the datetime column for an inserted row. The datetime column is called 'transaction'. I tried finding a similar PHP function to mirror/mimic the datetime format but couldn't find one suitable.

 $purchase = query("INSERT INTO `Portfolio`(`id`, `symbol`, `shares`, `transaction`, `transType`) VALUES ((?),(?),(?),(?),(?)) ON DUPLICATE KEY UPDATE shares = shares + VALUES(shares)",$user,$symbol,$shs,NOW(),"BUY");
Marcin Nabiałek

You can use PHP date function:

date("Y-m-d H:i:s") 

to put current time

or you can not bind the parameter:

$purchase = query("INSERT INTO `Portfolio`(`id`, `symbol`, `shares`, transaction`, `transType`) VALUES (?,?,?,NOW(),?) ON DUPLICATE KEY UPDATE shares = shares + VALUES(shares)",$user,$symbol,$shs,"BUY");

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

PHP Mysql Update Query not working

From Dev

MySQL/PHP UPDATE query not working

From Dev

MySQL update DATETIME to NOW() using PHP

From Dev

MySQL update DATETIME to NOW() using PHP

From Dev

Update database using MySQL and PHP

From Dev

Selecting last row in database not working using PHP

From Dev

Update one row in MySQL using php PDO

From Dev

select next row in mysql database using PHP

From Dev

Common words used over thousands of row in MySQL Database using PHP (or query)

From Dev

Update MySQL database using php statement

From Dev

UPDATE query is not working php

From Dev

Php update query not working

From Dev

php UPDATE not working query

From Dev

UPDATE query is not working php

From Dev

Using external parameter in Mysql Database query in PHP

From Dev

Using external parameter in Mysql Database query in PHP

From Dev

AJAX update MYSQL database using function called from HTML generated from PHP

From Dev

AJAX update MYSQL database using function called from HTML generated from PHP

From Dev

MySQL UPDATE function is not working

From Dev

Returning a value 0 from a database row in PHP/MySQL after a query

From Dev

PHP - basic select query returning only the first row of mysql database

From Dev

Failing to update a row in mySQL database using Java no error message

From Dev

AND operator not working in a PHP function using MySQL

From Dev

Update blob image in Database with UPDATE MySQL using PHP

From Dev

Mysql UPDATE using PHP and AJAX, can't update database

From Dev

Update not working with php mysql

From Dev

mysql UPDATE query not working for image upload via php

From Dev

Comparing mysql password hashes using query row returning 0 (not working)

From Dev

Unable Update row in mysql database

Related Related

  1. 1

    PHP Mysql Update Query not working

  2. 2

    MySQL/PHP UPDATE query not working

  3. 3

    MySQL update DATETIME to NOW() using PHP

  4. 4

    MySQL update DATETIME to NOW() using PHP

  5. 5

    Update database using MySQL and PHP

  6. 6

    Selecting last row in database not working using PHP

  7. 7

    Update one row in MySQL using php PDO

  8. 8

    select next row in mysql database using PHP

  9. 9

    Common words used over thousands of row in MySQL Database using PHP (or query)

  10. 10

    Update MySQL database using php statement

  11. 11

    UPDATE query is not working php

  12. 12

    Php update query not working

  13. 13

    php UPDATE not working query

  14. 14

    UPDATE query is not working php

  15. 15

    Using external parameter in Mysql Database query in PHP

  16. 16

    Using external parameter in Mysql Database query in PHP

  17. 17

    AJAX update MYSQL database using function called from HTML generated from PHP

  18. 18

    AJAX update MYSQL database using function called from HTML generated from PHP

  19. 19

    MySQL UPDATE function is not working

  20. 20

    Returning a value 0 from a database row in PHP/MySQL after a query

  21. 21

    PHP - basic select query returning only the first row of mysql database

  22. 22

    Failing to update a row in mySQL database using Java no error message

  23. 23

    AND operator not working in a PHP function using MySQL

  24. 24

    Update blob image in Database with UPDATE MySQL using PHP

  25. 25

    Mysql UPDATE using PHP and AJAX, can't update database

  26. 26

    Update not working with php mysql

  27. 27

    mysql UPDATE query not working for image upload via php

  28. 28

    Comparing mysql password hashes using query row returning 0 (not working)

  29. 29

    Unable Update row in mysql database

HotTag

Archive