PHP: What's wrong with this code?
<?php
$link = mysql_connect(\"localhost\",\"root\",\"\") or die(\"Connection Error: \".mysql_error());
mysql_select_db(\"thecofc_ama\",$link) or die (\"Database Error: \".mysql_error());
$result = mysql_query('INSERT INTO `sc_nom` (`stud`, `studnum`, `email`, `pres`, `vice`, `sec`, `treas`, `proe`, `proi`, `sgt`, `strep`, `ndrep`, `rdrep`, `datetime`)
VALUES (`$stud`, `$studnum`, `$email`, `$pres`, `$vice`, `$sec`, `$treas`, `$proe`, `$proi`, `$sgt`, `$strep`, `$ndrep`, `$rdrep`, NOW())',$link) or die(\"Query Error: \".mysql_error());
mysql_free_result($result);
mysql_close($link);
?>
You can try it out at http://thecofclub.distanthost.com/AMA/sc_nom.php
mairving posted this at 15:24 — 10th July 2003.
They have: 2,256 posts
Joined: Feb 2001
I stuck a line break in the code so that it wouldn't be quite so horizontal. The first major problem that it will try to submit values when the screen is refreshed. The second is that it has an unknown column 'stud'. This means that there is no column called 'stud' in that table. The other is that you will need to validate the form based on what are required fields and which are optional, else you will get some garbage entries.
Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states
friend_al_23 posted this at 15:39 — 10th July 2003.
They have: 15 posts
Joined: Jan 2003
I also tried using $_POST variables and still wouldn't work.
There is a stud column.
All are optional fields.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.