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 11-03-2007, 08:59 AM   #1
Casey
 
Join Date: Nov 2007
Posts: 7
Default Coding in video tutorials

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
Casey is offline   Reply With Quote
Old 11-03-2007, 09:16 AM   #2
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

i didnt supply the code

you have to write it as i cover it
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 11-04-2007, 12:10 AM   #3
Casey
 
Join Date: Nov 2007
Posts: 7
Default

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 is offline   Reply With Quote
Old 11-04-2007, 06:17 AM   #4
Casey
 
Join Date: Nov 2007
Posts: 7
Default

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
Casey is offline   Reply With Quote
Old 11-04-2007, 08:08 AM   #5
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

post the code
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 11-05-2007, 05:37 AM   #6
Casey
 
Join Date: Nov 2007
Posts: 7
Default

Here is the coding.

PHP Code:
 
<?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>
Casey is offline   Reply With Quote
Old 11-05-2007, 05:48 AM   #7
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

i cant remember but this bit looks unfamiliar
PHP Code:
 
<?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
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 11-05-2007, 11:07 PM   #8
Casey
 
Join Date: Nov 2007
Posts: 7
Default

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?
Casey is offline   Reply With Quote
Old 11-06-2007, 05:50 AM   #9
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

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.
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 11-06-2007, 06:47 AM   #10
Casey
 
Join Date: Nov 2007
Posts: 7
Default

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.
Casey 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 09:48 AM.


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