what Posted April 12, 2009 Share Posted April 12, 2009 I created a varialble to hold a path to a file folder but I'm having problems integrating it into my button. Can someone please advise? Below I want to replace '/admin/files/' with $files but my attempts just generate errors. <input type="button" name="View" value="View" OnClick="location.href=\'/admin/files/'.$row["file"].'\'" class="button_60"> Thanks Quote Link to comment https://forums.phpfreaks.com/topic/153685-php-variable-in-a-button/ Share on other sites More sharing options...
MasterACE14 Posted April 12, 2009 Share Posted April 12, 2009 try... <input type="button" name="View" value="View" OnClick="location.href=\'.$files.$row["file"].'\'" class="button_60"> Regards, ACE Quote Link to comment https://forums.phpfreaks.com/topic/153685-php-variable-in-a-button/#findComment-807660 Share on other sites More sharing options...
what Posted April 12, 2009 Author Share Posted April 12, 2009 Hi thanks.. I think something is still missing? I was getting the following errors: Warning: Unexpected character in input: '\' (ASCII=92) state=1 Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' I thought I saw where it was missing a tick from your example (after ["file"] ?), but even though I added it and then I was able to see my page without errors, the button did not work when I clicked on it. Quote Link to comment https://forums.phpfreaks.com/topic/153685-php-variable-in-a-button/#findComment-807670 Share on other sites More sharing options...
MasterACE14 Posted April 12, 2009 Share Posted April 12, 2009 what is the code a few lines above and below that line? Quote Link to comment https://forums.phpfreaks.com/topic/153685-php-variable-in-a-button/#findComment-807673 Share on other sites More sharing options...
what Posted April 12, 2009 Author Share Posted April 12, 2009 while ($row = mysql_fetch_array($result)) { echo '<tr><td width="98%">'.$row["title"].'</td> <td width="1%"><input type="button" name="View" value="View" OnClick="location.href=\'/admin/files/'.$row["file"].'\'" class="button_60"></td> <td width="1%"><input type="button" name="Download" value="Download" OnClick="location.href=\'file.php?file='.$row["id"].'\'" class="button_60"></td> </tr>'; } @mysql_close(); Quote Link to comment https://forums.phpfreaks.com/topic/153685-php-variable-in-a-button/#findComment-807677 Share on other sites More sharing options...
Philip Posted April 12, 2009 Share Posted April 12, 2009 try... <input type="button" name="View" value="View" OnClick="location.href=\'.$files.$row["file"].'\'" class="button_60"> Regards, ACE Should read: <input type="button" name="View" value="View" OnClick="location.href=\''.$files.$row["file"].'\'" class="button_60"> Using a syntax highlighter would help: echo '<input type="button" name="View" value="View" OnClick="location.href=\''.$files.$row["file"].'\'" class="button_60">'; Quote Link to comment https://forums.phpfreaks.com/topic/153685-php-variable-in-a-button/#findComment-807683 Share on other sites More sharing options...
what Posted April 12, 2009 Author Share Posted April 12, 2009 That did it. Thanks guys! Quote Link to comment https://forums.phpfreaks.com/topic/153685-php-variable-in-a-button/#findComment-807705 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.