Jump to content

robcrozier

Members
  • Posts

    175
  • Joined

  • Last visited

    Never

Posts posted by robcrozier

  1. Thanks for that MasterACE14, however, will that code actually find the relevant text in the document, without the text referencing it (e.g. like a function or something)?  It's Joomla thats actually generating the code from the database on the fly you see.  So i cant actually link that sentence to the php code that you have just supplied.  Or can i?  Any further assistance would be appreciated.  Cheers.

  2. Hi Guys, i'm using Joomla for a current project and theres one certain sentence that does Joomla has not wrapped with sufficient tags in order to let me style it in the CSS.  I'm therefore trying to discover how i might go about finding this sentence using PHP (i know what the full sentence is) and then wrap <p></p> tags around it.  I can then also include a class in the tags and thus use CSS to style the sentence.

     

    Any help would be great, cheers!

  3. Hi guys.

     

    I wonder if any of you can help me with what i think is a basic piece of code.  Basically, i have three form fields which accept numeric data and i would like to add the first two and then subtract the third and output the result in real time on the browser.  I just can't seem to find what I'm looking for in Google etc.

     

    Any help would be appreciated!

     

    Cheers

  4. Hi.

     

    Basically what i'm trying to do is compare two floating point numbers in order to see if one is less than or equal to the other, and if so proceed with extra functionality.  If not, an error is displayed.

     

    Here's that very simple code that i'm using:

     

    if ($var1 <= $var2)
           echo "proceed";
    else
          echo "dont proceed";
    

     

    This code works absolutely fine on all floating point numbers (so far) except if both vars are 17.99.  If this is the case the compare does not see the two numbers as equal, it sees var2 as less than var 1!?

     

    I've used the is_numeric() function just to make sure that both numbers are being treat as numeric by the script... and they are.  I've also used the htmlentities() function to make sure that no html tags etc are part of the var... and once again it's all fine!?

     

    Any suggestions?  It's doing my head in!

     

    Thanks

  5. Hi guys, i'm not sure if i'm posting this in the right forum or not but here goes.  Basically i want to know if there's any way (or any program) that can log the activity of a PHP file as it's being executed on the server.

     

    Basically a couple of my PHP scripts are running a bit slow and i'm not sure where the problem lies.  If i could see exactly where the process begins to slow down this would help a great deal.

     

    Any help or advice appreciated!

     

    Cheers

  6. Hi all,

     

    I've got a bit of a complex online auction site under development at the minute and i'm having a bit of trouble with a surprisingly basic thing, navigation.  On this site; users can find themselves delving deep within it if you know what i mean and i want to provide appropriate back links on each page so that the user can always navigate back and forth one stage at a time.  However, i need something that's going to remember what the previous referring page was even if the user navigates 2-3 pages in front and needs to get back for some reason.  I need something that isn't going to get thrown off or confused if the page is refreshed by the user too.

     

    Any suggestions to good sites, tutorials etc?

     

    thanks all!

  7. Hi, i wonder if anyone could suggest how i would go about this?

     

    Basically i have two tables (table1, table2).  Within table1 there is one column (ID) and within table2 there are two columns (ID, time).  The ID's reference one another too. 

     

    What i'm trying to do is select all distinct ID's from table1 and then order the results by 'time' which is in table2.

     

    Can anyone suggest how this can be done as i just can't get my head around it.  MySQL is not my strong point!

     

    Thanks all!

  8. Hi guys,

     

    I wonder if anyone can help or even point me in the right direction with this one?

     

    Basically what i'm trying to do is allow a user to upload an image via a form and then have php re-size it (proportionately) and also reduce the size of the image file in the process.  Basically, the upload stuff is done and im also watermarking the images on upload, so the file would need to be re-sized etc before the watermarking takes place.

     

    For instance, a user uploads a file with dimensions: H600px and W300px.  I want to be able to reduce the image so that it has a width of say 100px and the height to be reduced proportionately.  It is also important that the overall file size is reduced too in order to save disc space and image load time.

     

    If anyone has any suggestions, or knows of any good sites etc that might point me in the right direction this would be great!

     

    Thanks in advance

  9. Hi,

     

    I wonder if someone can help me here.  I'm trying to use addcslashes to escape data that is inserted into my mysql database.  The function IS working (does add slashes to the string to be inserted) however when the actual string is inserted into the database, the slashes are not present?  They simply don't show up?

     

    Is there any specific reason for this?  I was of the impression that you addslashes()/addcslashes() when inserting and the stripslashes() when retrieving.

     

    Any help would be appreciated, thanks!

  10. Hi,

     

    what i'm trying to do is add a given duration (as supplied by a user via a form field) - i.e. 3days, to the current time.

     

    So basically, i want to take the current time, add the specified duration to it (e.g. 3 days) and then return the output date in this format: Y-m-d H:i:s.

     

    I'm getting really confused and just can't figure it out.  Here's what i'm currently using, though it's outputting completely the wrong date+time.

     

    
    $current_time = date('Y-m-d H:i:s');
    $duration_timestamp = $duration * 86400; 
    $now = convert_datetime_db_format($current_time); // function that converts to timestamp 
    $end_datetime = $now + duration_timestamp;
    $end = date('Y-m-d H:i:s', $end_datetime); // final date = WRONG!!!
    
    

     

    Any help appreciated!  cheers!

  11. Haha, you know what... i was just about to report this topic as solved as i had just came up with the same resolution.  It's typical after sitting staring at it for ages and then posting the problem on here that i come up with the solution myself.

     

    Thanks a lot for your time anyway mate!

  12. Hi,

     

    I wonder if anyone can offer any assistance with regard to this problem?

     

    What im trying to do is assign a var in one script that contains a partial URL e.g:

    
    $var = page.php?var1=bla&var2=bla2
    
    

     

    Now.. what i want to do is pass $var through the URL to another script.  It's the way that i need to pass the var that#s causing the trouble.  What i need to do is pass $var through the URL contained within another var.  e.g:

     

     

    
    header("Location:new_page.php?var2=$var");
    
    

     

    As you can probably now see, the way in which the var is being passed is causing only the first part of $var to be passed through the URL (up to the 1st '&').  This is because it thinks that this is the start of another variable that is being passed through the URL.

     

    Does anyone have any suggestions as to how this could be worked around?  I need to pass $var all in one, contained within the URL var.

     

    I hope this makes sense, lol.

     

    Thanks for your time in advance!

  13. Hi,

     

    what i'm trying to do is display the duration between two dates in a similar format to that seen on eBay lots.  For example 1d, 2h, 23m.

     

    I have some code already that does most of the job, here it is:

    
    function dateDiff($from,$to) 
    {
      $diff = $to - $from;
      $info = array();
      if($diff>86400) {
    	//one or more days
    	$info['d'] = ($diff - ($diff%86400))/86400;
    	$diff = $diff%86400;
      }
      if($diff>3600) {
    	//one or more hours
    	$info['h'] = ($diff - ($diff%3600))/3600;
    	$diff = $diff%3600;
      }
      if($diff>60) {
    	//one or more minutes
    	$info['m'] = ($diff - ($diff%60))/60;
    	$diff = $diff%60;
      }
      else {
    	//less than 1 min
    	 return $diff."s";
      }
      $f = '';
      foreach($info as $k=>$v) {
    	if($v>0) $f .= "$v$k, ";
      }
      return substr($f,0,-2);
    }
    
    

     

    However....  the problem occurs with the number of hours that it displays.  It seems to add 12 hours to the display.  For example if there is 1h, 20m left, this function displays 13h, 20!

     

    Can anyone suggest why this is?  I'm pulling a datetime field strain from mysql and converting it to timestamp using strtotime() if this helps?

     

    I have a js function that does the same thing using the same datetime values (only difference being that it is a live counter) and it works fine?

     

    Thanks!

  14. Hi everyone, i will first of all make you aware that i am completely useless at regular expressions. 

     

    What i'm trying to do, and what i hope one of you lot will be able to help me with is to validate a name that is submitted through a form.  Basically i want to ensure that the name only contains letters, nothing else.

     

    Here's what i currently have

    
    if (!preg_match("/[a-zA-Z]/", $var))
    
    

     

    Now, it validates to a certain extent, however it allows you to enter things like semi colon's and apostrophe's etc in the middle of words.

     

    Can anyone help??? Thanks!

  15. Hi everyone, i wonder if anyone can tell me how i could find the difference between two datetime values that are taken from a MySQL database.  I want the difference between the times to display something like: 1d 2h 23m.

     

    I've done a bit of research and all i can find is how to ind the difference between two times or two dates separately.  I'm not even sure if a datetime difference can be found?

     

    Can anyone help?

     

    Thanks

  16. Hi, i wonder if anyone could tell me how i could find a non specific substring of a given string.  Basically i want to find a 5-digit integer value within a long string.  I know that there will only be one 5-digit integer within the string so i suppose this makes it possible, i'm just not sure how to go about it?

     

    I know that substr() will work if you know what the substring actually is (i.e '12345' as oppose to a 5-digit unspecified integer)

     

    Any suggestion would be great as it's doing my head in.

     

    Thanks

  17. Hi everyone, i have a problem at the min that is doing my head in!

     

    OK what i have is a form, within it is a loop.

     

    Each time this loop is executed a number of queries is stored within an array (may be 1, may be 5 queries etc). I think this bit's going fine.

     

    OK, now what i want to do is pass this array of queries to another script when the form is submitted so that they can be executed etc. i dont want the queries to be executed until the form has been submitted.

     

    ill collect the array of queries a bit like this when they are received:

    $x = 0;
    while (is_array($queries[$x])) 
    {
      $query = $queries[$x]; 
      echo $query;
      $x ++;
    }

     

    how can i get the array of queries passed from the form to the script which will handle them?

     

    any help appreciated, cheers

     

×
×
  • 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.