Page 1 of 1

NEED HELP INSERTING TO DB

Posted: Wed Aug 27, 2003 7:35 am
by Mero
I am having serious problems although im sure the solution is relatively simple.

I am trying to insert lines into a db from a form, I keep getting this error>

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /usr/local/httpd/htdocs/do_addrecord.php on line 13


Here is the code I am using >

//putenv("ORACLE_SID=dbone");
putenv("ORACLE_HOME=/u01/oracle/product/9ir2");
$connect=ocilogon("kc_labs", "helpme", "dbone.linux");

$sql = "INSERT INTO KC_CAMPUS.ELECTRONIC_PARTS (PART_NUMBER, PART_CATEGORY, PART_NAME, PART_DESCRIPTION, PART_KIT, PART_LOCATION, PART_COST, PART_PAR) VALUES ('$_POST["PART_NUMBER"]', '$_POST["PART_CATEGORY"]', '$_POST["PART_NAME"]', '$_POST["PART_DESCRIPTION"]', '$_POST["PART_KIT"]', '$_POST["PART_LOCATION"]', $_POST["PART_COST"], $_POST["PART_PAR"]);


$stmt = OCIParse($connect, $sql);
OCIExecute($stmt);

Im using the $_POST["variable"] becuae I am using php 4.3.2 and as I understand, that is how to do it.

Any help is appreciated.

Posted: Wed Aug 27, 2003 8:51 am
by JayBird
try single quotes instead of double quotes

instead of $_POST["variable"]

try $_POST['variable']

Posted: Wed Aug 27, 2003 8:59 am
by Mero
Thanks man.

I did a $PNUM = $_POST["PART_NUMBER"]; on the receiving page, to cut down on some of my confusion.

The single ticks fixed it right up and i can add records now :) I knew it was something simple but this is my first time with php and im working on a linux box with oracle, they are trying to kill me i think....

Posted: Wed Aug 27, 2003 10:43 am
by JAM
To understand more, this post might come in handy, when dealing with single and double quotes.

Just a sidenote.