Page 1 of 1

[SOLVED] On to the next one...not updating in database...

Posted: Mon Jun 28, 2004 12:21 am
by FreeBaGeL
Moving along, I have a webpage that displays the contents of students at a university and their grades from an oracle database.

I've gotten it so I can select a row in the table of users and their grades and edit them, but when it "edits" them I have it redirected to the page where the grades were listed, and they haven't changed.

It SHOULD work, I've been staring at it for hours and can't figure out why it won't.

Here's the snippet of code.

Code: Select all

<?php

$S_ID=$_POST['student_id'];
$D_ID=$_POST["dtl_id"];
$PR=$_POST["points_received"];
$ANN=$_POST["annotation"];
$SD=$_POST["submission_date"];


$connect=OCILogon('username','password','orcl');

$query=OCIParse($connect,'update mgargano.student_grades set detail_id=$:bind1,points_received=:bind2,annotation=:bind3,submission_date=:bind4 where student_id=:bind5');
OCIBindByName($query, ":bind1", $D_ID);
OCIBindByName($query, ":bind2", $PR);
OCIBindByName($query, ":bind3", $ANN);
OCIBindByName($query, ":bind4", $SD);
OCIBindByName($query, ":bind5", $S_ID);

@OCIExecute($query,OCI_DEFAULT);
OCICommit($connect);
OCILogoff($connect);

$url = "http://www.cise.ufl.edu/~aantonio/Admin/Grades/grades.php"; // target of the redirect
$delay = "3"; // 3 second delay

echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
include('Header.html');
echo'<p>Database is being Updated. Please wait...;</p>';
echo'<p>Thank you for using Creation Inc.</p>';
echo $S_ID;
echo $PR;
?>

the names "student_ID," etc are defined in a form on the previous page that sends the data here. Note that when I print the variables $S_ID and $PR at the end of the script and run it, they are set to the values that I entered to edit with as they should, but the actual data in the database never changes.


feyd | switched

Code: Select all

to

Code: Select all

tag.[/color]

2 things real quick.

Posted: Mon Jun 28, 2004 1:34 am
by EricS
I've yet to work with an oracle database but I still may be of a little help.

In the following code:

Code: Select all

<?php
$query=OCIParse($connect,'update mgargano.student_grades set detail_id=$:bind1,points_received=:bind2,annotation=:bind3,submission_date=:bind4 where student_id=:bind5');
?>
Why is there a $ after detail_id= ?

Second in the following code:

Code: Select all

<?php
@OCIExecute($query,OCI_DEFAULT);
?>
You are suppressing the error return from OCIExecute. Try removing the @ from in front of the call and running it. This should aid you in finding the problem with your code.

Hope this helps.

Posted: Mon Jun 28, 2004 9:59 am
by FreeBaGeL
Ahhhhhhhhhhhhhhhhhhh thank you thank you thank you.

The turning the error checking back on really helped. Turned out I had accidentally had detail_id=:bind1 instead of dtl_id=:bind1.

dtl_id was the name I gave it but it stands for "detail ID" and that must've been what I was thinking in my head as I typed it out. Thanks.