Page 1 of 1

INSERT INTO statement not working

Posted: Tue Mar 03, 2009 1:40 pm
by nishmgopal
hey guys, My code seems to be working, it echos ther success message, but doesnt actually add anything to my database.

The code is:

Code: Select all

$projectname=$_POST['pname1'];
$java_skillset=$_POST['skill1'];
$cs_skillset=$_POST['skill2'];
$cp_skillset=$_POST['skill3'];
$net_skillset=$_POST['skill4'];
$php_skillset=$_POST['skill5'];
$t_skillset=$_POST['skill6'];
$l_skillset=$_POST['skill7'];
$p_skillset=$_POST['skill8'];
$c_skillset=$_POST['skill9'];
$score1=$_POST['score1'];
$score2=$_POST['score2'];
$score3=$_POST['score3'];
$score4=$_POST['score4'];
$score5=$_POST['score5'];
$score6=$_POST['score6'];
$score7=$_POST['score7'];
$score7=$_POST['score8'];
$score8=$_POST['score8'];
            
$query="INSERT INTO `conmg`.`Job_Spec` (`Project_Name` ,`Team_Work` ,`Leadership` ,`Java` ,`Communication` ,`Problem_Solving` , `C++` ,`C#` ,`.NET` ,`PHP MYSQL`) VALUES ('$projectname', '$t_skillset', '$l_skillset', '$java_skillset', '$c_skillset',
 '$p_skillset', '$cp_skillset', '$cs_skillset', '$net_skillset', '$php_skillset')";
 
 if (!$query) {
die('Data error ' . mysql_error());
}
echo 'Inserted successfully!'; 
?>
The code for the form where the information is coming from is:

Code: Select all

<form id="form2" method="post" action="do_addjob.php">
<table width="200" border="0">
  <tr>
    <td>Project Role Name</td>
    <td>Skill Set</td>
    <td>Required Score</td>
  </tr>
  <tr>
    <td><label>
      <input type="text" name="pname1" id="pname1" />
    </label></td>
    <td><label>
    <input name="skill1" type="text" id="skill1" value="Java" readonly="readonly" />
    </label></td>
    <td><label>
        <select name="score1" id="score1">
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
        </select>
    </label></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input name="skill2" type="text" id="skill2" value="C#" readonly="readonly" /></td>
    <td><select name="score2" id="score2">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input name="skill3" type="text" id="skill3" value="C++" readonly="readonly" /></td>
    <td><select name="score3" id="score3">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input name="skill4" type="text" id="skill4" value=".NET" readonly="readonly" /></td>
    <td><select name="score4" id="score4">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input name="skill5" type="text" id="skill5" value="PHP_MYSQL" readonly="readonly" /></td>
    <td><select name="score5" id="score5">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input name="skill6" type="text" id="skill6" value="Team_Working" readonly="readonly" /></td>
    <td><select name="score6" id="score6">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input name="skill7" type="text" id="skill7" value="Leadership" readonly="readonly" /></td>
    <td><select name="score7" id="score7">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input name="skill8" type="text" id="skill8" value="Problem_Solving" readonly="readonly" /></td>
    <td><select name="score8" id="score8">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input name="skill9" type="text" id="skill9" value="Communication" readonly="readonly" /></td>
    <td><select name="score9" id="score9">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><label>
      <input type="submit" name="button" id="button" value="Add Project" />
    </label></td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>
Thanks!
Please help.

Re: INSERT INTO statement not working

Posted: Tue Mar 03, 2009 2:22 pm
by ben.artiss
`PHP MYSQL` might give you some problems - is there supposed to be a space there? Try using an underscore instead and it may work :wink:

Re: INSERT INTO statement not working

Posted: Tue Mar 03, 2009 5:09 pm
by josh
Might help to execute the query with mysql_query()

Re: INSERT INTO statement not working

Posted: Wed Mar 04, 2009 2:40 am
by ben.artiss
Man i was slow last night - well spotted josh!