Re: simple odbc/insert problem
| From: | LondonVibe | Date: | Mon, 20 Aug 2001 15:27:33 +0000 |
| Subject: | Re: simple odbc/insert problem | ||
| References: | 1 2 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-8956@lists.php.net to get a copy of this message | ||
"Erik H. Mathy" <erik@butlerandco.com> wrote in message
news:001d01c1298a$c45958e0$1300020a@erik_laptop...
> > new to php so be nice :)
>
> Always! ;)
>
> > win2k.... iis5.....ms access..
>
> Check...
>
> > // 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')";
> > // 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.");
> >
> > // execute SQL statement and get results
> > odbc_execute($sql_result) or die("Couldn't execute statement1.");
> >
> > odbc_free_result($sql_result);
> > odbc_close($connect);
>
> Off the top of my head, you might want to uncomment your sql_prepare
> statement.
>
> As it is:
>
> // 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.");
>
> As it should be:
>
> // 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.");
>
>
>
> Also, if that's not it...what errors are you getting, if any?
>
> Speaking for myself, I end up using odbc_exec() rather than the
combination
> of odbc_prepare()/odbc_execute(). Just a personal preference.
>
> You might want to toss in some data validation prior to the $sql
definition.
> It'll help insure you're not trying to insert bad/null values into your
> database.
>
> Hope this helps ya,
> - Erik
>
thx erik... i missed the first one (comment)... still get error... Couldn't
execute statement1 .... third not sure on the odbc_exec..