Jump to content

Tjorriemorrie

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Everything posted by Tjorriemorrie

  1. Thanks Arne, I'll have to check that. I got it working as 'lastUpdate'. Weird. Also, the value should be long, therefore it should not be date('r', $blog->date) but just $blog->date. Thanks for the reply. Tjorriemorrie
  2. Hey, I'm trying to build my own feed after the user has created or edited a post. However, even though I set the pubDate in the entries, Zend still goes and overwrite it with the current timestamp, even worse the timestamp is in the wrong timezone Can anyone help me figure out how to set the pubDate of the entries as per the date of the data? private function setXml() { function cmpEntries($a , $b) { $a_time = strtotime($a['pubDate']); $b_time = strtotime($b['pubDate']); if ($a_time == $b_time) { return 0; } return ($a_time > $b_time) ? -1 : 1; } $entries = array(); $blogDb = new Model_Blog(); $blogs = $blogDb->getAllBlogs(); foreach ($blogs as $blog) { $entry = array( 'title' => $blog->title, 'link' => 'http://www.aviyacrest.com/index/blog/entry/' . $blog->id, 'description' => htmlentities(nl2br($blog->description)), 'pubDate' => date('r', $blog->date) ); array_push($entries, $entry); } $poemsDb = new Model_Poem(); $poems = $poemsDb->getAllPoems(); foreach ($poems as $poem) { $entry = array( 'title' => $poem->title, 'link' => 'http://www.aviyacrest.com/index/poems/entry/' . $poem->id, 'description' => 'New poem from Aviya.', 'pubDate' => date('r', $poem->date) ); array_push($entries, $entry); } usort($entries, 'cmpEntries'); $feed = array( 'title' => 'Aviya', 'link' => 'http://www.aviyacrest.com', 'charset' => 'UTF-8', 'entries' => $entries ); $rss = Zend_Feed::importArray($feed, 'rss'); $rssFeed = $rss->saveXML(); try { $fh = fopen(PUBLIC_PATH . '/blog.xml', 'w'); fwrite($fh, $rssFeed); fclose($fh); return true; } catch (Zend_Exception $e) { $this->message = $e->getMessage(); return false; } } Here's an extract of the xml file: <item> <title><![CDATA[Fragile]]></title> <link>http://www.aviyacrest.com/index/blog/entry/21</link> <description><![CDATA[understand others by understanding yourself]]></description> <pubDate>Thu, 11 Jun 2009 13:15:31 +0000</pubDate> </item> <item> <title><![CDATA[We have done the same]]></title> <link>http://www.aviyacrest.com/index/poems/entry/17</link> <description><![CDATA[New poem from Aviya.]]></description> <pubDate>Thu, 11 Jun 2009 13:15:31 +0000</pubDate> </item>
  3. Hey, I just switched to phpDesigner 2008. I opened my project folder which is using the zend framework and i got these errors: Warning: strpos() [function.strpos]: Empty delimiter in C:\wamp\www\thelivingtree\library\Zend\Controller\Request\Http.php on line 493 this one happened 3 times. code: if (0 === strpos($requestUri, $baseUrl)) { // full $baseUrl matches $this->_baseUrl = $baseUrl; return $this; } if (0 === strpos($requestUri, dirname($baseUrl))) { // directory portion of $baseUrl matches $this->_baseUrl = rtrim(dirname($baseUrl), '/'); return $this; } if (!strpos($requestUri, basename($baseUrl))) { // no match whatsoever; set it blank $this->_baseUrl = ''; return $this; } and Zend_Session_Exception: Session must be started before any output has been sent to the browser; output started in C:\wamp\www\thelivingtree\library\Zend\Controller\Request\Http.php/493 in C:\wamp\www\thelivingtree\library\Zend\Session.php on line 419 this seems to be errors phpDesigner gives with the library of the zend framework. Anybody know how to get around these?
  4. Sorry, can you please explain that to me a bit more, I'm still stuck
  5. Hey, as the title says, my images doesn't show in the browser. I'm saving the absolute path of the images in my database (using absolute as I'm testing locally using wamp). When i put those paths in an img tag, the image doesn't show. IE doesn't show the red 'broken link' cross, but the image placeholder icon, so I'm not sure why it just doesn't show the picture. Here is the code: <?php echo "<p>Name: " . $left["picpath"] . "</p>\r\n"; echo "<p>Size: " . $left["picsize"] . "</p>\r\n"; echo "<p><img src=\"" . $left["picpath"] . "\" /></p>\r\n"; print_r($left); ?> Here is its page source: <p>Name: F:\pictures other\art\22903721.jpg</p> <p>Size: 97812</p> <p><img src="F:\pictures other\art\22903721.jpg" /></p> Array ( [id] => 1518 [picpath] => F:\pictures other\art\22903721.jpg [picsize] => 97812 [picstats] => [lastupdate] => 0000-00-00 00:00:00 ) Any help appreciated!
  6. Hey, if anyone can please check my code for me. I want to update a record, i select the entry from the list, but when i click the button, no post values exist. No errors, and it's not updated. Here's the code to update (at top of file): It updates the one record setting one field as the id of another field (as the followup or required) and does the reverse for the other record involved. // ========== UPDATE RECORD ========== if ($_POST['Submit'] == 'Set required' || $_POST['Submit'] == 'Set followup') { // Get parameters from form $id = $questID; $questToSetID = $_POST['questToSet']; // Do update statement if ($_POST['Submit'] == 'Set required') { $query = "UPDATE quests SET ReqQst='$questToSet' WHERE QID='$id'"; print($query); $queryVV = "UPDATE quests SET FolQst='$id' WHERE QID='$questToSet'"; print($queryVV); } elseif ($_POST['Submit'] == 'Set followup') { $query = "UPDATE quests SET FolQst='$questToSet' WHERE QID=$id"; print($query); $queryVV = "UPDATE quests SET ReqQst='$id' WHERE QID='$questToSet'"; print($queryVV); } else { unset($query); unset($queryVV); } Connect(); // Do update if (mysql_query($query)) { if (mysql_query($queryVV)) { $updateGoTo = 'RecSeries.php?qst=' . $questID; header("Location: $updateGoTo"); } else {echo '<h1>ERROR updating vica versa quest!</h1>'; exit;} } else {echo '<h1>ERROR updating quest!</h1>' . var_dump($_POST); exit;} } // ========== END update record ========== Here is one of the lists to select: the values appears fine, but it's like no post values are submitted. I have put a print_r($_Post) on top file and when this submit button is pushed, the post array is empty, but the method="post", so i'm clueless as to why nothing gets posted. $questsInZone = GetQuestsInZone($zone); //$questsInZone = array("null" => "<none>") + $questsInZone; // 3A - REQUIRED // if ($setValue == 'req') { ?> <form id="form" name="form" method="post" action="RecSeries.php?qst=<?php echo $questID; ?>"> <p><span id="spryselect5"> <label for="questToSet">Required quest:</label> <select name="questToSet" id="questToSet2"><?php foreach ($questsInZone as $reqQuestID => $reqQuestName) { $reqQuest = GetQuestInfo($reqQuestID); if (empty($reqQuest['FolQst']) && $reqQuest['Faction'] == $quest['Faction'] && $reqQuestID != $questID) { ?> <option value="<?php echo $reqQuestID; ?>"><?php echo $reqQuestName; ?></option><?php } } ?> </select> <span class="selectRequiredMsg">Please select an item.</span></span></p> <p><input type="submit" name="Submit" id="Submit" value="Set required" /> </p> </form> I think the problem is nothing gets posted when I click the Set required button. Any help appreciated!
  7. [sOLVED] // get key if ($key = array_search($questID, $obtained)) { $found = true; } elseif ($obtained[0] == $questID) { $key = 0; $found = true; } else { $found = false; } //remove if found if ($found) { unset($obtained[$key]);
  8. Hey, I've used Excel's standard deviation and confidence functions, and I'm looking for something similar in php. I used the standard deviation for the confidence, giving me a conservative and aggressive 'boundry' from the average. I couldn't find it http://www.w3schools.com/php/php_ref_math.asp What I'm looking for is to get a calculated minimum/conservative value and maximum/aggresive value for an array's values. Does anybody have functions or something that I can use?
  9. Thanks rhodesa!! that explains it! OK, but it is not to say the result will be the first key, it could stretch into thousands in the end. So my code was all wrong, coz it has that error if it's the first record and returns 0 which equates to false. Is this better? Also, can I now take out the reset($array); ?
  10. I have problems figuring this out. I expect it to remove the number and set the cookie again, but it gives this error: Quest 132 not found in obtained: Error in search! array(1) { [ 0 ] => string(3) "132" } Here's the code: // remove qst, implode, and set reset($obtained); if ($key = array_search($questID, $obtained)) { unset($obtained[$key]); $adjObtained = implode(" ", $obtained); if (setcookie("obtained$s", $adjObtained, time()+86400*30)) { $goto = "setquests.php?sel=" . $s . "&drop=" . $questID; header("Location: $goto"); } else { echo '<h1>Cookie could not be set!</h1>'; ?><pre><?php var_dump($adjCompleted); ?></pre><?php exit; } } else { echo "<h1>Quest $questID not found in obtained:</h1>"; ?><pre><?php var_dump($obtained); ?></pre><?php exit; } Can anyone please help? It seems as soon as the array is only 1 size big, it can't find the value...or maybe it can't find the first value... sigh, please help
  11. OK, finally google helped me with the global question: So I've changed the both $rsAll to global: mysql_select_db($database_connWoW, $connWoW); $query_rsAll = "SELECT * FROM quests WHERE Faction = 'Horde'"; global $rsAll; $rsAll = mysql_query($query_rsAll, $connWoW) or die(mysql_error()); $row_rsAll = mysql_fetch_assoc($rsAll); $totalRows_rsAll = mysql_num_rows($rsAll); function GetCloseQuests ($low, $high, $level) { global $rsAll; mysql_data_seek($rsAll, 0); $row_rsAll = mysql_fetch_assoc($rsAll); However, the error is still the same: WTF does 7 mean? Please help me!
  12. Hey, I have a file that only has php functions in it. I've also included a recordset in that file. First question is if I am using the recordset result correctly, I made the result global in the function, is it right? Secondly, I get this error and I don't understand it. Can anyone help to resolve this? code from file: mysql_select_db($database_connWoW, $connWoW); $query_rsAll = "SELECT * FROM quests"; $rsAll = mysql_query($query_rsAll, $connWoW) or die(mysql_error()); $row_rsAll = mysql_fetch_assoc($rsAll); $totalRows_rsAll = mysql_num_rows($rsAll); function GetCloseQuests ($low, $high, $level) { global $rsAll; mysql_data_seek($rsAll, 0); $row_rsAll = mysql_fetch_assoc($rsAll); etc
  13. Hey! I used the insert record which is provided by Dreamweaver. And i have a page insertcomplete.php where it redirects to after it was inserted. However, now i need to also carry over 2 variables via GET. Here's the default code: $insertGoTo = "insertcomplete.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); I have to add the $kingdom and $zone variables to that, e.g. "insertcomplete.php?kingdom=$kingdom&zone=$zone" , but ofcourse that doesn't work. any help appreciated!!
  14. [solved] this works: if (isset($_COOKIE['totalCount'])) { $CookInc = $_COOKIE['totalCount'] + 1; } else { $CookInc = 1; } setcookie('totalCount', $CookInc, time()+86400); I think $_COOKIE['totalCount']++ doesn't work...anyone knows why??
  15. Thanks! It's still not working though, but I've tried the following so it must be wrong somewhere? if (isset($_COOKIE['totalCount'])) { $cookInc = $_COOKIE['totalCount']++; setcookie('totalCount', $cookInc, time()+60000); } else { setcookie('totalCount', 1, time()+60000); } I think the cookie doesn't save or something It keeps being at 1. Am I setting it correctly?
  16. hey everyone! Got this little cookie problem. Basically suppose to work like a count for the total number of pages the user have loaded. Somehow the value never gets past 2. So freakin weird. Please help: if (isset($_COOKIE['totalCount'])) { $_COOKIE['totalCount']++; } else { setcookie('totalCount', 1, time()+60); } It works for the session though: if (empty($_SESSION['count'])) { $_SESSION['count'] = 1; } else { $_SESSION['count']++; } Don't know why the cookie gets stuck at 2
  17. Thanks BlueSkyIS. The other thing is that I want to put an if in. True will let it load and false won't let it load. So I was hoping this would've worked I guess I have to just ignore the sleep all together. Sigh, I hate it when I can't implement functions
  18. Hey, for simplicity: the user is at page1. from there it's redirected to page2. then page2 will redirect it to page1. I have the redirection going fine, but the problem is that I want page1 to show "Loading...", then wait for 3seconds and then start loading page1. So far I have: (note I'm only getting my toes wet, just trying to see how things work, thus redirect excl). <?php $goto = $_SESSION['URLvisited']; if (!$CookieIsSet) { echo "Cookie could not be set"; die(); } else { for ($i = 1; $i <= 10; $i++) { echo "Loading " . $i; sleep($i); } } I'm just trying to get it to work with that for loop. But it doesn't show each 'loading'. Page2 stays blank and then throws the timeout error (which is fine). How can I get echo's to show on the screen with sleep() inbetween? Secondly, how is my script different from the example in the manual?? (coz mine isn't working ) <?php // current time echo date('h:i:s') . "\n"; // sleep for 10 seconds sleep(10); // wake up ! echo date('h:i:s') . "\n"; ?>
  19. Thank you. Me too appreciate clear answers much more.
  20. Hey, I have a table Comments and a recordset rsComments for that table. I want to show the comment with the date it was submitted. <?php do { ?> <p class="commenter"><?php echo $row_rsComments['name']; ?> said: <span class="CommentDate"><?php echo " (on ".date("d M y", $row_rsComments['CommentDate']).")"; ?></span></p> <p class="commentleft"><?php echo $row_rsComments['comment']; ?></p> <p> </p> <?php } while ($row_rsComments = mysql_fetch_assoc($rsComments)); ?> Somehow when I test it it always returns 1 Jan 1970. Please take note I'm not familiar with php date() function PS: the CommentDate field is timestamp in MySQL, is that ok? The value lookin in phpMyAdmin shows 2008-03-24 21:16:20. Can anyone help me with this?
  21. Hey, was hoping someone can help me. What is the -> and => operators? And what are they called? How do they work? Thanks!
  22. Amount $100 VAT $17.50 (100 x 17.5%) Total $117.50 Thus: $total = $price * (1+ $vat/100); or do it in two steps $VATrate = 17.5; $VATamt = $price * $VATrate; $total = $price + $VATamt;
  23. Hey, sorry, I don't know if I'm just blind, but where is the RSS feeds for the forum??
  24. Hey ever1, I'm having problems with my form. In the (same) form there is two menu's/lists. Both of the menus have the same 6 options. But, I want the second menu to exclude whatever the person have chosen in the first menu... I think I have to throw in if's with each <option> in the html. Am I thinking along the right path? If I am, then what values/equation must be behind the if? Should it be something like select.name!=option.value THEN option.unchosenvalue ? BTW, can anyone recommend good articles on forms? I can't find anything that really explains well... Thanks, Total Noob
×
×
  • 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.