PDA

View Full Version : Stuck on Part 9 Inserting data with php


3ppps
05-21-2008, 01:03 PM
Hi
1st Post so go easy:

Im stuck on the video part 9 inserting data with php, at the end of the turtorial where you insert the data and click submit, the data then updates in the table below

Unfortunately this is not happening for me, the table remains the same
some part of my code must be wrong or something

can you help
Thanks in Advance, Very Good Videos Keep Up The Good Work


**************below is my connection.php

<?php
$database = "dwc";
$username = "dj";
$password = "********";
$link = @mysql_connect('localhost', $username, $password);
$db = mysql_select_db($database, $link);
?>


**************below is my dwc.php

<?php
require_once("connections/connection.php");

$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 is 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));*/
?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<p>&nbsp;</p>
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
<table width="400" border="1">
<tr>
<td>data2</td>
<td>data3</td>
<td>data4</td>
</tr>
<tr>
<td><label>
<input type="text" name="data2" id="data2" />
</label></td>
<td><label>
<input name="data3" type="text" id="data3" value="" size="45" />
</label></td>
<td><label>
<input name="data4" type="text" id="data4" value="" size="45" />
</label></td>
</tr>
<tr>
<td colspan="3"><label>
<div align="center">
<input type="submit" name="Submit" id="Submit" value="Submit" />
<input name="submit" type="hidden" id="submit" value="1" />
</div>
</label></td>
</tr>
</table>
</form>
<p>&nbsp;</p>
<table width="400" height="135" border="1">
<tr>
<td width="32"><div align="center">id1</div></td>
<td width="46"><div align="center">data2</div></td>
<td width="46"><div align="center">data2</div></td>
<td width="190"><div align="center">data3</div></td>
</tr>

<?php do { ?>
<tr>
<td> <div align="center"><?php echo $row ['field1_id'];?></div></td>
<td><div align="center"><?php echo $row ['field2'];?></div></td>
<td><div align="center"><?php echo $row ['field3'];?></div></td>
<td><div align="center"><?php echo $row ['field4'];?></div></td>
</tr>

<?php }while ($row = mysql_fetch_array($result));?>
</table>
</body>
</html>

davidj
05-21-2008, 02:01 PM
$_post ['data2'];


Your post vars should be Capitals

Like this... (and $_POST< no space here >['data2'])


$_POST['data2'];

3ppps
05-21-2008, 03:44 PM
Thanks D

That worked fine

Also when watching the videos on PHP Arrays, Functions and Classes (http://www.dreamweaverclub.com/vtm/arrays-classes-functions.php) is there any way that I can view them in Camtasia Studio 4 the same way as the others, ie to stop and pause etc

Thanks
Paul

davidj
05-21-2008, 07:35 PM
Mmmm

It works for me?

3ppps
05-21-2008, 08:18 PM
Hi d
In ie7 and firefox both the videos are central on screen with the dreamweaver club in the background either side, they also take forever to download in ie7
They download a lot quicker in firefox but the sound quality is distorted
Is there any way you can email or file transfer them to me, all the other videos are fine so not sure as to what is going on
Thanks Paul

davidj
05-21-2008, 08:21 PM
will look into this

davidj
05-21-2008, 08:31 PM
in IE try right clicking the link to the tut and then open in new window

Report back if its quicker

3ppps
05-21-2008, 08:48 PM
Hi d
In ie7 and firefox both the videos are central on screen with the dreamweaver club in the background either side, they also take forever to download in ie7
They download a lot quicker in firefox but the sound quality is distorted
Is there any way you can email or file transfer them to me, all the other videos are fine so not sure as to what is going on
Thanks Paul

davidj
05-21-2008, 08:55 PM
in IE try right clicking the link to the tut and then open in new window

Report back if its quicker

3ppps
05-21-2008, 09:01 PM
Hi d

That works fine, once again thank you

P