This may be a simple problem but I cant find the answer.
I set up my table in an MySql InnoDB database but I can seem to get my
Select statment to Insert.
All my fields are varchar even the primary key as it needs to accept pd#### format.
I can retrieve info no problem so I dont think it is a connection difficulty.
Heres my code: sorry its a bit long but it I also suspect it could be a variable problem too. The html form action opens the following script. I also suspect that I need to use php extract fucntion to pass the variable. I have looked a several different books but they all use a number of different ways. A case of too much information
<?php
if ($_POST['submit'])
{
//connect to db
$hostname_connect = "localhost";
$database_connect = "newprelude";
$username_connect = "root";
$password_connect = "";
$connect = mysql_pconnect($hostname_connect, $username_connect, $password_connect) or trigger_error(mysql_error(),E_USER_ERROR);
// Retreiving Form Elements from Form
$fname = (trim($_POST['fname'])=="") ?
die ('ERROR: Enter a first name') : mysql_escape_string ($_POST['fname']);
$lname = (trim($_POST['lname'])=="") ?
die ('ERROR: Enter a last name') : mysql_escape_string ($_POST['lname']);
$tel = (trim($_POST['tel'])=="") ?
die ('ERROR: Enter a Phone Number') : mysql_escape_string ($_POST['tel']);
$role = (trim($_POST['role'])=="") ?
die ('ERROR: Enter your Role') : mysql_escape_string ($_POST['role']);
$pos1 = (trim($_POST['pos'])=="") ?
die ('ERROR: Enter your department') : mysql_escape_string ($_POST['pos1']);
$intro =(trim($_POST['intro'])=="") ?
die ('ERROR: Enter an Introduction') : mysql_escape_string ($_POST['intro']);
$proj1 =(trim($_POST['proj1'])=="") ?
die ('ERROR: Enter a Project Title') : mysql_escape_string ($_POST['proj1']);
$proj2 = (trim($_POST['proj2'])=="") ?
die ('ERROR: Enter a Project Title ') : mysql_escape_string ($_POST['proj2']);
$time1 =(trim($_POST['time1'])=="") ?
die ('ERROR: Enter a project duration') : mysql_escape_string ($_POST['time1']);
$time2 = (trim($_POST['time2'])=="") ?
die ('ERROR: Enter a project duration') : mysql_escape_string ($_POST['time2']);
$des1 = (trim($_POST['des1'])=="") ?
die ('ERROR: Enter a project decription') : mysql_escape_string ($_POST['des1']);
$des2 = (trim($_POST['des2'])=="") ?
die ('ERROR: Enter a project decription') : mysql_escape_string ($_POST['des2']);
$email = (trim($_POST['email'])=="") ?
die ('ERROR: Enter an email address') : mysql_escape_string ($_POST['email']);
$pdID = (trim($_POST['pdID'])=="") ?
die ('ERROR: Enter a file location') : mysql_escape_string ($_POST['pfile']);
$sqlQuery = "INSERT INTO consultant (fname, lname, tel, email, intro, pos1, role, proj1, proj2, time1, time2, des1, des2, pdID) VALUES ('$fname,$lname,$tel,$email,$intro,$pos1,$role,$proj1,$proj2,$time1,$time2,$des1,$des2``, '$pdID')";
$result = mysql_query($sqlQuery);
echo'New record inserted with ID'.mysql_insert_id().'<br>';
echo mysql_affected_rows().'recrd(s) affected' 0;
}
else
{ ?> html.................
I am greatful for any help.