Jump to content

Pezzoni

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Pezzoni's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. The actual output is designed to be either output by caching it to a executable PHP file, or calling eval() on the variable, so given that it appears that this is actually the browsers doing, and the actual PHP is present in the source, things are good again Thanks for the help.
  2. Hi, I'm currently in the process of writing myself a PHP Framework, a part of which is a template engine. The exact details aren't important, but one of the things I need to be able to do is to have variables which contain PHP - specifically the opening and closing <?php ?> tags. At the moment, if I have a variable containing these, then the whole section encapsulated by them does not appear - adding a backslash to break the tags (i.e. changing to <\?php ?>) fixes the problem, but is obviously no good for me. As an example, this does not work: <?php error_reporting(E_ALL); $test = 'Hey {$user}, how are {$things[$and]}?'; echo 'Before:<br />'; echo $test; echo '<br /><br />'; $test = preg_replace('/\{\$([A-Za-z0-9]+|[A-Za-z0-9]+\[\'[A-Za-z0-9]+\'\]|[A-Za-z0-9]+\[\$[A-Za-z0-9]+\])\}/', '<?php echo $$1; ?>', $test); echo 'After:<br />'; print_r($test); ?> Wheras this does: <?php error_reporting(E_ALL); $test = 'Hey {$user}, how are {$things[$and]}?'; echo 'Before:<br />'; echo $test; echo '<br /><br />'; $test = preg_replace('/\{\$([A-Za-z0-9]+|[A-Za-z0-9]+\[\'[A-Za-z0-9]+\'\]|[A-Za-z0-9]+\[\$[A-Za-z0-9]+\])\}/', '<\?php echo $$1; ?>', $test); echo 'After:<br />'; print_r($test); ?> I know the regex isn't quite a perfect description of the PHP variable grammar, but it's good enough for now. Thanks for any help,
  3. On further investigation, I've discovered a MySQL database on the network containing the details I need, so I don't actually need to use the LDAP stuff. Thanks anyway.
  4. Hi, I'm working on an script to get the details of users from their 'mailNickname', and I can't get it to function correctly. Looking up someone on their 'sn' works fine, and if I go into my exchange mailbox, I can look someone up using their 'alias' (which is, I think, equivilent to mailNickname) with no problems. The code I have: echo 'Connecting: <br />'; $ds=ldap_connect("ldaphost.whereever.uk"); echo "Connect result is $ds <br />"; $r = ldap_bind($ds); echo "Bind result is $r <br />"; $sr = ldap_search($ds, "o=Whatever, c=GB", "mailNickname=blah"); echo "Search result is " . $sr . "<br />"; echo "Number of entires returned is " . ldap_count_entries($ds, $sr) . "<br />"; echo "Getting entries...<p>"; $info = ldap_get_entries($ds, $sr); echo "Data for " . $info["count"] . " items returned:<p>"; echo '<pre>'; print_r($info); echo '</pre>'; echo "Closing connection"; ldap_close($ds); Am I searching on the wrong attribute, or doing something else totally wrong? Thanks,
  5. Not quite a logic error, but a bit of copy&paste related stupidity on my behalf. I had a mysql_fetch_array() on it's own, in addition to the one I used to build an index of the results. Which shouldn't have been there. Thanks for the help, and sorry for the dumb-ass mistake... There goes another 3 hours of my life! :D
  6. Like the title says. For example, if I have n rows in a database, then run 'SELECT *' on it, then n-1 rows are always returned (the newest one is left off). This is happening at the most basic level of the result returned by mysql_query, so I really have no idea what is wrong. Does anyone have any suggestions? Thanks, Dan
  7. Would it not be simpler to just set a variable for each page? So for example, at the top of index.php, you have a line saying: [code]$page = 'index';[/code] And at the top of product .php, you have a line that says: [code]$page = 'product';[/code] You could do it in the way you are suggesting, but it would be needlessly complex.
  8. Fixed this one with: [code]         $pieces = preg_split('/(\{loop \$.+ as \$.+\}(?s:.+?)\{endloop\})/', $this->template_file, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);[/code]
  9. Try: [code]<table width="100%" height="116" border="0" id="head">     <tr> <tr class="mTr"><td><p> </p>     <p>Web site</p></td><td>       <textarea rows="10" name="S1" cols="20"><? echo $profile->web; ?></textarea></td></tr>         </tr> </table>[/code] Also don't forget to do the normal processing you would do on the data for display (stripslashes etc), or things might start getting strange.
  10. I have the following preg_split command at the moment: [code]preg_split('/(\{loop \$.+ as \$.+\}.+?\{endloop\})/', $this->template_file, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);[/code] Now this works great, so long as the text to be matched is all on the same line. For example: [code]{loop $waa as $wai}{$wai[one]}{$wai[two]}{endloop}[/code] All works fine. However, unfortunately, if the contained statements are split onto different lines, the preg_split statement stops working properly, so this will not work for example: [code]{loop $waa as $wai}     {$wai[one]}     {$wai[two]} {endloop}[/code] All of which is a little annoying! Any help would be gratefully recieved! Thanks.
  11. Seems like it definately is the source of the problem: [a href=\"http://www.htmlhelp.com/tools/validator/problems.html#amp\" target=\"_blank\"]http://www.htmlhelp.com/tools/validator/problems.html#amp[/a]
  12. Anyone got any ideas on this one? Thanks again. Dan
  13. WYSIWYG - Maybe - it seems a little excessive for a forum system (the idea is to communicate content primerially, with the layout of that for individual posts seeming a little insignificant). URL Rewriting - As in modifiying the URL for SEO purposes? It's a possibility, although from what I've read, if redundant data is stripped from URL's from search engines, it doesn't really offer much in the way of SEO benefits. PNG - As far as I know, IE6 is the only vaugely modern browser that doesn't support it properly, and when I started, I was in a 'sod IE' phase. If the project continues to move on, I imagine that a backwards leap to GIF/JPEG is inevitable to ensure proper transparancy compatibility. As for standards, it seems to be largely the use of actual & (and maybe = ?) signs which is causing problems - only one error is caused by somthing else! Definately somthing which needs sorting.
  14. I agree that the templates need a fair bit of work (they don't look as they should outside of Firefox for example), and the majority of what you said was sensible - It is also a problem I hope to alleviate in the future by getting dedicated people to work on the design, it was somthing that felt a bit rushed throughout, with it being knocked together to fit around the functionality, rather than the other way round. One thing that really does need addressing in the codebase is the use of & insted of &amp; in URL's - which is responsible for the vast majority of validation errors. Thankyou - your comments have been taken upon board and will be acted upon in the future :)
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.