Jump to content

2wasted

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

Posts posted by 2wasted

  1. [quote author=HuggieBear link=topic=110633.msg447650#msg447650 date=1160090791]
    You need to convert the time in php to a format MySQL can recognise...

    $date = time(); as suggested will not give you a valid date format in MySQL.  Do you just want a current timestamp, if so, use this:

    [code]
    <?php
    $query = "INSERT INTO onlineform (name, Cname, email, query, Pnumber, date) VALUES ('$name','$Cname','$email','$Query', '$Pnumber', now())";
    ?>
    [/code]

    Regards
    Huggie
    [/quote]
    i think you have hit the nail on the head:-)it displays on the page but does not go in to the datamase(MYSQL)
  2. this is what i have changed it to and it still does'nt work

            $Name=$_POST['name'];
    $Cname=$_POST['cname'];
    $Query=$_POST['Question'];
    $email=$_POST['email'];
    $Pnumber=$_POST['Pnumber'];
    $date = time();
    $query = "INSERT INTO onlineform VALUES ('','$name','$Cname','$email','$Query', '$Pnumber', '$showdate')";
    mysql_query($query);

    mysql_close();


      echo "<h2>THank you for filling in this form, we will be in touch with you ASAP</h2>";
      //echo $showdate;
  3. lo all,
    i have a form that goes to a database, everthing works fine except the timestamp says 0000-00-00 00:00:00 .i have tryed changing the value in the mysql from timestamp to date but still is'nt working...i have displayed the date on my page np...here is the code
    ?PHP
        $Name=$_POST['name'];
    $Cname=$_POST['cname'];
    $Query=$_POST['Question'];
    $email=$_POST['email'];
    $Pnumber=$_POST['Pnumber'];
    $date = time();
    $showdate = date("H:i:s d/m/Y");
    mysql_select_db($database_csc, $csc);
    $query_Recordset1 = "SELECT * FROM onlineform";
    $Recordset1 = mysql_query($query_Recordset1, $csc) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    $query_Recordset1 or die( "Unable to select database");
    if($_POST['submit']) {

    $query = "INSERT INTO onlineform VALUES ('','$name','$Cname','$email','$Query', '$Pnumber', '$date')";
    mysql_query($query);

    mysql_close();


      echo "<h2>THank you for filling in this form, we will be in touch with you ASAP</h2>";
      echo $showdate;
    }

    ?>
    Thanks for any help
    Charlie
  4. here ya go:-) 
    <input name="submit" type="Submit" onclick="MM_validateForm('email','','RisEmail');return document.MM_returnValue" value="Enter information" />
        </label></td>
        <td>&nbsp;</td>
    <?PHP
        $Name=$_POST['name'];
    $Cname=$_POST['cname'];
    $Query=$_POST['Question'];
    $email=$_POST['email'];


    mysql_select_db($database_csc, $csc);
    $query_Recordset1 = "SELECT * FROM onlineform";
    $Recordset1 = mysql_query($query_Recordset1, $csc) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    $query_Recordset1 or die( "Unable to select database");

    $query = "INSERT INTO onlineform VALUES ('','$name','$Cname','$email','$Query')";
    mysql_query($query);

    mysql_close();

    ?>
  5. lo all,
    i have a simple form that posts fine 2 a mysql, but i want to check that there is something in the email textbox. So i did this...
    //validate email
    $var = $_POST['email'];
    $len = strlen($var);
    if($len >0)
    {
    $query = "INSERT INTO onlineform VALUES ('','$name','$Cname','$email','$Query')";
    mysql_query($query);

    mysql_close();
    }
    else
    {
    echo "Error:Please fill in your email address";
    }
    ?>
    its does not work:-(
    thx for any help
    Charlie
  6. can i query the mysql DB and add them for display?i have a guestbook i put a vote on so when i goto the table it says name,email,comment,then there are 2 rows for the vote 'yesvote' and 'novote' with a 1 where there vote is.could i echo out the total added together?
    cheers
    Charlie
  7. [!--quoteo(post=383104:date=Jun 13 2006, 12:38 AM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Jun 13 2006, 12:38 AM) [snapback]383104[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    Do you mean you added a vote system to an existing database/code and you need an update
    query to get the votes in if a existing user votes.
    [/quote]
    soz for not explaining it properly,but yeah when they vote it goes into the DB but i would like the number to update:-)
    Thx
    Charlie
  8. thx for the reply,what i would like is for the votes to be added up in the database.atm it looks like this in the DB,
    Name,email,comment(memo),yvote1,novote 0<<submit 1
    Name,email,comment(memo),yvote1,novote 0<<submit 2
    i would like..
    Name,email,comment(memo),yvote2,novote 0<<submit 2 the yvote adding atm its just telling me what there vote was.
    yvote=yes
    nvote=no
    Thx
    Charlie
  9. lo all,
    i have put a vote yes/no on a guestbook that submits with the other info name,email,comment.it works ok,but could i use "update" or something like that so it adds in the database?
    this is what i have done...
    [!--coloro:#006600--][span style=\"color:#006600\"][!--/coloro--] $name = $_POST["txt_name"];
    $len = strlen($name);
    if ($len > 0)
    { $email = $_POST["txt_email"];
    $comment = $_POST["txt_comment"];
    $date = time();
    $yvote = $_POST["ybutton"];
    $nvote = $_POST["nbutton"];
    if ($ybutton == true)
    {
    $yvote++;
    }
    else
    {
    $nvote++;
    }
    $query = "INSERT INTO guestbook (autoID, name, email, comment, date_auto, yvote, nvote) VALUES (NULL, '$name', '$email', '$comment', '$date', '$yvote', '$nvote')";[!--colorc--][/span][!--/colorc--]
    Thx for any help:-)
    Charlie
  10. lo all,
    i dont know if i should install it.iam new to php doing it on DW and i thought this might help me...?anyone use it?
    Thx for any reply
    Charlie
    P.s i hope i put this in the right part of the forum.
  11. [!--quoteo(post=382292:date=Jun 10 2006, 01:58 PM:name=joquius)--][div class=\'quotetop\']QUOTE(joquius @ Jun 10 2006, 01:58 PM) [snapback]382292[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    just choose do add a new row, considering you are using an INT field it will automatically set all fields to a negative result of 0 if u do not set the default to 1 (given there are already entries in the book)
    [/quote]
    thx all,
    Charlie
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.