PHP and SQL I am trying to write some php to add new records to a .mdb file my code is as follows and i just cannot see why it isnt working..... ---------------------- <form action = "insertEx2.php" method = "post"> Description <input type = "text" name = "description“ /> Year <input type = "text" name = "year“ /> Country <input type = "text" name = "country“ /> Type <input type = "text" name = "Type" /> Theme <input type = "text" name = "Theme" /> <input type = "submit" name = "submit" value = "Add New Product“ /> </form> <? include 'ltdedition_ODBC.php'; // make db connection using ODBC DSN $desc = $_POST['description']; // store parameters in variables $year = $_POST['year']; $country = $_POST['country']; $type = $_POST['type']; $theme = $_POST['theme']; ******odbc_exec($conn, "INSERT INTO Limited_Edition (Description, Year, Country, Type, Theme) values('$desc', '$year', '$country', '$type', '$theme')") or die (odbc_errormsg()); odbc_close($conn); ?> i get the following error.....Data Type Mismatch on the line that is starred is it something to do with the fact that some of the data in the databases are integers and some are strings? what do i use in this section if that is the case? $desc = $_POST['description']; // store parameters in variables $year = $_POST['year']; $country = $_POST['country']; $type = $_POST['type']; $theme = $_POST['theme']; cheers for any help
Would it not just be the fact that the data your entering doesn't marry up with the data type of the database.. For example.. if year in your database has a data type of number and your trying to add text into it..
yeah thats what i think it is but i dont know what to change it to e.g. $year = $_POST['year']; year is probably an integer so what do i put instead of $_post ???
Just change the input type from "text" to "Number" or "Integer" Or change the data type in the database to "text"
read up on type casting in this context you may want to use (int)$_POST["year"]; fao chandler_90: input type="int" does not exist! secondly, why change the data type to text? surely that defeats the point of data types in the first place!
I was just giving him some options I'm only a n00b at this.. I thought that perhaps PHP might be like any other language I have learnt. Also.. just to make a point.. I have never been taught or even looked at PHP.. I am only now learning ASP. So there :strop: