PDA

View Full Version : Coding in video tutorials


Casey
11-03-2007, 09:59 AM
Where can i get the coding that you use in the video tutorials
(PHP, A Beginners Guide part 11 - updating data with PHP)?

Thanks.


Casey

davidj
11-03-2007, 10:16 AM
i didnt supply the code

you have to write it as i cover it

Casey
11-04-2007, 01:10 AM
I have tried out the video tutorial but i get this message.

403 forbidden
you don't have permission to access /on this server.

I am just wandering that i might miss some of your codes.
That's why i am asking for the coding.
I can't figure out where is the problem.

Thanks.

Casey

Casey
11-04-2007, 07:17 AM
Now the problem is solved but i dont know why my coding does not work properly.

I can not update the records or delete them.

Can i post my coding here?

Thanks.


Casey

davidj
11-04-2007, 09:08 AM
post the code

Casey
11-05-2007, 06:37 AM
Here is the coding.



<?php if(isset($_POST['submit'])) {
$link = mysql_connect("localhost", "casey", "");
if (!$link) {
die('Could not connect: ' . mysql_error());
}

$db_selected = mysql_select_db('testing', $link);

$data2 = $_POST['data2'];
$data3 = $_POST['data3'];
$data4 = $_POST['data4'];
$submit = $_POST['submit'];
$del = $_GET['del'];
$upd = $_GET['upd'];
$update_id = $_POST['update_id'];

$query = sprintf("SELECT * FROM table1 WHERE field1_id = '$upd'");
$result = @mysql_query($query) or die(mysql_error());;
$rowUpdate = mysql_fetch_array($result);

if($submit && $data2 && $data3 && $data4 && !$update_id)
{
$query = "INSERT into table1(field2, field3, field4) values('$data2', '$data3', '$data4')";
mysql_query($query) or die(mysql_error());
}
elseif($submit && $update_id)
{
$query = "UPDATE table1 set field2 = '$data2', field3 = '$data3', field4 = '$data4' WHERE field_id = '$udate_id'";
}

////delete record
if($del)
{
$query = "DELETE FROM table1 WHERE field1_id = '$del'";
mysql_query($query) or die (mysql_error());
}

$query = sprintf("SELECT * FROM table1");
$result = @mysql_query($query);
$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>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>

<br/><br/>

<form id = "form1" name = "form1" method = "post" action = "<?php $_SERVER['PHP_SELF'];?>">

<table width>

<tr>
<td width = "144" height="23">data2 </td>
<td width = "144">data3 </td>
<td width = "144">data4 </td>
</tr>
<tr>
<td><input name = "data2" type "text" id = "data2" value = "<?php echo $rowupdate['field2'];?>"/></td>
<td><input name = "data3" type "text" id = "data3" value = "<?php echo $rowupdate['field3'];?>"/></td>
<td><input name = "data4" type "text" id = "data4" value = "<?php echo $rowupdate['field4'];?>"/></td>
</tr>
<tr>
<td height = "38" colspan="3" align="center" valign = "middle">
<input type = "reset" name = "submit4" value = "Reset"/>
<input type="submit" name="Submit" value="Submit" />
<input name = "submit" type = "hidden" id = "submit" value = "1"/>
<input name = "update_id" type = "hidden" id = "update_id" value = "<?php echo $rowupdate['field1_id'];?>"/>
</td>
</tr>
</table>
</form>

<table width="380" height = "56" border="1">
<tr>
<td width="59">&nbsp;</td>
<td width="81">ID1</td>
<td width="81">data2</td>
<td width="81">data3</td>
<td width="52">data4</td>
<td width="59">&nbsp;</td>

</tr>
<?php do{ ?>
<tr>
<td>
<input type="button" name="Submit3" value="Update" onClick = "document.location.href= 'dwc.php? upd = <?php echo $row['field1_id'] ?>'"/>
</td>
<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>
<td>
<input type="button" name="Submit2" value="Delete" onClick = "document.location.href = 'dwc.php? del = <?php echo $row['field1_id'] ?>'"/>
</td>
</tr>
<?php } while (mysql_fetch_array($result));?>
</table>
</body>
</html>

davidj
11-05-2007, 06:48 AM
i cant remember but this bit looks unfamiliar


<?php if(isset($_POST['submit'])) {
$link = mysql_connect("localhost", "casey", "");
if (!$link) {
die('Could not connect: ' . mysql_error());
}

$db_selected = mysql_select_db('testing', $link);


i thought i had that in my connections page. Did you get this from somewhere else

Casey
11-06-2007, 12:07 AM
i got that bit from somewhere else.

You gave this one:
<?php
require_once("Connections/connection.php");

Other than the connection part, is there any other part that is wrong?

davidj
11-06-2007, 06:50 AM
you have to follow my tutorial in full before i can troubleshoot this

its like phoning SONY asking why your plasma doesnt work then telling them you only followed half the instruction manual and used a PANASONIC instruction manual to cover the rest.

Casey
11-06-2007, 07:47 AM
I followed exactly as what you did except for the connection part.
When i put in the connection part that you gave, in the coding and run it, there was nothing on the screen. That's why i changed the connection part.

davidj
11-07-2007, 08:01 PM
and your way worked ic

replace what you changed with my version then paste it back in this thread and i will look at it

Casey
11-11-2007, 08:40 AM
I went through your video tutorials again and everything works well. I can now update my records. Thanks a lot.

Casey

davidj
11-11-2007, 11:23 AM
nice one casey

glad your enjoying them