Jump to content

ToonMariner

Members
  • Posts

    3,342
  • Joined

  • Last visited

Everything posted by ToonMariner

  1. to traverse a 2d array(must be a i x i array) [code]<?php $array = array(array(1,0,1,0),array(1,0,0,0),array(0,0,1,1),array(1,0,1,1); $arrsize = count($array[0]); $tlbrcount = NULL; var to store number of true values in tl - br diag $bltrcount = NULL; var to store number of true values in bl - tr diag for ($i = 0; $i < $arrsize; $i++) { //tl - br loop $tlbrcont = $array[$i][$i] == true ?  $tlbrcont + 1 : $tlbrcont; //bl - tr loop $bltrcont = $array[$i][($arrsize - 1) - $i] == true ?  $bltrcont + 1 : $bltrcont; } ?>[/code] There you go - took me 5 minutes to post that!!!!!!!! should start charging.
  2. use sesssion_unset(); prior to destroy.
  3. Are you passin the source code of the php file to teh validator or the output generated by the script? You should only pass teh latter!
  4. Perhaps a simpler option would be to use mysql_close at the end of your scripts and to restart your server - that will kill any connections currently persisting.
  5. You need to look into strip_slashes and add_slashes. The database my have the titles stored as: That\'s the way to do it and you query is looking for: That's the way to do it or vice versa.
  6. personally I have a table 'sections'. Within that table I have all the details for my menus and two fields - root_id and parent_id so top level menu item has root_id = 0 and parent_id = 0 I select the entire table and pace it in a array I then use a recursive function that uses array_keys to grab all the items from each top level element and as it traverses the array, will select all the items from the immediate parent element - quite elegant IMO
  7. take a look at this: [a href=\"http://uk.php.net/manual/en/function.umask.php\" target=\"_blank\"]umask[/a]
  8. Somewhere in (check login.php) you have some output - either an echo or print or just where you break out of php.
  9. [code]<?php $max_len = 400; // max number of characters. $string = "Your string"; if (str_len($string) > $max_len) { $string = substr($string,0,$max_length) . "..."; } echo $string; ?> [/code]
  10. Sorry but all that was not ultimately clear howerver..... you could simply run a cron job on one server that has accessto all the databases and any directories where you need to grab files and let that run on just the one site.
  11. <? $page[home]="index.php"; $page[services]="services.php"; $page[health]="health"; $page[eff]="effciency.php"; $page[about]="aboutus.php"; $page[contact]="contact.php"; file_get_contents ($page[$_GET['page']]); ?>
  12. You don't need any script for this. Simply have one of the radio buttons selected by default. <input type="radio" name="pay" id="pay" value="1" selected="selected">Number Attending <input type="radio" name="pay" id="pay" value="2">Cheque Amount <input type="radio" name="pay" id="pay" value="3">Phone Nummber (Odd for radio buttons as tehy don't seem connected - but hey its your form!)
  13. yes try the apache (or iis if it uses thst) configuration on the server
  14. You can do this on the page that displays their posts rather than on the actual script that enters the html into the database. This would allow you to filter the posts retrospectively - also you could set a cronjob up that will just loop through all the posts and do this for you so you have all the 'old' post corrected. The last suggestions of doing the retorspective updates means you could then just have the script entering posts into the database performing this job - much more efficient.
  15. Indeed - you need to use a preg_replace on the submitted html to remove bits that it doesn't like - using strip tags would stop the php but also the html.... try something like... [code] <?php $lookfor = array( '/(<\?)(?!>)*/', '/microsoft/') $replace = array( '', 'midocresoft'); $string = preg_replace($lookfor,$replace, $_POST['string']); ?>[/code] The ordering of the elements in the array ARE important $lookfor[2] will be replaced by $replace[2]...
  16. do you mean creating a function on-the-fly??? the only thing that would help is eval adn you create a string of teh whole function based on what ever info you feed that function.
  17. Regular expression allow you to check/manipulate large strings based on very small parts of it. An example - Like this site where ever someone enters the word 'php' you want to link it to php.net string is "I progam in php because it is not made by microsoft and its dead nice and you can do loads with php." $string = preg_replace('/(php)(\.| )/','<a href="http://www.php.net">\\1</a>\\2',$string); should return... I progam in <a href="http://www.php.net">php</a> because it is not made by microsoft and its dead nice and you can do loads with <a href="http://www.php.net">php</a>. Basically it allows you to control all manner of aspects of the string or get all manner of info from a string based on small parts of it without you having to know the exact content of the string before hand.
  18. Non! in your script that processes the entry of the blog you simply need to check the value of the public button - it sounds like you are using a check box. If so you only need to check if the variable has been set (checkboxes and radio buttons if not selected do not post that variable to teh accepting script!) input type=checkbox name=chk id=chk if (isset($_POST['chk])) { ... } Now all you need do then is if it is set add a value to the field (assumed `display` in the following query) in you database that can be compaired to see if it should be displayed or not. Once that is complete then your query would in clude... SELECT * FROM blogtable WHERE `display` = 1
  19. try... if ( $start == '2006-04-19 13:51:59') { echo "SERVER DOWN"; } else { echo mysql_result($runtime,"runtime"); }
  20. If you are checking that in the constructor you can check it in the script that instantiate the class before you instantiate it. Alternatively you can call the __destructor function to clean up the bits neccessary.
  21. I personally think using css is the best way to skin a site. Once you have some good css behind you then you can pretty do what you want. Having looked at a couple of of the shelf php aps like osdate and joomla I think the system they use is awful. If you need inspiration on the potential of css then visit css zen garden.
  22. Somewhere before your switch statement have the following... $id = $_GET['id'];
  23. Been busy on here today!!! OK a quicky I want to replace "; " with ;(carriage return) that is a semi-colon and a carriage return (not the words!!!!! ;)) $string = preg_replace('/; /',';\r,$string); aint working (tried \\r too) Any help much appreciated
  24. another oop prob!!!! I want to use an attribute created in a child class in its parent - not having much luck. The impudent child!!! [code] <?php class login_check extends page { public function draw_loginform() {   $username    =    isset($_POST['username'])    ?    $_POST['username'] : NULL;   $this->loginhtml = <<<HTMLSTART <div id="loginform"> <form action="cmslobby.php" name="loginfrm" id="loginfrm" method="post" enctype="application/x-www-form-urlencoded" target="_self" lang="en" dir="ltr">   <label lang="en" dir="ltr" for="username">Username:</label> <input name="username" type="text" id="username" tabindex="1" title="UserName" dir="ltr" lang="en" size="10" maxlength="20" value="$username"><br />   <label lang="en" dir="ltr" for="password">Password:</label> <input name="password" type="password" id="password" tabindex="2" title="Password" dir="ltr" lang="en" size="10" maxlength="20"><br />   <input type="hidden" name="refurl" id="refurl" value="$this->self">   <input name="login" type="submit" id="login" tabindex="3" title="Login" dir="ltr" lang="en" value="Login"><br /> </form> </div> <div class="clear"></div>          HTMLSTART; } ?>[/code] The disspaing parent... [code]<?php class page { public function pagehead_Section () {   echo <<<HTMLSTART <div id="header"> <h1><a href="/admin/cmslobby.php" target="_self" title="Foundry CMS Home"><span>Foundry CMS</span></a></h1> HTMLSTART;   echo login_check::$loginhtml;   echo <<<HTMLSTART </div> HTMLSTART; } } ?>[/code] Other properties exist in there of course but these are the bits I can't get to work. The error returned is: Fatal error: Access to undeclared static property: login_check::$loginhtml in C:\Program Files\Apache Group\Apache2\htdocs\nas\admin\includes\class\page.inc.php on line 99 For those incredibly sharp people teh $this->self is set in the parent constructor function and is $_SERVER['PHP_SELF'] - but that has no bearing on the error returned... Any help much appreciated.
  25. I am assuming you have something like... $arr = array('London', 'Paris'); ... <select name="sel"> <option value="0">London</option> <option value="1">Paris</option> </select> now there are two ways of doing this... either change the html to this <option value="London">London</option> <option value="Paris">Paris</option> or (and probably more useful!) in the script accepting the data have your array(s) once more $arr = array('London', 'Paris'); and then user $arr[$_POST['sel']]
×
×
  • 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.