Results 1 to 5 of 5

Thread: values not inserting

  1. #1
    Join Date
    Aug 2006
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question values not inserting

    This worked in php4 ,but it doesn't work in Php5, the 'id' and 'active' are inserted but the variable values aren't. i get empty fields
    I tried without the
    $na=$_POST[$name];
    $em=$_POST[$email];
    lines and got the same result, using (NULL,'$name','$email','active')"; instead of (NULL,'$na','$em','active')";

    Also get the same result with no "`" around the column names. I also tried single quotes after the = sign and at the end instead of double and got a T_varible error message. This is part of a larger script and everything else works, just this rather neccessary part, there are no repeated varible names, and I've tried exactly as shown in its own little script and keep getting no data inserted in the varible fields

    before everything was inserted
    id name email status
    20 Debbie notrealemail@com.ca active

    now I get
    id name email status
    21 blankspace blankspace active

    <?php
    include("connect.php");
    include("header.php");
    ?>
    <FORM METHOD="post" ACTION="insertdatav.php">
    <p>Name <INPUT TYPE="text" NAME="name" SIZE="30"><br><br>
    <p>Email <INPUT TYPE="text" NAME="email" SIZE="30"><br><br>
    <INPUT TYPE="submit" NAME="submit" VALUE="Join"></FORM>
    <?php
    include("footer.php");
    ?>


    insertdatav.php :
    <?php
    include("connect.php");
    $na=$_POST[$name];
    $em=$_POST[$email];
    $sql="INSERT INTO list (`id`,`name`,`email`,`status`) VALUES (NULL,'$na','$em','active')";
    mysql_query($sql);
    include("test.php");
    ?>

    And is there a way around the VERY ANNOYING fact that you can't use a full path name with include? Seriously, if the decision was mine that alone would be enough reason roll back to php 4. I got 15 folders for some websites, more being added, and copying the header, footer and connect files in every folder is RIDICULOUS

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Make the highlighted changes in the following your code

    Code:
    <?php
    include("connect.php");
    $na=$_POST["name"];
    $em=$_POST["email"];
    $sql="INSERT INTO list (`id`,`name`,`email`,`status`) VALUES (NULL,'$na','$em','active')";
    mysql_query($sql);
    include("test.php");
    ?>

  3. #3
    Join Date
    Aug 2006
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks but it didn't work

    neither did

    $na=$_GET["$name"];
    $em=$_GET["$email"];

    or

    $na=$_GET['$name'];
    $em=$_GET['$email'];

    or

    $_GET["$name"];
    $_GET["$email"];

    putting everything in one script

    <?php
    include("connect.php");
    include("header.php");
    ?>
    <FORM METHOD="post" ACTION="">
    <p>Name <INPUT TYPE="text" NAME="name" SIZE="30"><br><br>
    <p>Email <INPUT TYPE="text" NAME="email" SIZE="30"><br><br>
    <INPUT TYPE="submit" NAME="submit" VALUE="Join"></FORM>
    <?php
    if(isset( $submit ))
    {
    $sql="INSERT INTO list (`id`,`name`,`email`,`status`) VALUES (NULL,'$name','$email','active')";
    mysql_query($sql);
    }
    include("footer.php");
    ?>

    and nothing at all gets inserted, nothing happens, no blank spaces, no 'active',
    nothing

    so I try

    if(isset( $submit ))
    {
    $sql="INSERT INTO list (`id`,`name`,`email`,`status`) VALUES (NULL,'$name','$email','active')";
    mysql_query($sql) or die(mysql_error());
    }

    nothing inserted and no error message

    ditto with

    if(isset( $submit ))
    {
    $sql="INSERT INTO list (`id`,`name`,`email`,`status`) VALUES (NULL,'$name','$email','active')";
    mysql_query($sql);
    }
    if (!$sql)
    {
    die(mysql_error());
    }

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    insertdatav.php :
    Code:
    <?php
    include("connect.php");
    $na=$_POST['name'];
    $em=$_POST['email'];
    $sql="INSERT INTO list (`id`,`name`,`email`,`status`) VALUES (NULL,'$na','$em','active')";
    mysql_query($sql);
    include("test.php");
    ?>
    That should do it. Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. The Following User Says Thank You to thetestingsite For This Useful Post:

    solarcom (03-29-2008)

  6. #5
    Join Date
    Aug 2006
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    It works thank you all. And I got a solution to uploading to multiple folders. A little script that does just that

    <form method="POST" action="upload" enctype="multipart/form-data">
    <input type="file" name="header" size="59">
    <INPUT TYPE="submit" NAME="submit" VALUE="Upload"></FORM>

    if( $_FILES['header']['size'] >0)
    {
    copy ($_FILES['header']['tmp_name'], "/home/username/public_html/newsletter/images/".$_FILES['header']['name']) or die ("Could not copy.....");
    $header=$_FILES['header']['name'];
    copy ($_FILES['header']['tmp_name'], "/home/username/public_html/tru2life/".$_FILES['header']['name']) or die ("Could not copy.....");
    $header=$_FILES['header']['name'];
    copy ($_FILES['header']['tmp_name'], "/home/username/public_html/10seconds/".$_FILES['header']['name']) or die ("Could not copy.....");
    $header=$_FILES['header']['name'];
    }

    I just expand it for every folder I want to copy to and do the same thing for footer and connect. I get all the bonuses of php5 and still get one click upload to multiple folders. Takes up a little extra space on the server but with these small scripts and the price of memory these days, big deal

Bookmarks

Posting Permissions

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