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?? Link to comment https://forums.phpfreaks.com/topic/124446-solved-php-extract-not-working/ 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. Link to comment https://forums.phpfreaks.com/topic/124446-solved-php-extract-not-working/#findComment-642653 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. ) Link to comment https://forums.phpfreaks.com/topic/124446-solved-php-extract-not-working/#findComment-642655 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? Link to comment https://forums.phpfreaks.com/topic/124446-solved-php-extract-not-working/#findComment-642663 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. Link to comment https://forums.phpfreaks.com/topic/124446-solved-php-extract-not-working/#findComment-642666 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. Link to comment https://forums.phpfreaks.com/topic/124446-solved-php-extract-not-working/#findComment-642674 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.