Jump to content

KrisNz

Members
  • Posts

    271
  • Joined

  • Last visited

Posts posted by KrisNz

  1. Hi, I have a query like this..

    SELECT `franchiseid` FROM `franchise` WHERE CONCAT(',', `postcodes`, ',') LIKE '%,7895,%' LIMIT 1
    

     

    which searches data like 1021,1024,7895 etc

     

    It mostly works, however, it doesn't match on the last item - in this case 7895. I can't see why it doesn't work when the concat puts the extra commas in I thought it would need to match. Can anyone suggest a fix or a better method?

     

    Thanks.

     

  2.             echo header("Content-type: application/xml");
                $dom = new DOMDocument('1.0');
                $dom->preserveWhiteSpace = false;
                $dom->formatOutput = true;
                $dom->loadXML($xmlobj->asXML());
                echo $dom->saveXML();
                exit;
    

  3. There's a few issues there, In the loop you reset $lastnameList on each iteration (that's why you only got the last result, however you don't need that loop at all) and array_push is only useful if you want to add more than 1 variable to an array as the function takes multiple arguments.

     

    Try this instead...

    $query = mysql_query('SELECT `lastname` FROM `names`') or trigger_error(mysql_error(),E_USER_ERROR) ;
    $lastnameslist = array();
    while ($namesArray = mysql_fetch_assoc($query)) {
        $lastnameslist[] = $namesArray['lastname'];
    }
    print_r($lastnameslist);
    

  4. ahh ok, first of all, change your checkbox field names from winner to winners[] - this will allow multiple values to be posted back (i.e an array). You then need to loop through each value that was posted back and update it e.g

     

    foreach ($_POST['winners'] as $key => $teamId) {
        mysql_query("update picks set result = 'w' WHERE winner = '$teamId' AND result = 'o' ") or die(mysql_error());
    }
    

     

     

  5. If I understand the problem correctly (you want to find, in a string, if theres at least one word longer than 20 characters),I think your original regex would work if you took out those anchors (the ^ and the $).

     

    <?php
    $desc = <<<EOF
    
    This is a test sentence with
    a supercalafragalisticexpialedocius
    word
    
    EOF;
    
    if (preg_match("/\S{20,}/",$desc)) {
        echo "match";
    } else {
        echo "no words longer than 20 chars";
    }
    ?>
    

  6. Your syntax is just a little muddled...

     

    <?php
    $row['UID'] = '&a234#304'; //a value that needs encoding
    ?>
    
    <a href="edittenantformt.php?uid=<?php echo urlencode($row['UID']); ?>">Edit My Details</a>
    
    <?php
    //and then on the edit tentant form...
    $uid = urldecode($_GET['uid']);
    ?>
    

     

     

     

     

  7. Having two $$ signs next to each other like that will also cause you problems. You need to escape the first one (like you've done in the display() function)

    e.g

    echo "\${$amount} added to account. Your current balance is \${$this->balance}</br>"; //note the {} aren't necessary but I like to add them for clarity.
    

  8. I'm definitely no expert but this works for me...

    <?php
    $xmlString = <<<EOF
    <?xml version="1.0" encoding="UTF-8"?>
    <player showDisplay="yes" showPlaylist="no" autoStart="yes" topTitle="Player" skinColor="2">
    <song path="mp3/beg.mp3" title="Omarion - Beg For It.mp3"></song>
    <song path="mp3/Show.mp3" title="Kat DeLuna - Run The Show"></song>
    <song path="mp3/wonder.mp3" title="Maroon 5 ft. Mims - Makes Me Wonder"></song>
    <song path="mp3/there.mp3" title="Sean Kingston - Take You There.mp3"></song>
    <song path="mp3/test.mp3" title="test.mp3"></song>
    </player>
    EOF;
    
    
    $oXml = new DOMDocument;
    $oXml->loadXML($xmlString);
    
    $player = $oXml->documentElement;
    
    $songs  = $player->getElementsByTagName('song');
    
    foreach ($songs as $song) {
        
        $title = $song->getAttributeNode('title'); 
        
        $path  = $song->getAttributeNode('path');
        
        if ($path->value == "mp3/test.mp3") {
        
            $player->removeChild($song);
        }
        
    }
    echo $oXml->saveXML(); //view source to see result!
    ?>
    

     

    Theres most likely a more efficient way but I hope that will get you started. Also, I don't think that short closing tags is allowed in XML.

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