Jump to content

zq29

Staff Alumni
  • Posts

    2,752
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by zq29

  1. I don't think your syntax is correct here, well, I have never seen ternary expressions written like that before...
    [code]$mpurpose = (!empty($purpose)) ? " AND purposes = '".$purpose."'" : "";[/code]
  2. Heres a list of functions that you could use to write your script...

    file() - To dump the contents of your text file into an array, loop through it with a foreach loop.
    strpos() - To see if your search term is found in the current line in the loop.
    array_push() - To put any matching lines into an array. Or, you could just use the $var[] = "string" method.
    explode() - To split up your matched lines into an array of words and define an index to return the correct word.

    Hope that helped some, I would write a demo script but I can't imagine it being quick to write, plus its nearly midnight here... Give it a go, any problems, post up your script and I'm sure you will be helped.
  3. Like this?
    [code]<script type="text/javascript">
    function ShowPrices(node) {
        var prices=node.value;
        document.getElementById('price').value=prices;
        document.getElementById('price').style.visibility="visible";
    }

    function Hideprice() {
        document.getElementById('price').style.visibility="hidden";
    }
    </script>

    <form name="test">
        Please, select an option:
        <input type="radio" name="pricing" value="£5.00" onclick="ShowPrices(this);">price A
        <input type="radio" name="pricing" value="£10.00" onclick="ShowPrices(this);">price B
        <br/><input type="text" id="price" value="£0.00"/>
        <br>
        <input type="submit" name="Request" value="Submit">
        <br><br>
        <input type="reset" name="Clear" value="Clear form" onclick="Hideprice()">
    </form>[/code]
  4. If you're not using any advanced rules for your replacements it would be better to use str_replace() instead of preg_replace(). In which case, you can use it like this:
    [code]<?php
    $search = array("old1","old2","old3");
    $replace = array("new1","new2","new3");

    $str = "old1 old2 old3";
    echo str_replace($search,$replace,$str);
    //The above will echo "new1 new2 new3"
    ?>[/code]
  5. As far as I can work out, the 11 character ASCII string [b]'m741007ë,W[/b] would only convert to a 33 character hexadecimal string. Printable ASCII characters are 3 hex characters long I think. Can you post up any code that you are using to receive the user data?
  6. Please be aware that this forum is not for requesting people to write you scripts - It is for requesting help with scripts that you are writing. But as this is a pretty easy task, here's something that will get you started:
    [code]<?php
    $data = "";
    $result = mysql_query("SHOW COLUMNS FROM `table`") or die(mysql_error());
    while($row = mysql_fetch_array($result)) {
        $data .= $row[0].",";
    }
    $data = substr($data,0,-1)."\r\n";

    $result = mysql_query("SELECT * FROM `table`") or die(mysql_error());
    while($row = mysql_fetch_assoc($result)) {
        foreach($row as $r) {
            $data .= "$r,";
        }
        $data = substr($data,0,-1)."\r\n";
    }

    $handle = fopen("data.csv","wb")
    fwrite($handle,$data)
    fclose($handle)

    echo "DONE.";
    ?>[/code]
    Please note, I have had to leave off the semi-colons after the file functions as there is a bug in the forum that refuses to post a reply with them on.
  7. [!--quoteo(post=370432:date=May 2 2006, 01:24 AM:name=askjames01)--][div class=\'quotetop\']QUOTE(askjames01 @ May 2 2006, 01:24 AM) [snapback]370432[/snapback][/div][div class=\'quotemain\'][!--quotec--]is that TechTV avatar because it look like the same.[/quote]Thats the logo for the Hip-Hop group Hieroglyphics.
  8. Topic moved to Misc forum.

    Core hacking is hacking PHP itself, not PHP scripts. Core hackers create PHP modules et cetera, its done at a low(er) level in C++ I think (I know its one of the C varients).
  9. You could try something like this...
    [code]<?php
    //Loop through all text files in a directory
    foreach(glob("path/to/files/*.txt") as $file) {
        $content = file($file);
        //Loop through each line in the file
        foreach($content as $line) {
            //Seperate the line by the pipe symbol into an array and display
            $temp = explode("|",$line);
            echo "<p>Image: $temp[0]<br/>Title: $temp[1]<br/>Flash: $temp[2]</p>";
        }
    }
    ?>[/code]
  10. First of all, the PHP Help forum is for specific PHP scripting problems, so I'll be moving this to a more relevent forum.

    Yes, I have done it - I have FreeBSD installed on an old machine: 800MHz CPU; 128Mb RAM; 10Gb HDD. But I mainly use this for learning the command line for FreeBSD as I have a couple of dedicated servers with the same OS on, if I want to do something on my live servers I test it out on my test one first so that I know what I am doing!

    For testing my PHP projects on, I just use my development machine which is running a WAMP set-up.
×
×
  • 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.