Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding the DateUploaded Time to MS SQL Database from PHP
    primarykey
    data
    text
    <p>After looking into it for a while I am struggling to use a hidden form field and a PHP MS SQL Query to add the date uploaded to the database when the data is submitted. Something similar to the MySQL NOW() function. Which I have tried and doesn't work. I also then tried the PHP date function. </p> <pre><code>&lt;input type="hidden" name="DateUploaded" value="&lt;?php date("d","m","y") ?&gt;"&gt; </code></pre> <p>With my upload looking like this:</p> <pre><code>&lt;?php $Title=$_POST['Title']; $Synopsis=$_POST['Synopsis']; $Article=$_POST['Article']; $DateUploaded=$_POST['DateUploaded']; $Deleted=$_POST['Deleted']; mssql_connect("*************", "*********", "*********") or die; mssql_select_db("DBName") or die; mssql_query("INSERT INTO DBTable (Title, Synopsis, Article, DateUploaded, Deleted) VALUES ('$Title','$Synopsis','$Article','$DateUploaded','$Deleted')"); Print "Your information has been successfully added to the database."; ?&gt; </code></pre> <p>Its just a simple test blog DB, however when I try this technique I get this error:</p> <pre><code>Warning: mssql_query() [function.mssql-query]: message: Conversion failed when converting character string to smalldatetime data type. (severity 16) in (File Path) on line 9 </code></pre> <p>I understand this is because im trying to put a string into a DB column set as smalldatetime. I was just wondering if there is a way around this that doesn't involve me having to change the data type in the DB? </p> <p>Any help would be appreciated. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload