Jump to content

[SOLVED] Problems writing to MySQL database


ifis

Recommended Posts

I am trying to save information from a form in an 'Endorsementlog' table.  The only problem is that only the first option of "lic" will write to the database.  All the other options still work and set "lic" to whatever it is supposed to be, but will not write to the table.

echo "<form id='form1' name='form1' method='POST' action='endorsementform.php'>
    <p>
      <input name='firstName' type='hidden' id='firstName' value='$row[firstName]' />
   <input name='lastName' type='hidden' id='lastName' value='$row[lastName]' />
    </p>
    <p>Endorsement:<br />
      <select name='lic' id='lic'>
        <option>Pre-Solo Aeronautical Knowledge</option>
        <option>Pre-Solo Flight Training</option>

<?php
$today=date("Y/m/d");
$make=$_POST['make'];
$lic = $_POST['lic'];
$student=$_POST['student'];
$sex = $_POST['sex'];
$CFI=$_POST['CFI'];
$expireip=$_POST['expireip'];
$firstName=$_POST['firstName'];
$lastName=$_POST['lastName'];

include("endorsementlog.inc");
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

//write to instructor log
mysql_query("INSERT INTO $tbl_name (Username, Date, Student, Endorsement) VALUES ('{$_SESSION['myusername']}','$today', '$student','$lic')");

What am I doing wrong?

Link to comment
Share on other sites

Change it to:

<?php
$today=date("Y/m/d");
$make=$_POST['make'];
$lic = $_POST['lic'];
$student=$_POST['student'];
$sex = $_POST['sex'];
$CFI=$_POST['CFI'];
$expireip=$_POST['expireip'];
$firstName=$_POST['firstName'];
$lastName=$_POST['lastName'];

include("endorsementlog.inc");
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

//write to instructor log
mysql_query("INSERT INTO $tbl_name (Username, Date, Student, Endorsement) VALUES ('{$_SESSION['myusername']}','$today', '$student','$lic')") or die (mysql_error());

and tell us the error it produces.

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.