Re: simple odbc insert problem
| From: | Justin Buist | Date: | Mon, 20 Aug 2001 15:17:16 +0000 |
| Subject: | Re: simple odbc insert problem | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-11571@lists.php.net to get a copy of this message | ||
On Mon, 20 Aug 2001, LondonVibe wrote:
> new to php so be nice :)
>
> win2k.... iis5.....ms access..
>
> what is the order for adding var's to a access DB ??
> code i tried... with data from form don't work...
>
> // connect to system dsn odbc name login and password or die
> $connect = odbc_connect("DB","name","pword") or die (" not
> connected");
>
> $sql="INSERT INTO basket (Item,Amount,Price) Values
> ('$id','$amount','$price')";
Don't put single ticks around a field which holds numerical data... unless
you defined your primary ID as a text field (hope not) that's probably why
the query is bombing out.
> // prepare SQL statement
> //$sql_prepare = odbc_prepare($connect,$sql) or die("Couldn't prepare
> query.");
> // prepare SQL statement
> $sql_result = odbc_prepare($connect,$sql) or die("Couldn't prepare query.");
Okay, I've never written PHP to ODBC but making the same call twice and
assigning the values to different variables? One of us is confused...
> // execute SQL statement and get results
> odbc_execute($sql_result) or die("Couldn't execute statement1.");
>
> odbc_free_result($sql_result);
> odbc_close($connect);
Justin Buist
Trident Technology, Inc.
4700 60th St. SW, Suite 102
Grand Rapids, MI 49512
Ph. 616.554.2700
Fx. 616.554.3331
Mo. 616.291.2612