Update Script Annoyance
Moderator: General Moderators
-
wolfnipplechips
- Forum Commoner
- Posts: 32
- Joined: Tue Aug 18, 2009 6:46 am
- Location: Berkshire, UK
Update Script Annoyance
Hi Folks,
I'm a complete novice in PHP - first things first.
The script below is really annoying me. There doesn't seem to be anything obvious - I've done searches online and have tweaked bits here and there to match tutorials etc. Not even my "or Die" command works - am I doing it right? It simply does not update anything in the database.
If somebody could help me out with this, it would be much appreciated...
I'm a complete novice in PHP - first things first.
The script below is really annoying me. There doesn't seem to be anything obvious - I've done searches online and have tweaked bits here and there to match tutorials etc. Not even my "or Die" command works - am I doing it right? It simply does not update anything in the database.
If somebody could help me out with this, it would be much appreciated...
Last edited by wolfnipplechips on Tue Aug 18, 2009 7:32 am, edited 1 time in total.
-
wolfnipplechips
- Forum Commoner
- Posts: 32
- Joined: Tue Aug 18, 2009 6:46 am
- Location: Berkshire, UK
Re: Update Script Annoyance
Code: Select all
<? php
include("connect.php");
if ($_POST["$submit"])
{
$courseID = $_POST['courseID'];
$courseTitle = $_POST['courseTitle'];
$str = "UPDATE course SET courseTitle='$courseTitle' WHERE courseID='$courseID'";
mysql_query($str) or die("Query failed:<br>".mysql_error());
echo "<span class='titles'>Edit Complete!</span><br><br>";
}
include("connect.php");
$courseID=$_GET['courseID'];
$result=mysql_query("select * from course where courseID='$courseID'");
$row=mysql_fetch_assoc($result);
?>
-
wolfnipplechips
- Forum Commoner
- Posts: 32
- Joined: Tue Aug 18, 2009 6:46 am
- Location: Berkshire, UK
Re: Update Script Annoyance
This is the form I'm posting...
Code: Select all
<form action="process_edit_course.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="courseID" value="<?php echo $row['courseID']; ?>">
<TABLE width="100%" cellpadding="0" cellspacing="10" bgcolor="#FFFFFF" class="border">
<br>
<TR valign="top">
<TD width="388"><span class="bodytext">Course Title: </span></TD>
</TR>
<TR valign="top">
<TD width="388"><input name='courseTitle' type='text' class="border" id="courseTitle" value="<? echo $row['courseTitle']; ?>" size="45" /></TD>
</TR>
<TR valign="top">
<TD><input type="submit" name="submit" value="Add Course to Libary" /></TD>
</TR>
</TABLE>
</form>
Re: Update Script Annoyance
Hello,
At first glance it seems:
looks incorrect to me and should be:
I literally havnt went any further than that line.
Thanks
.
At first glance it seems:
Code: Select all
($_POST["$submit"])
Code: Select all
($_POST['submit'])
Thanks
-
wolfnipplechips
- Forum Commoner
- Posts: 32
- Joined: Tue Aug 18, 2009 6:46 am
- Location: Berkshire, UK
Re: Update Script Annoyance
Thanks for the reply.
No unfortunately not, still nothing!
No unfortunately not, still nothing!
Re: Update Script Annoyance
what does
display?
Code: Select all
print_r($_POST);-
wolfnipplechips
- Forum Commoner
- Posts: 32
- Joined: Tue Aug 18, 2009 6:46 am
- Location: Berkshire, UK
Re: Update Script Annoyance
I put that in line 6 - nothing happens. Was that the right place to put it?
Re: Update Script Annoyance
Line 3 
-
wolfnipplechips
- Forum Commoner
- Posts: 32
- Joined: Tue Aug 18, 2009 6:46 am
- Location: Berkshire, UK
Re: Update Script Annoyance
Ah woops!
I get 'Array ( )'
I get 'Array ( )'
Re: Update Script Annoyance
It works for me. You are putting this on the processing script right?? Also, remove the space between <? and php.
-
wolfnipplechips
- Forum Commoner
- Posts: 32
- Joined: Tue Aug 18, 2009 6:46 am
- Location: Berkshire, UK
Re: Update Script Annoyance
Hmmm. I deleted the space straight after posting here.
This all sits within one file 'process_edit_course.php'. It get posted back at itself essentially, and processes.
This is the entire document...
This all sits within one file 'process_edit_course.php'. It get posted back at itself essentially, and processes.
This is the entire document...
Code: Select all
<?php
include("check_session.php");
?>
<?php
include_once("../fckeditor/fckeditor.php") ;
?>
<?php
include("connect.php");
print_r($_POST);
if ($_POST['$submit'])
{
$courseID = $_POST['courseID'];
$courseTitle = $_POST['courseTitle'];
$str = "UPDATE course SET courseTitle='$courseTitle' WHERE courseID='$courseID'";
mysql_query($str) or die("Query failed:<br>".mysql_error());
echo "<span class='titles'>Edit Complete!</span><br><br>";
}
include("connect.php");
$courseID=$_GET['courseID'];
$result=mysql_query("select * from course where courseID='$courseID'");
$row=mysql_fetch_assoc($result);
?>
<form action="process_edit_course.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="courseID" value="<?php echo $row['courseID']; ?>">
<TABLE width="100%" cellpadding="0" cellspacing="10" bgcolor="#FFFFFF" class="border">
<br>
<TR valign="top">
<TD width="388"><span class="bodytext">Course Title: </span></TD>
</TR>
<TR valign="top">
<TD width="388"><input name='courseTitle' type='text' class="border" id="courseTitle" value="<? echo $row['courseTitle']; ?>" size="45" /></TD>
</TR>
<TR valign="top">
<TD><input type="submit" name="submit" value="Add Course to Libary" /></TD>
</TR>
</TABLE>
</form></td>
Re: Update Script Annoyance
That submits for me, and the $_POST array has the correct values in it. Although you still haven't taken juma929's point into account.
-
wolfnipplechips
- Forum Commoner
- Posts: 32
- Joined: Tue Aug 18, 2009 6:46 am
- Location: Berkshire, UK
Re: Update Script Annoyance
I didn't notice that the $ had gone, I thought it was just a change in quote types.
That now works - really sorry for wasting your time, I really appreciate your help.
I clearly need to pay more attention.
Thanks again.
That now works - really sorry for wasting your time, I really appreciate your help.
I clearly need to pay more attention.
Thanks again.