KrisNz
Members-
Posts
271 -
Joined
-
Last visited
Everything posted by KrisNz
-
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.
-
$a will always equal 1 in your code, your login function never gets called. Maybe do a search for some login tutorials to help you along.
-
You're missing a double quote. I'll let you find it
-
Are you sure it's not just that query that's failing? table is a mysql keyword, try putting `table` instead. You should add some error handling to your query method also.
-
Merging Arrays And Removing Duplicate Values?
KrisNz replied to Silky1284's topic in PHP Coding Help
What are all the loops for? If you print_r($arrayid) you get your desired output (more or less, you can sort() it if you want to get sequential keys). -
Try this... foreach ($object->Entries as $field_object) { echo $field_object->Field13.'<br/>'; } Obviously replacing $object with whatever variable you print_r'd.
-
So, if I understand correctly, you let people run whatever php code they want on your server?
-
The path you want to save to needs to include a file name, try if (ftp_get($resource, '/var/www/downloads/'.$files[$i], $files[$i], FTP_BINARY)){ Also recommend calculating the length of your for loop outside of the loop rather than in it. Or use foreach.
-
In what way does it not work? Is $data['sec1'] empty or does it not unserialize into whatever it was when you serialized it?
-
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;
-
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);
-
Is there any reason your array can't be structured like $['keyword'] = $timesAppearedOnPage; ??
-
that would be mysql_data_seek() you're looking for. But in your query you use $ordersid but the variable you initialize at the start is $orderid. Are you sure that's working?
-
What are you trying to do with this exactly?
-
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()); }
-
your checkboxes are called "winner" not "value", ie use $_POST['winner']. doing a print_r($_POST); might make things a little clearer for you as you'll see how the post array is structured.
-
escape it with mysql_real_escape_string() not htmlencode(). You shouldn't need to do anything else.
-
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"; } ?>
-
This might interest/help you... http://www.alistapart.com/articles/flashsatay/
-
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']); ?>
-
well then.....carry on
-
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.
-
http://dev.mysql.com/doc/refman/5.0/en/truncate.html
-
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.
-
[TOPIC SOLVED] Probably a very simple bracket problem....
KrisNz replied to HughbertD's topic in PHP Coding Help
semicolon.