Re: php and oracle question

From: Gerard H. Pille <ghp_at_skynet.be>
Date: Thu, 16 Mar 2006 19:31:23 +0100
Message-ID: <4419ad8d$0$19097$ba620e4c_at_news.skynet.be>


Gerard H. Pille wrote:

> Steff wrote:
> 

>> Hello everyone,
>>
>> I've been wasting hours on this and I still don't know what's wrong
>> with my code.
>>
>> Can anyone tell me what misses in this code to make the insertion work?
>>
>> The set up of php apache and oracle is ok. I can select stuff from the
>> db.
>>
>> I keep on getting this message:
>>
>> Warning: oci_execute() [function.oci-execute]: ORA-00984:
>> a column name is not authorised here c:\pageWeb\test.php on line 13
>>
>> =========================================================
>> <html>
>>
>> <head>
>>
>> <title>test insert</title>
>>
>> </head>
>>
>> <body>
>>
>> <p>test insert into db</p>
>>
>> <p>&nbsp;</p>
>>
>> <p>&nbsp;</p>
>>
>> <form method="POST" action="test.php">
>>
>> <p><input type="text" name="vegy_name" size="20"><input
>> type="submit" value="insert" name="B1"><input type="reset"
>> value="reset" name="B2"></p>
>> </form>
>>
>> <p>&nbsp;</p>
>>
>> </body>
>>
>> </html>
>>
>> =========================================================
>>
>> <?php
>>
>> $veg=vegy_name;
>>
>>
>> $c1=oci_connect("stephane","Stef1975",$bdtest05);
>>
>> $query="insert into vegetables (name) values ($veg)";
>>
>> $stmt=oci_parse($c1,$query);
>>
>> oci_execute($stmt, OCI_DEFAULT);
>>
>>
>> oci_free_statement($stmt);
>>
>> oci_close($c1);
>>
>> ?>
>>
>> =========================================================
>>
>> thanks for looking!
>>
>>
> try this:
> 
> 
> $query="insert into vegetables (name) values ('$veg')";
> 
> 
> 
> But it would be much better to use a bind variable, I copied this from 
> www.oracle.com:
> 
> $q = "INSERT INTO teetimes (teetime, rate) VALUES (TO_DATE(:t, 
> 'yyyy-mm-dd hh24:mi'), :r)";
> 
> 
> // Parse the query.
> 
> $s = oci_parse($c, $q);
> 
> 
> // Bind the values.
> 
> oci_bind_by_name($s, ':t', $time, 16);
> oci_bind_by_name($s, ':r', $rate, 5);
> 
> 
> // Insert each record into the table.
> foreach ($teetimes as $time => $rate) {
> 
>     // Execute the query.
>     oci_execute ($s);
> 
> }
> 

you're welcome! Received on Thu Mar 16 2006 - 19:31:23 CET

Original text of this message