Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

Insert script runs but data base gets no data

Would some one please debug this thing for me, I am lost as to why I cant get it to work. The form sends the data to the script, and the script than echo's back but its not adding the data to the server. Can you tell me where I have gone wrong.
*** Script ****

<?php

$conn=odbc_connect('nnxxnn','nnnn','nnnnnn');
if (!$conn)
  {exit("Connection Failed: " . $conn);}
  

$sql= "INSERT INTO log_driverlogs (mpp_id, log_date, total_miles, off_duty_hrs, sleeper_berth_hrs, driving_hrs, on_duty_hrs)
VALUES ('$_POST[mpp_id]', '$_POST[log_date]', '$_POST[total_miles]', '$_POST[off_duty_hrs]', '$_POST[sleeper_berth_hrs]', '$_POST[driving_hrs]', '$_POST[on_duty_hrs]')";

echo "Record added";

   odbc_close($conn); 
?>





*** Form ***
<form method="POST" action="insert_log_hours.php">
        <div align="left">
          <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="96%" align="left">
            <tr>
              <td width="50%"><font face="Verdana" size="2">
              &nbsp;Today's Date : </font></td>
              <td width="70%">
              <p align="left">&nbsp;<input type="hidden" name="mpp_id" size="15" value="<?php echo $_SESSION['SESS_DRIVER_ID'];?>">
              <input type="text" name="log_date" size="15" value="<?php echo date("Y-m-d"); ?>"></td>
            </tr>
            <tr>
              <td width="50%"><font face="Verdana" size="2">&nbsp;Off-duty 
              : </font></td>
              <td width="70%">
              <p align="left">&nbsp;<input type="text" name="off_duty_hrs" size="10">
              <font face="Verdana" size="1">ex: 10</font></td>
            </tr>
            <tr>
              <td width="50%"><font face="Verdana" size="2">&nbsp;Sleeper 
              Berth :</font></td>
              <td width="70%">
              <p align="left">&nbsp;<input type="text" name="sleeper_berth_hrs" size="10">
              <font face="Verdana" size="1">ex: 1.5</font></td>
            </tr>
            <tr>
              <td width="50%"><font face="Verdana" size="2">&nbsp;Driving 
              :</font></td>
              <td width="70%">
              <p align="left">&nbsp;<input type="text" name="driving_hrs" size="10">
              <font face="Verdana" size="1">ex: 11</font></td>
            </tr>
            <tr>
              <td width="50%"><font face="Verdana" size="2">&nbsp;On-duty 
              :<br>
&nbsp;</font></td>
              <td width="70%">
              <p align="left">&nbsp;<input type="text" name="on_duty_hrs" size="10">
              <font face="Verdana" size="1">ex: 1.5<br>
&nbsp;</font></td>
            </tr>
            <tr>
              <td width="100%" colspan="2">
              <p align="center"><font face="Verdana" size="1">Hours from the 
              above 4 fields&nbsp; <b><font color="#FF0000">MUST</font></b> 
              amount to 24<br>
&nbsp;</font></td>
            </tr>
            <tr>
              <td width="50%"><font face="Verdana" size="2">&nbsp;Total Miles <br>
              Driving Today<br>
              <br>
&nbsp;</font></td>
              <td width="70%">
              <p align="left">&nbsp;<br>
              <input type="text" name="T6" size="10"><br>
              <br>
        <input type="submit" value="Submit" name="B1">&nbsp; <input type="reset" value="Reset" name="B2"></td>

Open in new window

*** Script ****

<?php

$conn=odbc_connect('nnxxnn','nnnn','nnnnnn');
if (!$conn)
  {exit("Connection Failed: " . $conn);}
  

$sql= "INSERT INTO log_driverlogs (mpp_id, log_date, total_miles, off_duty_hrs, sleeper_berth_hrs, driving_hrs, on_duty_hrs)
VALUES ('$_POST[mpp_id]', '$_POST[log_date]', '$_POST[total_miles]', '$_POST[off_duty_hrs]', '$_POST[sleeper_berth_hrs]', '$_POST[driving_hrs]', '$_POST[on_duty_hrs]')";

echo "Record added";

   odbc_close($conn); 
?>





*** Form ***
<form method="POST" action="insert_log_hours.php">
        <div align="left">
          <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="96%" align="left">
            <tr>
              <td width="50%"><font face="Verdana" size="2">
              &nbsp;Today's Date : </font></td>
              <td width="70%">
              <p align="left">&nbsp;<input type="hidden" name="mpp_id" size="15" value="<?php echo $_SESSION['SESS_DRIVER_ID'];?>">
              <input type="text" name="log_date" size="15" value="<?php echo date("Y-m-d"); ?>"></td>
            </tr>
            <tr>
              <td width="50%"><font face="Verdana" size="2">&nbsp;Off-duty 
              : </font></td>
              <td width="70%">
              <p align="left">&nbsp;<input type="text" name="off_duty_hrs" size="10">
              <font face="Verdana" size="1">ex: 10</font></td>
            </tr>
            <tr>
              <td width="50%"><font face="Verdana" size="2">&nbsp;Sleeper 
              Berth :</font></td>
              <td width="70%">
              <p align="left">&nbsp;<input type="text" name="sleeper_berth_hrs" size="10">
              <font face="Verdana" size="1">ex: 1.5</font></td>
            </tr>
            <tr>
              <td width="50%"><font face="Verdana" size="2">&nbsp;Driving 
              :</font></td>
              <td width="70%">
              <p align="left">&nbsp;<input type="text" name="driving_hrs" size="10">
              <font face="Verdana" size="1">ex: 11</font></td>
            </tr>
            <tr>
              <td width="50%"><font face="Verdana" size="2">&nbsp;On-duty 
              :<br>
&nbsp;</font></td>
              <td width="70%">
              <p align="left">&nbsp;<input type="text" name="on_duty_hrs" size="10">
              <font face="Verdana" size="1">ex: 1.5<br>
&nbsp;</font></td>
            </tr>
            <tr>
              <td width="100%" colspan="2">
              <p align="center"><font face="Verdana" size="1">Hours from the 
              above 4 fields&nbsp; <b><font color="#FF0000">MUST</font></b> 
              amount to 24<br>
&nbsp;</font></td>
            </tr>
            <tr>
              <td width="50%"><font face="Verdana" size="2">&nbsp;Total Miles <br>
              Driving Today<br>
              <br>
&nbsp;</font></td>
              <td width="70%">
              <p align="left">&nbsp;<br>
              <input type="text" name="T6" size="10"><br>
              <br>
        <input type="submit" value="Submit" name="B1">&nbsp; <input type="reset" value="Reset" name="B2"></td>

Open in new window

0
GD_GRAY
Asked:
GD_GRAY
  • 3
  • 2
1 Solution
 
Ray PaseurCommented:
You must run the query.  These scripts only create the query string -- they do not call the data base engine.
0
 
Ray PaseurCommented:
What data base are you using?
0
 
GD_GRAYAuthor Commented:
SQL 2000
0
 
GD_GRAYAuthor Commented:
duh...

$rs=odbc_exec($conn,$sql);

thank you so much, I have been looking at this way to long......lol
0
 
Ray PaseurCommented:
Yeah, I completely understand. When you make the same omission about a hundred times it becomes really easy to spot!  Thanks for the points and good luck with it, ~Ray
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now