gnawz Posted September 16, 2008 Share Posted September 16, 2008 I have used this before and it worked... <?php if (!defined('WEB_ROOT')) { exit; } if (isset($_GET['ProjectID']) && (int)$_GET['ProjectID'] > 0) { $ProjectID = (int)$_GET['ProjectID']; } $sql = "SELECT * FROM prismprojects WHERE ProjectID = '$ProjectID'"; $result = dbQuery($sql); extract(dbFetchAssoc($result)); ?> <table width="100%" border="0" cellpadding="5"> <tr> <td colspan="3" class="title_text">Details</td> </tr> <tr> <td width="143" valign="top">Overall Project Title</td> <td width="791" colspan="2" bgcolor="#FFFFFF"> <?php echo $OverallProjectTitle; ?> </td> </tr> <tr> <td valign="top" class="style3 tdcontent">Specific Project</td> <td colspan="2" bgcolor="#FFFFFF"><?php echo $SpecificProject; ?></td> </tr> <tr> <td valign="top" class="style3 tdcontent">Partner Organisation</td> <td colspan="2" bgcolor="#FFFFFF"><?php echo $PartnerOrganisation; ?></td> </tr> <tr> <td valign="top" class="style3 tdcontent">Country</td> <td colspan="2" bgcolor="#FFFFFF"><?php echo $Country; ?></td> </tr> <tr> <td valign="top" class="style3 tdcontent">Sector</td> <td colspan="2" bgcolor="#FFFFFF"><?php echo $Sector; ?></td> </tr> <tr> <td valign="top" class="style3 tdcontent">Value</td> <td colspan="2" bgcolor="#FFFFFF"><?php echo $Value; ?></td> </tr> <tr> <td valign="top" class="style3 tdcontent">Date created</td> <td colspan="2" bgcolor="#FFFFFF"><?php echo $DateAdded; ?></td> </tr> <tr> <td colspan="3" class="tdcontent"> <div align="center"> <input name="btnBack" type="button" id="btnBack" value=" Back " onClick="window.history.back();" class="button_image"> </div></td> </tr> </table> <? ?> I get these errors..... Notice: Undefined variable: ProjectID in C:\xampp\htdocs\prism\admin\portfolio\detail.php on line 12 Warning: extract() [function.extract]: First argument should be an array in C:\xampp\htdocs\prism\admin\portfolio\detail.php on line 14 What could be the problem?? Quote Link to comment Share on other sites More sharing options...
ratcateme Posted September 16, 2008 Share Posted September 16, 2008 if $_GET['ProjectID'] is not set then $ProjectID is not set so the wuery looks like ProjectID = '' so zero results are returned and so extract fails Scott. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted September 16, 2008 Share Posted September 16, 2008 What if $ProjectID is not set? You should add an else and set a default or tell the user they have selected an invalid project id. The second error is a result of the first notice because its saying that the variable is not defined which means that $result does not contain a MySQL Resource ID which means extract will fail. You need more error checking, to ensure these errors don't occur. (Yeah what Scott said. ) Quote Link to comment Share on other sites More sharing options...
gnawz Posted September 16, 2008 Author Share Posted September 16, 2008 These code works well in a similar program. Is there a way I could rewrite it? Quote Link to comment Share on other sites More sharing options...
ratcateme Posted September 16, 2008 Share Posted September 16, 2008 you could add a else onto the second if and redirect them somewhere if ProjectID is not set Scott. Quote Link to comment Share on other sites More sharing options...
gnawz Posted September 16, 2008 Author Share Posted September 16, 2008 Thanks guys, I have seen the error. I had to remove a space in my list.php file where a user clicks before going to detail.php <?php echo $_SERVER['PHP_SELF']; ?>?view=detail&ProjectID=<?php echo $ProjectID; ?> There was a space between ProjectID AND = which means ProjectID had not been set Thanks alot. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.