Jump to content

Mysql_Query("insert Into Tblworkf... Not Working?


Darkside

Recommended Posts

Hi all...

 

I cant seem to get data to INSERT INTO a table...

 

Tried everything that my very limited knowledge will let me think of.

 

Heres the code im using: Any suggestions greatly appreciated..

 

Q: I have a few rows in the table that I havent php coded for at this point in time... ie: "username" "password" will this effect the operation of INSERT INTO ?????

workfitnessform1.html

formtest1.php

Link to comment
Share on other sites

OK... heres the form html.

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

</head>

<?php include 'include/mysqlconnect.php'; ?>

<body>

 

 

<form action="workfitness.php" method="post" enctype="multipart/form-data" name="workfitnessform" id="workfitnessform"><H1> </H1>

<h3> </h3>

<table width="380" border="1">

<tr>

<th colspan="3" scope="col">Fitness</th>

</tr>

<tr>

<th colspan="3" scope="row"><p>XXXXXXXX</p>

</tr>

<tr>

<th width="287" scope="row"><div align="left">

<h3>FITNESS FOR WORK </h3>

</div></th>

<td colspan="2" rowspan="2"><h1 align="center">WHERE</h1>

<label for="textfield"></label>

<input type="text" name="rig" id="rig" /></td>

</tr>

<tr>

<th scope="row"><div align="left">

<h3>PRE WORK CYCLE QUESTIONNAIRE</h3>

</div></th>

</tr>

<tr>

<th scope="row"> </th>

<td width="72"><div align="center"><strong>YES</strong></div></td>

<td width="73"><div align="center"><strong>NO</strong></div></td>

</tr>

<tr>

<th scope="row"><p align="left">Are you presently taking any medication of any kind?</p>

</th>

<td><input type="radio" name="medication" id="yesmedication" /></td>

<td><input type="radio" name="medication" id="nomedication" /></td>

</tr>

<tr>

<th colspan="3" scope="row"><div align="left">

<p><FONT color="#FF0000"> IF YES,PLEASE LIST TYPE:</FONT>

 

<label for="medication type"></label>

<textarea name="medicationtype" id="medicationtype" cols="70" rows="5"></textarea>

</p>

</div>

<tr>

<th scope="row"><div align="left">Are you under any doctors recommendation in relation to work (<em>ie: Dr Certificate</em>) <em></em><font color="#FF0000">IF YES YOU MUST CONTACT PERSONAL MANAGEMENT BEFORE BORDING</font></div></th>

<td><input type="radio" name="doctor" id="yesdoctor" />

<label for="yesdoctor"></label></td>

<td><input type="radio" name="doctor" id="nodoctor" />

<label for="nodoctor"></label></td>

</tr>

<tr>

<th scope="row"><div align="left">Do you have stomache problems (Gastro) or Flu-like symptoms?</div></th>

<td><input type="radio" name="gastroflu" id="yesgastroflu" />

<label for="yesgastroflu"></label></td>

<td><input type="radio" name="nogastroflu" id="nogastroflu" />

<label for="nogastroflu"></label></td>

</tr>

<tr>

<th scope="row"><div align="left">Do you have a fever (<em>high body temperature)</em>?</div></th>

<td><input type="radio" name="fevertemp" id="yesfevertemp" />

<label for="yesfevertemp"></label></td>

<td><input type="radio" name="nofevertemp" id="nofevertemp" />

<label for="nofevertemp"></label></td>

</tr>

<tr>

<th scope="row"><div align="left">Are you suffering from a hangover?</div></th>

<td><input type="radio" name="hangover" id="yeshangover" />

<label for="yeshangover"></label></td>

<td><input type="radio" name="hangover" id="nohangover" />

<label for="nohangover"></label></td>

</tr>

<tr>

<th scope="row"><div align="left">

<p>Are you suffering from dehydration? </p>

</div></th>

<td><input type="radio" name="dehydration" id="yesdehydration" />

<label for="yesdehydration"></label></td>

<td><input type="radio" name="dehydration" id="nodehydration" />

<label for="nodehydration"></label></td>

</tr>

<tr>

<th scope="row"><div align="left">Have you been exposed to high temperatures during your time off?</div></th>

<td><input type="radio" name="temperature" id="yestemperature" />

<label for="yestemperature"></label></td>

<td><input type="radio" name="temperature" id="notemperature7" />

<label for="notemperature"></label></td>

</tr>

<tr>

<th scope="row"><div align="left">Have you ever suffered from heat exhaustion or heat stress symptoms?</div></th>

<td><input type="radio" name="heatstrees" id="yesheatstrees" />

<label for="yesheatstrees"></label></td>

<td><input type="radio" name="heatstrees" id="noheatstrees" />

<label for="noheatstrees"></label></td>

</tr>

<tr>

<th scope="row"><div align="left">In your personal opinion and given your health condition will you be able to efficiently undertake your work activities?</div></th>

<td><input type="radio" name="able" id="yesable" />

<label for="yesable"></label></td>

<td><input type="radio" name="able" id="noable" />

<label for="noable"></label></td>

</tr>

<tr>

<th scope="row"><div align="left">Do you spend your time off in a colder climate eg: NZ, Canada, or Northern Hemisphere?</div></th>

<td><input type="radio" name="colderclimate" id="yescolderclimate" />

<label for="yescolderclimate"></label></td>

<td><input type="radio" name="colderclimate" id="nocolderclimate" />

<label for="nocolderclimate"></label></td>

</tr>

<tr>

<th scope="row"><div align="left">I am aware and understand Fitness for Work, Alcohol and other Drug Policy</div></th>

<td><input type="radio" name="alcdrugpolicy" id="yesalcdrugpolicy" />

<label for="yesalcdrugpolicy"></label></td>

<td><input type="radio" name="noalcdrugpolicy" id="noalcdrugpolicy" />

<label for="noalcdrugpolicy"></label></td>

</tr>

<tr>

<th scope="row"><div align="left">Have you recently been in contact with someone with a contagious illness?</div></th>

<td><input type="radio" name="contagious" id="yescontagious" />

<label for="yescontagious"></label></td>

<td><input type="radio" name="contagious" id="nocontagious" />

<label for="nocontagious"></label></td>

</tr>

<tr>

<th scope="row"><div align="left"> Do you have a current Drivers Licence</div></th>

<td><input type="radio" name="licence" id="yeslicence" />

<label for="yeslicence"></label>

</td>

<td><input type="radio" name="licence" id="nolicence" /> <label for="nolicence"></label>

</td>

</tr>

<tr>

<th scope="row"><div align="left">I agree that typing my name the box below on this online form is equal to my signature. </div></th>

<td><input type="radio" name="sign" id="yessign" />

<label for="yessign"></label></td>

<td><input type="radio" name="sign" id="nosign" />

<label for="nosign"></label></td>

</tr>

<tr>

<th scope="row"><div align="left">Date

<label for="Date"></label>

<input type="text" name="date" id="Date" />

</div></th>

<td><label for="Date"></label></td>

<td> </td>

</tr>

<tr>

<th scope="row"><div align="left">Name

<label for="Name"></label>

<input type="text" name="name" id="Name" />

</div></th>

<td><label for="Name"></label>

<label for="Name"></label></td>

<td> </td>

</tr>

<tr>

<th colspan="3" scope="row"><div align="left">REVIEW COMMENTS (if any by the Manager)

<label for="Comments"></label>

<textarea name="Comments" id="Comments" cols="70" rows="5"></textarea>

</div> <label for="Comments"></label></th>

</tr>

<tr>

<th colspan="3" scope="row">Drivers Licence </th>

</tr>

<tr>

<th colspan="3" scope="row"><label for="Licence"></label>

<input type="file" name="licence" id="Licence" /></th>

</tr>

<tr>

<th colspan="3" scope="row"><label for="Licence"></label>

<input type="submit" name="submit" id="submit" /></th>

</tr>

</table>

</form>

</body>

</html>

 

 

and the php that goes with

 

 

<?php

$id = $_POST['id'];

$username = $_POST['username'];

$email = $_POST['email'];

$emailactivation = $_POST['emailactivation'];

$rig = $_POST['rig'];

$medication = $_POST['medication'];

if (isset($_POST['medication'])) {

$medication - $POST['medication'];

 

$medicationtype = $_POST['medicationtype'];

$doctor = $_POST['doctor'];

$doctorsorders = $_POST['doctorsorders'];

$gastroflu = $_POST['gastroflu'];

$fevertemp = $_POST['fevertemp'];

$hangover = $_POST['hangover'];

$dehydration = $_POST['dehydration'];

$tempexposure = $_POST['tempexposure'];

$heatstress = $_POST['heatstress'];

$able = $_POST['able'];

$colderclimate = $_POST['colderclimate'];

$alcdrugpolicy = $_POST['alcdrugpolicy'];

$contagious = $_POST['contagious'];

$sign = $_POST['sign'];

$licence = $_POST['licence'];

$date = $_POST['date'];

$name = $_POST['name'];

$comments = $_POST['comments'];

$file = $_POST['file'];

mysql_query("INSERT INTO tblworkfitness (id,username,email,emailactivation,medication,medicationtype,doctor,doctorsorders,gastroflu,fevertemp,hangover,dehydration,tempexposure,heatstress,able,colderclimate,alcdrugpolicy,contagious,sign,licence,date,name,comments,file)

VALUES ('".$id."','".$username."','".$email."','".$emailactivation."','".$rig."','".$medication."','".$medicationtype."','".$doctor."','".$doctorsorders."','".$gastroflu."','".$fevertemp."','".$hangover."','".$dehydration."','".$tempexposure."','".$heatstress."','".$able."','".$colderclimate."','".$alcdrugpolicy."','".$contagious."','".$sign."','".$licence."','".$date."','".$name."','".$comments."','".$file."')");

 

 

 

?>

Link to comment
Share on other sites

Well first off, this is pointless

$medication = $_POST['medication'];
if (isset($_POST['medication'])) {
$medication - $POST['medication'];

 

And second if you had error reporting on you would see a syntax error of unexpected $end because you aren't closing your if() { with a }

Link to comment
Share on other sites

Let's say that $_POST['medication'] contains the value of 1. Your code would then look like this:

x = 1;
if (x != 0) {
   x - 1;

Not only are you subtracting the value from itself, but you're not even storing the result. Which means that the operation was, indeed, quite pointless.

 

Also, if it's not set, then you've already tried to use it before checking, rendering the check rather useless as well. Move the check above the first instance where you try to use $_POST['medication'], to make sure that it really is set before you try to use its value.

 

As for the error reporting bit, please read this article.

 

PS: Please use the [code][/code] tags around your code, as it helps make both your post and your code a lot easier to read.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.