problem with MYSQL INSERT table

Hi and Merry Christmas to all

I pretty inexperienced with all coding.

But trying to build a simple form utilising both radio buttons and textfields…

Unfortunately I cant get anything to INSERT into the MYSQL DATABASE table.

When I run the script below I get a message… Array
(
)

Not sure what this message is telling me as I cant seem to locate info it???

[code]

testform [/code] [php]<?php

$db_host = “localhost”;
$db_username = //“username”;
$db_pass = //“password”;
$db_name = //“databasename”;
$table = “test”;
@mysql_connect ("$db_host","$db_username","$db_pass") or die (“Check your stuff connection to MYSQL failed probably the db host as localhost is wrong”);
@mysql_select_db("$db_name") or die (“Didnt find that database”);
echo (“you’ve got the connection to this database”);
?>

<?php error_reporting(E_ALL); ini_set('display_errors', '1'); print '
';
print_r($_POST);

if (isset($_POST['rig'], $_POST['medication'])) {
    $rig = $_POST['rig'];
    $medication = $_POST['medication'];

    $sql = ("INSERT INTO tabletest (rig,medication) VALUES ('{$rig}','{$medication}')");
    $result = mysql_query($sql) or trigger_error("Query Failed! SQL: {$sql} - Error: ".mysql_error(), E_USER_ERROR);
  

}
[/php]

That message comes from:

print_r($_POST);

It’s simply displaying the $_POST array, but since your html form doesn’t exist, there is no $_POST data to display.

[code]OOPS!!!

Somehow i missed pasting the form code

try this.

[code

shorttest <?php include 'shorttest.php'; ?>

 

 

  </div></th>
  <td colspan="2" rowspan="2"><h1 align="center">RIG</h1>
    <label for="textfield"></label>
  <input type="text" name="rig" id="col2" /></td>
</tr>
<tr>
  <th scope="row"><div align="left">
    
  </div></th>
</tr>
<tr>
  <th scope="row">&nbsp;</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="col3" /></td>
  <td><input type="radio" name="medication" id="col3" /></td>
</tr>
<tr>
 
</tr>
 <tr>
  <th colspan="3" scope="row">
  <input type="submit" name="submit" id="submit" /></th>
</tr>
][/code]

I know its a bit messy… but just travelled and worked a total of 36hrs straight and too tired to tidy it up right now.

Can u see a problem other than the messyness???

you are missing values for the input of medication.

<input type="radio" name="medication" id="col3" value="WHAT THIS RADIO BUTTON STANDS FOR"/>
Sponsor our Newsletter | Privacy Policy | Terms of Service