logo-dw

Go Back   Dreamweaver Club Forums > Dreamweaver forums > Video Tutorials
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 12-17-2007, 05:08 PM   #1
heirani1
 
Join Date: Dec 2007
Posts: 10
Question PHP Video Tutorial part 9, date doesn't post

hi, i am following part 9 of the VTM and i am sure i have got all the code correct and when i go to add data into each one it adds it to the bottom of the list apart from the date field. all i get is 0000-00-00, the other 2 fields work perfectly!

heres the code...

PHP Code:
<?php
require_once("connections/connection.php"); //database connection

///////////////////////////////////////////
$data2     =     $_POST['data2'];
$data3     =     $_POST['data3'];
$data4     =     $_POST['data4'];
$submit =     $_POST['Submit'];
///////////////////////////////////////////

if ($submit && data2 && data3 && data4){

///////////////////////////////////////////
$query    sprintf("INSERT into table1 (field2, field3, field4) values ('$data2', '$data3', 'data4')");
          
mysql_query($query)or die(mysql_error());
///////////////////////////////////////////

}elseif($submit){

echo 
"one of your fields are empty!";

}

///////////////////////////////////////////
$query     =     sprintf("SELECT * FROM table1");
$result =     @mysql_query($query);
$row     =     mysql_fetch_array($result);
///////////////////////////////////////////

/*do {
echo $row['field3']."<br>";

}while ($row = mysql_fetch_array($result));*/

?>

<body>
<form id="form1" name="form1" method="post" action="<?php $SERVER {'PHP_SELF'}; ?>">
  <table width="424" border="1">
    <tr>
      <td>Data2</td>
      <td>Data3</td>
      <td>Data4</td>
    </tr>
    <tr>
      <td><label>
      <input name="data2" type="text" id="data2" />
      </label></td>
      <td><label>
      <input name="data3" type="text" id="data3" />
      </label></td>
      <td><label>
      <input name="data4" type="text" id="data4" />
      </label></td>
    </tr>
    <tr>
      <td colspan="3"><label>
        <div align="center">
          <input type="submit" name="Submit" value="Submit" />
          <input name="Submit" type="hidden" id="Submit" value="1" />
        </div>
      </label></td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
<table width="424" border="1">
  <tr>
    <td>ID1</td>
    <td>Data2</td>
    <td>Data3</td>
    <td>Data4</td>
  </tr>
  
  <?php do { ?>
  <tr>
    <td><?php echo $row['field1_id'];  ?> </td>
    <td><?php echo $row['field2'];  ?></td>
    <td><?php echo $row['field3'];  ?></td>
    <td><?php echo $row['field4']; ?></td>
  </tr>
  <?php }while ($row mysql_fetch_array($result)); ?>

Last edited by domedia; 12-17-2007 at 06:55 PM.. Reason: aded php tags
heirani1 is offline   Reply With Quote
Old 12-17-2007, 07:52 PM   #2
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

your going to kick yourself

check the var (data4) in your SQL statement

its missing something!

///

give yourself a smack on the head..

welcome to the forums mate
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 12-18-2007, 09:57 AM   #3
heirani1
 
Join Date: Dec 2007
Posts: 10
Default

i don't believe it i checked that code convinced it was right, i hate it when things like that happen lol anyway thanks for your help, these tutorials are becoming very helpful. While im here is there any more tutorials i can follow on from after i have done the updating php data - part 11?

Thanks again for your help,

Chris
heirani1 is offline   Reply With Quote
Old 12-18-2007, 10:06 AM   #4
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

no probs

there are other tuts in there which i have done
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:01 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com