Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT query form not working.

Status
Not open for further replies.

cbhead

Technical User
Jul 31, 2002
31
0
0
GB
I have created a form to Insert new records into a mySQL db but it is not working.
I do not get any error messages returned but the new data is not getting to the database.

My form and code to process the form are in the same page.

The code is below:-

<html>
<head>
<title>Outline Vacancies test</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<body bgcolor=&quot;#FFFFCC&quot; text=&quot;#000000&quot;>

<?php

if($submit)
{

require( 'connect_jobs1.php' );

$sql=&quot;INSERT INTO allvacs (company) VALUES ('$company')&quot;;

$result=mysql_query($sql,$db);

echo &quot;Thank you! Information entered.\n&quot;;
}
else
{
?>

<form method=&quot;post&quot; action=&quot;insert_test.php&quot;>
<div align=&quot;center&quot;>
<h1> Graduate Vacancies update page
</h1>
</div>
<p align=&quot;left&quot;> <font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>Please enter
data into the boxes below:</font><br>

<p align=&quot;left&quot;><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>company</font>
<input type=&quot;text&quot; name=&quot;company&quot;>

<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Enter information&quot;>
<p align=&quot;center&quot;> 
</form></body>
<?
}
?>
</html>

I hope someone can help me with this.

Thanks.
 
and you get the message
&quot;Thank you! Information entered.\n&quot;;

when submitted ?


Is the key in the database set on autoincrement ?? or is company the keyfield ?
 
Yes, I get the message &quot;Thank you! Information entered.\n&quot;; ok.

ID is the primary key and is defined in mySQL as follows:-
`ID` int(11) default NULL,
So I don't think it is auto increment.
company is varchar(255)
 
the primary key should be put to autoincrement
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top