Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2008
    Location
    pakistan
    Posts
    109

    Unanswered: record doesn't insert

    PHP Code:
    <form name="form1" method="post" action="insert.php">
      <p>
        Title
          <input name="tie" type="text" id="tie">
    </p>
      <p>
        Stuff
          <textarea name="stu" id="stu"></textarea>
        <input type="submit" name="Submit" value="Submit">
      </p>
    </form>

    <?php
    include('vars.php');
    include(
    'connect.php');
    $a=$_POST['tie'];
    $b=$_POST['stu'];
    $sql ="INSERT INTO `desktop_urdumag`.`urdumag` (`id`, `head`, `stuff`) VALUES (1 or NULL, '$a','$b');";
    $query=mysql_query($sql);
    if(!
    $query){
    echo 
    "query not executed<br>".mysql_error();
    }
    else
    {
    echo 
    "query executed";
    }
    ?>
    it doesn't insert values how to add that please suggest me

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by don_log View Post
    INSERT INTO `desktop_urdumag`.`urdumag` (`id`, `head`, `stuff`) VALUES (1 or NULL, '$a','$b')
    did you test this query outside of php first?

    i'm not sure whether 1 or NULL is gonna work...
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •