Jump to content

Brandon_R

Members
  • Posts

    115
  • Joined

  • Last visited

    Never

Posts posted by Brandon_R

  1. What are you trying to do? Are you trying to change the statement '$age = 0' in a php file to the value of age passed in the form? If so you will need to use string literals to built the query to search for ie '$age = ' and the post value to built the replace ie '$age = ' . $_POST['age']; and then search and replace it in the file and then rewite the new code in the file.

     

    $fileContents = file_get_contents('oldfile.php');

    $newFile = str_replace('$age = 0;', '$age = ' . $_POST['age'], $fileContents);

    file_put_contents('oldfile.php', $newFile);

  2. I actually want to match the entire psp code from an html page. Say we have a page with html such as title, head, meta, content etc. I want it to pull those psp codes from the page and hopefully into an array, one code per array element. It matches the code some times and other times it just doesn't get a match.

  3. I created a regex to match psp codes from full to basic

     

    #!!999999999 Monies

    0x00000000 0x00000000

    ;this is a comment

    0x00000000 0x00000000 ; Mod this

    ;mod this

     

    #Hello

    0x00000000 0x00000000

     

    Here it is

     

     

    (#!*.+[\r\n]*(?:(?:;.+[\r\n]*)*(?:0x[a-f0-9]{8}\s0x[a-f0-9]{1,8}(?:\s*;.+)*[\r\n]*)*)+)

     

     

    Can someone show me where i went wrong? Im pretty sure it's the newline as it checks for \r\n but im pertty sure on html pages its <br /> but still not positive. A Code can have one title and infinitly* many code lines followed by comment lines

  4. We have a winner - PFMaBiSmAd's post

     

    Facebook Like as an example - if someone likes a page they will click it if not then don't say anything. Kinda iterating the old saying (If you ain't got anything nice to say then don't say nothing).

     

    I am in favor of a one sided rep system like a "Like" OR "Thanks" system and not a double sided one like ratings/thumbs up or down etc as those can cause trouble.

  5. Hello guys, i wrote a regex to capture a repeated group but instead it repeats the captured group only getting the last line matched.

     

    I wanted it to match

     

    _C0 Infinite LP (8000)

    _L 0x110E6938 0x00001F40

    _L 0x110E6940 0x00001F40

    _L 0x110E6950 0x00001F40

    _L 0x1162A528 0x00001F40

     

    With name tags so after the PHP regex has run, codeTitle would contain the stuff after _C0 and codeAddresses would be an array with all the lines on the left such as 110E6938, 110E6940 etc and codeValues would be an array with all the stuff on the right. So far i have

     

    ((?P<gameCodes>(_C0\s(?P<codeName>.+)\r\n(_L\s0x(?P<codeAddress>[a-f0-9]{8})\s0x(?P<codeValue>[a-f0-9]{8})(?:\r\n)?)+)))+

     

    but that doesn't work. It only gets the last line and sometimes it doesn't even do that :D can you guys help?

  6. Could you guys share some websites built using the zend framework? Doesn't have to be opensource, i want to check out loading times, see what the zend framework is capable of etc? The websites can be a total zend framework application or just a part of it but i perfer total website built using the zend framework.

     

    In addition, some zend framework scripts could be helpful so i can see how it's used etc.

  7. It's better practice to have the function getName() to return private variables, as that name should be. Simply replace your echo with return and then it shall work. Then to  place the name in an array create a variable like $person = array('name' -> $name); then it shall work. Then to add other values to the array $person['age'] = $age etc.

     

    On a side note since you are just beginning, you shouldn't head right in to OOP as it can be confusing if you don't know the basics.

  8. <?php
    
    $teams = mysql_query("
    SELECT teamid
    FROM team
    WHERE ladderid = $ladder
    ORDER BY teamid
    ");
    
    while ($team = mysql_fetch_array($teams))
    {
    $gamesWon = mysql_query("
    	SELECT matchid
    	FROM matches
    	WHERE winnerid = $team[teamid]
    ");
    $gamesWonCount = mysql_num_rows($gamesWon);
    
    $gamesLost = mysql_query("
    	SELECT matchid
    	FROM matches
    	WHERE loserid = $team[teamid]
    ");
    $gamesLostCount = mysql_num_rows($gamesLost);
    
    echo "
    	Games Won: $gamesWonCount,
    	Games Lost: $gamesLostCount,
    	ToTal Games Played: ($gamesWonCount + $gamesLostCount)
    ");
    }
    
    ?>

  9. holy crap it's true! if you add 317 to your current post count, you get... 456!!

     

    That may be what's known as a 'special case' rather than universally applicable.

     

    Whatever!! Being a creative genius, I decided to use my first name and the initial of my surname for my username here.  Quite a story!!

     

    Same story with andy just i put an underscore between them.

  10. An api usually outputs the data as XML so you can have id, title etc as XML tags and the value of that inside the tag. You would need to use a mysql query to pull the data and then use DOM etc to insert the data into a tag and output it. Then the client site would use DOM to get the XML and parse it and output it to their visitors.

  11. Adding onto the SEO suggestion the above posted suggested, the regex i would use for a nice SEO friendly name will be

     


    '#^[A-Z0-9._-]#si'
    [/cODE]

     

    Basically that allows any alphanumeric character, an underscore, a dash or a period.

     

    You might want to add or remove constraints as you wish. Windows doesn't allow slashes, arrows, colon, asterick, question mark bar or quotation marks in file names so you might want to prevent files to be named this incase a user downloads the file and gets an error on his/her windows pc.

  12. Oh i thought you meant a normal variable created outside the function and you want access to it inside the function,

     

    Session is just one of the superglobals and can be referenced in the globals array.

     

    $GLOBALS['_SESSION']['user_id']

     

    would contain the same as

     

    $_SESSION['user_id']

     

    can be used anywhere, ie in functions etc

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