Help with multiple queries

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pinzasso
    New Member
    • Aug 2007
    • 4

    #1

    Help with multiple queries

    The second query works fine by itself, so why doesn't it work when the first query is in front of it and the else is triggered?
    still spits out the print with no errors.

    [PHP]
    <? include("dbconn ect.php");
    $result = mysql_query("SE LECT CTRL_NUM "
    . "FROM inventory "
    ."WHERE CTRL_NUM = $_POST[ctrl_num] ");

    $res = mysql_fetch_arr ay($result);

    if( $_POST[ctrl_num] = $res[0])
    {

    print ("Record could not be added."); print ("Item already exists.");

    }
    else
    {
    mysql_query ("INSERT INTO inventory (CTRL_NUM, PART_NUM, SHELF_BIN, UNIT_ISSUE, PART_TYPE, WHSE, VENDOR, MANUFACTUR, SYSTEM, DOM, SUB_SYS, validation, Repairstat, QAstat)
    VALUES ('$_POST[ctrl_num]', '$_POST[part_num]', '$_POST[shelf_bin]', '$_POST[unit_issue]', '$_POST[part_type]', '$_POST[whse]', '$_POST[vendor]', '$_POST[manufactur]', '$_POST[system]', '$_POST[dom]', '$_POST[sub_sys]', '$_POST[validation]', '$_POST[repairstat]', '$_POST[qastat]')");

    print ("Your record has been added.");
    }
    mysql_close();
    ?>
    [/PHP]
  • jx2
    New Member
    • Feb 2007
    • 228

    #2
    the code looks fine
    posible problem:
    u trying to insert improper values into the table
    e.g. char(asci) into integer column

    try this after last query

    echo mysql_error();

    it will display the error - if any occur

    hope that help
    jx2

    Comment

    • pinzasso
      New Member
      • Aug 2007
      • 4

      #3
      actually it was simply as the = statement changeing the data to be entered..i wasn't sure if == was useable in php but it seems to be.

      Comment

      • jx2
        New Member
        • Feb 2007
        • 228

        #4
        lol i didnt notice that eighter :-) well done

        Comment

        Working...