Ok i've hit another probem this time in a script i'm building to update the projects in the database.
I have three php scripts to do this one to select the project to be updated the other to show the current data and the third to handle the changed data in the form.
But i'm the query seems to die because of an error in teh query i suspect.
The query requires the variable $projectid=$_REQUEST['projectid']; so it can select the correct row to update in the database. but i tried commenting out the query and just echoing the variable and it seems to not print so maybe there is an error in it being posted from the second script to the third script. I've tried putting in a hidden input field with the projectid in it and it still doesn;t seem to pick it up.
The scripts are as follows:
Script 1 (updateproject.php):
PHP Code:
<h3>Project Management </h3> <fieldset><legend>Project Lookup</legend><form action="uproject.php" method="post" enctype="multipart/form-data" name="findproject" id="findproject"> <label><strong>Project Name: </strong> <select name="projectid" id="projectname"> <?php require('functions.php'); dbconnect(); $query= "SELECT * FROM projects ORDER BY projectname ASC"; $result = mysql_query($query); while($row=mysql_fetch_array($result)) { echo "<option value=\"{$row['projectid']}\">{$row['projectname']}</option>\n"; } ?> </select> </label> <p> <input name="findproject" type="submit" id="findproject" value="Find Project" /> </p> </form></fieldset>
Script 2 (uproject.php):
PHP Code:
<h3>Project Management </h3> <?php require('functions.php'); dbconnect();
// get variables $projectname=$_REQUEST['projectname']; $projectid=$_REQUEST['projectid']; // Delete client from database using form data $sql = "SELECT * FROM `projects` WHERE projects.projectid=$projectid;"; $result=mysql_query($sql); if($result==0){ echo "<p align='center'>There has been a problem!</p><br />"; } else { while ($row=mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<strong>Project ID: </strong>" .$row['projectid']. "<br />"; echo "<input name='projectid' type='hidden' value='".$row['projectid']."' />"; echo "<form action='editproject.php' method='post' enctype='multipart/form-data' name='editproject'><br /><br />"; echo "<strong>Project Name: </strong><input name='projectname' type='text' value='".$row['projectname']."' /><br /><br />"; echo "<strong>Project URL: </strong><input name='projecturl' type='text' value='".$row['projecturl']."' /><br /><br />"; echo "<strong>Project Status: </strong><input name='projectstatus' type='text' value='".$row['projectstatus']."' /><br /><br />"; echo "<strong>Project Decription: </strong><textarea name='projectdesc' cols='40' rows='10' >".$row['projectdesc']."</textarea><br /><br />"; echo "<input name='editproject' type='submit' id='editproject' value='Update Project' />"; echo "</form>"; } }
?>
Script 3 (editproject.php):
PHP Code:
<h3>Project Management </h3> <?php require('functions.php'); dbconnect();
// get variables $projectname=$_REQUEST['projectname']; $projectid=$_REQUEST['projectid']; $projectstatus=$_REQUEST['projectstatus']; $projectdesc=$_REQUEST['projectdesc']; $projecturl=$_REQUEST['projecturl']; // Delete client from database using form data $sql = "UPDATE `projects` SET projectid=Null, projectname='".$projectname."', projectstatus='".$projectstatus."', projectdesc='".$projectdesc."', projecturl='".$projecturl."' WHERE projects.projectid=$projectid;"; $result=mysql_query($sql); if($result==0){ echo "<p align='center'>There has been a problem!</p><br />"; } else { echo "The project details have been successfully updated!"; }
?>
Any suggestions would be greatly appreciated
Regards,
Martin
|